Added: 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/repository/MockWorkflowRepository.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/repository/MockWorkflowRepository.java?rev=1653721&view=auto
==============================================================================
--- 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/repository/MockWorkflowRepository.java
 (added)
+++ 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/repository/MockWorkflowRepository.java
 Thu Jan 22 00:14:55 2015
@@ -0,0 +1,350 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.workflow.repository;
+
+//JDK imports
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+//OODT imports
+import org.apache.commons.lang.Validate;
+import org.apache.oodt.cas.workflow.structs.Workflow;
+import org.apache.oodt.cas.workflow.structs.WorkflowCondition;
+import org.apache.oodt.cas.workflow.structs.WorkflowConditionConfiguration;
+import org.apache.oodt.cas.workflow.structs.WorkflowTask;
+import org.apache.oodt.cas.workflow.structs.WorkflowTaskConfiguration;
+import org.apache.oodt.cas.workflow.structs.exceptions.RepositoryException;
+
+//Google imports
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+/**
+ * A mock {@link WorkflowRepository}.
+ *
+ * @author bfoster (Brian Foster)
+ * @author mattmann (Chris Mattmann)
+ */
+public class MockWorkflowRepository implements WorkflowRepository {
+
+   private Map<String, List<Workflow>> eventToWorkflowsMap;
+   private Map<String, Workflow> workflows;
+   private Map<String, WorkflowTask> tasks;
+   private Map<String, WorkflowCondition> conditions;
+
+   public final static String EVENT1_NAME = "Event1_Name";
+   public final static String EVENT2_NAME = "Event2_Name";
+
+   public final static String WORKFLOW1_ID = "Workflow1_Id";
+   public final static String WORKFLOW2_ID = "Workflow2_Id";
+   public final static String WORKFLOW3_ID = "Workflow3_Id";
+
+   public final static String WORKFLOW1_NAME = "Workflow1_Name";
+   public final static String WORKFLOW2_NAME = "Workflow2_Name";
+   public final static String WORKFLOW3_NAME = "Workflow3_Name";
+
+   public final static String TASK1_ID = "Task1_Id";
+   public final static String TASK2_ID = "Task2_Id";
+   public final static String TASK3_ID = "Task3_Id";
+   public final static String TASK4_ID = "Task4_Id";
+
+   public final static String TASK1_NAME = "Task1_Name";
+   public final static String TASK2_NAME = "Task2_Name";
+   public final static String TASK3_NAME = "Task3_Name";
+   public final static String TASK4_NAME = "Task4_Name";   
+
+   public final static String CONDITION1_ID = "Condition1_Id";
+   public final static String CONDITION2_ID = "Condition2_Id";
+   public final static String CONDITION3_ID = "Condition3_Id";
+   public final static String CONDITION4_ID = "Condition4_Id"; 
+
+   public final static String CONDITION1_NAME = "Condition1_Name";
+   public final static String CONDITION2_NAME = "Condition2_Name";
+   public final static String CONDITION3_NAME = "Condition3_Name";
+   public final static String CONDITION4_NAME = "Condition4_Name"; 
+
+   public final static WorkflowTaskConfiguration tConf = new 
WorkflowTaskConfiguration();
+   public final static WorkflowConditionConfiguration cConf = new 
WorkflowConditionConfiguration();
+
+   public MockWorkflowRepository() {
+      eventToWorkflowsMap = Maps.newHashMap();
+      workflows = Maps.newHashMap();
+      tasks = Maps.newHashMap();
+      conditions = Maps.newHashMap();
+
+      WorkflowCondition condition1 = new WorkflowCondition();
+      condition1.setConditionId(CONDITION1_ID);
+      condition1.setConditionName(CONDITION1_NAME);
+      condition1.setConditionInstanceClassName("some.class.path");
+      condition1.setCondConfig(cConf);
+      conditions.put(condition1.getConditionId(), condition1);
+
+      WorkflowCondition condition2 = new WorkflowCondition();
+      condition2.setConditionId(CONDITION2_ID);
+      condition2.setConditionName(CONDITION2_NAME);
+      condition2.setCondConfig(cConf);
+      condition2.setConditionInstanceClassName("some.class.path");
+      conditions.put(condition2.getConditionId(), condition2);
+
+      WorkflowCondition condition3 = new WorkflowCondition();
+      condition3.setConditionId(CONDITION3_ID);
+      condition3.setConditionName(CONDITION3_NAME);
+      condition3.setCondConfig(cConf);
+      condition3.setConditionInstanceClassName("some.class.path");
+      conditions.put(condition3.getConditionId(), condition3);
+
+      WorkflowCondition condition4 = new WorkflowCondition();
+      condition4.setConditionId(CONDITION4_ID);
+      condition4.setConditionName(CONDITION4_NAME);
+      condition4.setCondConfig(cConf);
+      condition4.setConditionInstanceClassName("some.class.path");
+      conditions.put(condition4.getConditionId(), condition4);
+
+      WorkflowTask task1 = new WorkflowTask();
+      task1.setTaskId(TASK1_ID);
+      task1.setTaskName(TASK1_NAME);
+      task1.setTaskConfig(tConf);
+      task1.setConditions(Lists.newArrayList(condition1, condition2));
+      tasks.put(task1.getTaskId(), task1);
+
+      WorkflowTask task2 = new WorkflowTask();
+      task2.setTaskId(TASK2_ID);
+      task2.setTaskName(TASK2_NAME);
+      task2.setTaskConfig(tConf);
+      task2.setConditions(Lists.newArrayList());
+      tasks.put(task2.getTaskId(), task2);
+
+      WorkflowTask task3 = new WorkflowTask();
+      task3.setTaskId(TASK3_ID);
+      task3.setTaskName(TASK3_NAME);
+      task3.setTaskConfig(tConf);
+      task3.setConditions(Lists.newArrayList());
+      tasks.put(task3.getTaskId(), task3);
+
+      WorkflowTask task4 = new WorkflowTask();
+      task4.setTaskId(TASK4_ID);
+      task4.setTaskName(TASK4_NAME);
+      task4.setTaskConfig(tConf);
+      task4.setConditions(Lists.newArrayList(condition4));
+      tasks.put(task4.getTaskId(), task4);
+
+      Workflow workflow1 = new Workflow();
+      workflow1.setId(WORKFLOW1_ID);
+      workflow1.setName(WORKFLOW1_NAME);
+      workflow1.setTasks(Lists.newArrayList(task1, task2));
+      workflow1.setConditions(Lists.newArrayList(condition1));
+      workflows.put(workflow1.getId(), workflow1);
+
+      Workflow workflow2 = new Workflow();
+      workflow2.setId(WORKFLOW2_ID);
+      workflow2.setName(WORKFLOW2_NAME);
+      workflow2.setTasks(Lists.newArrayList(task1, task2, task4));
+      workflow2.setConditions(Lists.newArrayList(condition1, condition4));
+      workflows.put(workflow2.getId(), workflow2);
+
+      Workflow workflow3 = new Workflow();
+      workflow3.setId(WORKFLOW3_ID);
+      workflow3.setName(WORKFLOW3_NAME);
+      workflow3.setTasks(Lists.newArrayList(task3));
+      workflow3.setConditions(new ArrayList<WorkflowCondition>());
+      workflows.put(workflow3.getId(), workflow3);
+
+      eventToWorkflowsMap.put(EVENT1_NAME, Lists.newArrayList(workflow1));
+      eventToWorkflowsMap.put(EVENT2_NAME, Lists.newArrayList(workflow1,
+            workflow2));
+   }
+
+   @Override
+   public Workflow getWorkflowByName(String workflowName)
+         throws RepositoryException {
+      Validate.notNull(workflowName);
+
+      for (Workflow workflow : workflows.values()) {
+         if (workflow.getName().equals(workflowName)) {
+            return workflow;
+         }
+      }
+      return null;
+   }
+
+   @Override
+   public Workflow getWorkflowById(String workflowId)
+         throws RepositoryException {
+      Validate.notNull(workflowId);
+
+      return workflows.get(workflowId);
+   }
+
+   @Override
+   public List<Workflow> getWorkflows() throws RepositoryException {
+      return Lists.newArrayList(workflows.values());
+   }
+
+   @Override
+   public List<WorkflowTask> getTasksByWorkflowId(String workflowId)
+         throws RepositoryException {
+      Workflow workflow = getWorkflowById(workflowId);
+      List<WorkflowTask> tasks = Lists.newArrayList();
+      if (workflow != null) {
+         tasks.addAll(workflow.getTasks());
+      }
+      return tasks;
+   }
+
+   @Override
+   public List<WorkflowTask> getTasksByWorkflowName(String workflowName)
+         throws RepositoryException {
+      List<WorkflowTask> tasks = Lists.newArrayList();
+      Workflow workflow = getWorkflowByName(workflowName);
+      if (workflow != null) {
+         tasks.addAll(workflow.getTasks());
+      }
+      return tasks;
+   }
+
+   @Override
+   public List<Workflow> getWorkflowsForEvent(String eventName)
+         throws RepositoryException {
+      Validate.notNull(eventName);
+
+      List<Workflow> workflows = eventToWorkflowsMap.get(eventName);
+      if (workflows == null) {
+         return Lists.newArrayList();
+      }
+      return workflows;
+   }
+
+   @SuppressWarnings("unchecked")
+   @Override
+   public List<WorkflowCondition> getConditionsByTaskName(String taskName)
+         throws RepositoryException {
+      List<WorkflowCondition> conditions = Lists.newArrayList();
+      WorkflowTask task = getWorkflowTaskByName(taskName);
+      if (task != null) {
+         conditions.addAll(task.getConditions()); 
+      }
+      return conditions;
+   }
+
+   @SuppressWarnings("unchecked")
+   @Override
+   public List<WorkflowCondition> getConditionsByTaskId(String taskId)
+         throws RepositoryException {
+      List<WorkflowCondition> conditions = Lists.newArrayList();
+      WorkflowTask task = getWorkflowTaskById(taskId);
+      if (task != null) {
+         conditions.addAll(Lists.newArrayList(task.getConditions()));
+      }
+      return conditions;
+   }
+
+   @Override
+   public WorkflowTaskConfiguration getConfigurationByTaskId(String taskId)
+         throws RepositoryException {
+      WorkflowTask task = getWorkflowTaskById(taskId);
+      if (task != null) {
+         return task.getTaskConfig();
+      }
+      return null;
+   }
+
+   @Override
+   public WorkflowTask getWorkflowTaskById(String taskId)
+         throws RepositoryException {
+      Validate.notNull(taskId);
+
+      return tasks.get(taskId);
+   }
+
+   public WorkflowTask getWorkflowTaskByName(String taskName)
+         throws RepositoryException {
+      Validate.notNull(taskName);
+
+      for (WorkflowTask task : tasks.values()) {
+         if (task.getTaskName().equals(taskName)) {
+            return task;
+         }
+      }
+      return null;
+   }
+
+   @Override
+   public WorkflowCondition getWorkflowConditionById(String conditionId)
+         throws RepositoryException {
+      Validate.notNull(conditionId);
+
+      return conditions.get(conditionId);
+   }
+
+   @Override
+   public List<String> getRegisteredEvents() throws RepositoryException {
+      return Lists.newArrayList(eventToWorkflowsMap.keySet());
+   }
+
+   @Override
+   public String addWorkflow(Workflow workflow) throws RepositoryException {
+      workflows.put(workflow.getId(), workflow);
+      return workflow.getId();
+   }
+
+   @Override
+   public List<WorkflowCondition> getConditionsByWorkflowId(String workflowId)
+         throws RepositoryException {
+      List<WorkflowCondition> conditions = Lists.newArrayList();
+      Workflow workflow = getWorkflowById(workflowId);
+      if (workflow != null) {
+         conditions.addAll(workflow.getConditions());
+      }
+      return conditions;
+   }
+
+  /* (non-Javadoc)
+   * @see 
org.apache.oodt.cas.workflow.repository.WorkflowRepository#addTask(org.apache.oodt.cas.workflow.structs.WorkflowTask)
+   */
+  @Override
+  public String addTask(WorkflowTask task) throws RepositoryException {
+    // check its conditions
+    if(task.getPreConditions() != null && task.getPreConditions().size() > 0){
+      for(WorkflowCondition cond: task.getPreConditions()){
+        if(!this.conditions.containsKey(cond.getConditionId())){
+          throw new RepositoryException("Reference in new task: 
["+task.getTaskName()+"] to undefined pre condition ith id: 
["+cond.getConditionId()+"]");            
+        }          
+      }
+      
+      for(WorkflowCondition cond: task.getPostConditions()){
+        if(!this.conditions.containsKey(cond.getConditionId())){
+          throw new RepositoryException("Reference in new task: 
["+task.getTaskName()+"] to undefined post condition ith id: 
["+cond.getConditionId()+"]");            
+        }              
+      }
+    }
+    
+    String taskId = task.getTaskId() != null ? 
+        task.getTaskId():UUID.randomUUID().toString();
+   this.tasks.put(taskId, task);
+   return taskId;    
+  }
+
+  /* (non-Javadoc)
+   * @see 
org.apache.oodt.cas.workflow.repository.WorkflowRepository#getTaskById(java.lang.String)
+   */
+  @Override
+  public WorkflowTask getTaskById(String taskId) throws RepositoryException {
+    return tasks.get(taskId);
+  }
+}

Added: 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/repository/TestPackagedWorkflowRepository.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/repository/TestPackagedWorkflowRepository.java?rev=1653721&view=auto
==============================================================================
--- 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/repository/TestPackagedWorkflowRepository.java
 (added)
+++ 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/repository/TestPackagedWorkflowRepository.java
 Thu Jan 22 00:14:55 2015
@@ -0,0 +1,173 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.oodt.cas.workflow.repository;
+
+//JDK imports
+import java.io.File;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.oodt.cas.workflow.structs.Workflow;
+import org.apache.oodt.cas.workflow.structs.WorkflowCondition;
+
+//Junit imports
+import junit.framework.TestCase;
+
+/**
+ * 
+ * Test harness for the {@link PackagedWorkflowRepository}.
+ * 
+ * @author mattmann
+ * @version $Revision$
+ * 
+ */
+public class TestPackagedWorkflowRepository extends TestCase {
+
+  private PackagedWorkflowRepository repo;
+
+  public TestPackagedWorkflowRepository() {
+  }
+  
+  /**
+   * @since OODT-205
+   */
+  public void testWorkflowConditions(){
+    Workflow w = null;
+    try{
+      w = this.repo.getWorkflowById("urn:npp:GranuleMaps");
+    }
+    catch(Exception e){
+      fail(e.getMessage());
+    }
+    
+    assertNotNull(w);
+    assertNotNull(w.getConditions());
+    System.out.println("NUM CONDITIONS: "+w.getConditions().size());
+    assertTrue(w.getConditions().size() > 0);
+    assertEquals(w.getConditions().size(), 3);
+  }
+
+  public void testDetectOuterLevelWorkflows() {
+    assertNotNull(this.repo);
+    List<Workflow> workflows = null;
+    try {
+      workflows = this.repo.getWorkflows();
+    } catch (Exception e) {
+      fail(e.getMessage());
+    }
+
+    boolean foundGranuleMaps = false;
+    for (Workflow w : workflows) {
+      if (w.getId().equals("urn:npp:GranuleMaps")) {
+        foundGranuleMaps = true;
+      }
+    }
+
+    assertTrue(foundGranuleMaps);
+  }
+
+  public void testDetectInnerWorkflows() {
+    assertNotNull(this.repo);
+    List<String> events = null;
+
+    try {
+      events = this.repo.getRegisteredEvents();
+    } catch (Exception e) {
+      fail(e.getMessage());
+    }
+
+    boolean foundFour = false, foundThree = false;
+    for (String event : events) {
+      List<Workflow> workflows = null;
+
+      try {
+        workflows = this.repo.getWorkflowsForEvent(event);
+      } catch (Exception e) {
+        fail(e.getMessage());
+      }
+
+      assertNotNull(workflows);
+      assertTrue(workflows.size() > 0);
+      if (workflows.size() == 3) {
+        foundThree = true;
+      } else if (workflows.size() == 4) {
+        foundFour = true;
+      }
+
+    }
+
+    assertTrue(foundThree);
+    assertTrue(foundFour);
+  }
+  
+  /**
+   * @since OODT-207
+   */
+  public void testGetConditionTimeout(){
+    WorkflowCondition cond = null;
+    try{
+      cond = this.repo.getWorkflowConditionById("urn:npp:MOA_IASI_L1C_Daily");
+    }
+    catch(Exception e){
+      e.printStackTrace();
+      fail(e.getMessage());
+    }
+    
+    assertNotNull(cond);
+    assertEquals(30L, cond.getTimeoutSeconds());
+  }
+  
+  /**
+   * @since OODT-208
+   */
+  public void testGetOptional(){
+    WorkflowCondition cond = null;
+    try{
+      cond = 
this.repo.getWorkflowConditionById("urn:npp:MOA_ORBITS_FileBased");
+    }
+    catch(Exception e){
+      e.printStackTrace();
+      fail(e.getMessage());
+    }
+    
+    assertNotNull(cond);
+    assertEquals(true, cond.isOptional());   
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @see junit.framework.TestCase#setUp()
+   */
+  @Override
+  protected void setUp() throws Exception {
+    repo = new PackagedWorkflowRepository(Collections.singletonList(new File(
+        "src/main/resources/examples/wengine/GranuleMaps.xml")));
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @see junit.framework.TestCase#tearDown()
+   */
+  @Override
+  protected void tearDown() throws Exception {
+    repo = null;
+  }
+
+}

Added: 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/repository/TestWorkflowDataSourceRepository.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/repository/TestWorkflowDataSourceRepository.java?rev=1653721&view=auto
==============================================================================
--- 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/repository/TestWorkflowDataSourceRepository.java
 (added)
+++ 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/repository/TestWorkflowDataSourceRepository.java
 Thu Jan 22 00:14:55 2015
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.oodt.cas.workflow.repository;
+
+//JDK imports
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.sql.SQLException;
+import javax.sql.DataSource;
+
+//OODT imports
+import org.apache.oodt.commons.database.DatabaseConnectionBuilder;
+import org.apache.oodt.commons.database.SqlScript;
+import org.apache.oodt.cas.metadata.Metadata;
+import org.apache.oodt.cas.workflow.structs.Workflow;
+import org.apache.oodt.cas.workflow.structs.WorkflowCondition;
+import org.apache.oodt.cas.workflow.structs.WorkflowConditionInstance;
+import org.apache.oodt.cas.workflow.structs.exceptions.RepositoryException;
+import org.apache.oodt.cas.workflow.util.GenericWorkflowObjectFactory;
+
+//Junit imports
+import junit.framework.TestCase;
+
+/**
+ * @author mattmann
+ * @version $Revision$
+ * 
+ * <p>
+ * Test suite for the {@link DataSourceCatalog} and
+ * {@link DataSourceCatalogFactory}.
+ * </p>.
+ */
+public class TestWorkflowDataSourceRepository extends TestCase {
+
+    private String tmpDirPath = null;
+
+    private DataSource ds;
+    
+    public TestWorkflowDataSourceRepository() throws SQLException, 
FileNotFoundException {
+        // set the log levels
+        System.setProperty("java.util.logging.config.file", new File(
+                "./src/main/resources/logging.properties").getAbsolutePath());
+
+        // first load the example configuration
+        try {
+            System.getProperties().load(
+                    new 
FileInputStream("./src/main/resources/workflow.properties"));
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+
+        // get a temp directory
+        File tempDir = null;
+        File tempFile = null;
+
+        try {
+            tempFile = File.createTempFile("foo", "bar");
+            tempFile.deleteOnExit();
+            tempDir = tempFile.getParentFile();
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+        
+        tmpDirPath = tempDir.getAbsolutePath();
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        ds = DatabaseConnectionBuilder.buildDataSource("sa", "", 
"org.hsqldb.jdbcDriver", "jdbc:hsqldb:file:" + tmpDirPath + 
"/testCat;shutdown=true");
+        SqlScript coreSchemaScript = new 
SqlScript("src/test/resources/workflow.sql", ds);
+        coreSchemaScript.loadScript();
+        coreSchemaScript.execute();
+        ds.getConnection().commit();
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see junit.framework.TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception {
+        ds.getConnection().close();
+    }
+    
+    /**
+     * @since OODT-205
+     */
+    public void testWorkflowConditions(){
+      DataSourceWorkflowRepository repo = new DataSourceWorkflowRepository(ds);
+            
+      Workflow w = null;
+      try{
+        w = repo.getWorkflowById("1");
+      }
+      catch(Exception e){
+        fail(e.getMessage());
+      }
+      
+      assertNotNull(w);
+      assertNotNull(w.getConditions());
+      assertTrue(w.getConditions().size() > 0);
+      assertEquals(w.getConditions().size(), 1);
+    }
+    
+    
+    public void testDataSourceRepo() throws SQLException, RepositoryException {
+        DataSourceWorkflowRepository repo = new 
DataSourceWorkflowRepository(ds);
+        
+        //test id 1
+        WorkflowCondition wc = repo.getWorkflowConditionById("1");
+        assertEquals(wc.getConditionName(), "CheckCond");
+        WorkflowConditionInstance condInst = 
GenericWorkflowObjectFactory.getConditionObjectFromClassName(wc.getConditionInstanceClassName());
+        Metadata m = new Metadata();
+        m.addMetadata("Met1", "Val1");
+        m.addMetadata("Met2", "Val2");
+        m.addMetadata("Met3", "Val3");
+        assertTrue(condInst.evaluate(m, wc.getTaskConfig()));
+        
+        //test id 2
+        wc = repo.getWorkflowConditionById("2");
+        assertEquals(wc.getConditionName(), "FalseCond");
+        condInst = 
GenericWorkflowObjectFactory.getConditionObjectFromClassName(wc.getConditionInstanceClassName());
+        assertFalse(condInst.evaluate(m, wc.getTaskConfig()));
+        
+        //test id 3
+        wc = repo.getWorkflowConditionById("3");
+        assertEquals(wc.getConditionName(), "TrueCond");
+        condInst = 
GenericWorkflowObjectFactory.getConditionObjectFromClassName(wc.getConditionInstanceClassName());
+        assertTrue(condInst.evaluate(m, wc.getTaskConfig()));
+    }
+    
+}
+

Added: 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/repository/TestWorkflowRepository.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/repository/TestWorkflowRepository.java?rev=1653721&view=auto
==============================================================================
--- 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/repository/TestWorkflowRepository.java
 (added)
+++ 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/repository/TestWorkflowRepository.java
 Thu Jan 22 00:14:55 2015
@@ -0,0 +1,392 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.oodt.cas.workflow.repository;
+
+//Junit imports
+import junit.framework.TestCase;
+
+//JDK imports
+import java.io.File;
+import java.util.List;
+import java.util.Vector;
+
+//OODT imports
+import org.apache.oodt.cas.metadata.Metadata;
+import org.apache.oodt.cas.workflow.structs.Workflow;
+import org.apache.oodt.cas.workflow.structs.WorkflowTask;
+import org.apache.oodt.cas.workflow.structs.WorkflowCondition;
+import org.apache.oodt.cas.workflow.structs.WorkflowTaskConfiguration;
+import org.apache.oodt.cas.workflow.structs.exceptions.RepositoryException;
+import org.apache.oodt.cas.workflow.util.GenericWorkflowObjectFactory;
+
+/**
+ * @author mattmann
+ * @version $Revision$
+ * 
+ * <p>
+ * Unit tests for the Workflow Repository.
+ * </p>
+ * 
+ */
+public class TestWorkflowRepository extends TestCase {
+
+    private XMLWorkflowRepository workflowRepository = null;
+
+    private static List workflowDirUris = new Vector();
+
+    /**
+     * <p>
+     * Default Constructor
+     * </p>
+     */
+    public TestWorkflowRepository() {
+        workflowDirUris.add(new File("./src/main/resources/examples").toURI()
+                .toString());
+        workflowRepository = new XMLWorkflowRepository(workflowDirUris);
+    }
+    
+    /**
+     * @since OODT-205
+     */
+    public void testWorkflowConditions(){
+      Workflow w = null;
+      try{
+        w = 
this.workflowRepository.getWorkflowById("urn:oodt:conditionsWorkflow");
+      }
+      catch(Exception e){
+        fail(e.getMessage());
+      }
+      
+      assertNotNull(w);
+      assertNotNull(w.getConditions());
+      assertTrue(w.getConditions().size() > 0);
+      assertEquals(w.getConditions().size(), 1);
+    }    
+
+    public void testGetWorkflowByName() {
+        Workflow w = null;
+
+        try {
+            w = workflowRepository.getWorkflowByName("backwardsTestWorkflow");
+        } catch (RepositoryException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+
+        validateBackwardsWorkflow(w);
+    }
+
+    public void testGetWorkflowById() {
+        Workflow w = null;
+
+        try {
+            w = workflowRepository
+                    .getWorkflowById("urn:oodt:backwardsTestWorkflow");
+        } catch (RepositoryException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+
+        validateBackwardsWorkflow(w);
+    }
+
+    public void testGetWorkflows() {
+        List workflows = null;
+
+        try {
+            workflows = workflowRepository.getWorkflows();
+        } catch (RepositoryException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+
+        assertNotNull(workflows);
+        assertEquals(11, workflows.size());
+    }
+
+    public void testGetWorkflowsForEvent() {
+        List workflows = null;
+
+        try {
+            workflows = workflowRepository.getWorkflowsForEvent("test");
+        } catch (RepositoryException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+
+        assertNotNull(workflows);
+        assertEquals(1, workflows.size());
+
+        try {
+            workflows = workflowRepository.getWorkflowsForEvent("backwards");
+        } catch (RepositoryException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+
+        assertNotNull(workflows);
+        assertEquals(1, workflows.size());
+        
+
+        try {
+            workflows = 
workflowRepository.getWorkflowsForEvent("externalScript");
+        } catch (RepositoryException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+
+        assertNotNull(workflows);
+        assertEquals(1, workflows.size());
+    }
+
+    public void testGetTasksByWorkflowId() {
+        List tasks = null;
+
+        try {
+            tasks = workflowRepository
+                    .getTasksByWorkflowId("urn:oodt:backwardsTestWorkflow");
+        } catch (RepositoryException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+
+        validateBackwardsWorkflowTasks(tasks);
+    }
+
+    public void testGetTasksByWorkflowName() {
+        List tasks = null;
+
+        try {
+            tasks = workflowRepository
+                    .getTasksByWorkflowName("backwardsTestWorkflow");
+        } catch (RepositoryException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+
+        validateBackwardsWorkflowTasks(tasks);
+    }
+
+    public void testGetConditionsByTaskId() {
+        List conditions = null;
+
+        try {
+            conditions = workflowRepository
+                    .getConditionsByTaskId("urn:oodt:GoodbyeWorld");
+        } catch (RepositoryException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+
+        validateTaskCondition(conditions);
+    }
+
+    public void testGetConditionsByTaskName() {
+        List conditions = null;
+
+        try {
+            conditions = workflowRepository
+                    .getConditionsByTaskName("Goodbye World");
+        } catch (RepositoryException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+
+        validateTaskCondition(conditions);
+    }
+    
+    /**
+     * @since OODT-207
+     */
+    public void testGetConditionTimeout(){
+      WorkflowCondition cond = null;
+      try{
+        cond = 
workflowRepository.getWorkflowConditionById("urn:oodt:TimeoutCondition");
+      }
+      catch(Exception e){
+        e.printStackTrace();
+        fail(e.getMessage());
+      }
+      
+      assertEquals(30L, cond.getTimeoutSeconds());
+    }
+    
+    /**
+     * @since OODT-208
+     */
+    public void testGetConditionOptional(){
+      WorkflowCondition cond = null;
+      try{
+        cond = 
workflowRepository.getWorkflowConditionById("urn:oodt:OptionalCondition");
+      }
+      catch(Exception e){
+        e.printStackTrace();
+        fail(e.getMessage());
+      }
+      
+      assertEquals(true, cond.isOptional());
+    }    
+
+    public void testGetConfigurationByTaskId() {
+        WorkflowTaskConfiguration config = null;
+
+        try {
+            config = workflowRepository
+                    .getConfigurationByTaskId("urn:oodt:GoodbyeWorld");
+        } catch (RepositoryException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+
+        validateTaskConfiguration(config);
+    }
+
+    public void testEnvVarReplaceConfigProperties() {
+        WorkflowTaskConfiguration config = null;
+
+        try {
+            config = workflowRepository
+                    .getConfigurationByTaskId("urn:oodt:PropReplaceTask");
+        } catch (RepositoryException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+
+        assertNotNull(config);
+        String replacedPath = config.getProperty("PathToReplace");
+        String expectedValue = System.getenv("HOME") + "/my/path";
+        assertEquals("The path: [" + replacedPath
+                + "] does not equal the expected" + "path: [" + expectedValue
+                + "]", replacedPath, expectedValue);
+
+        String notReplacedPath = config.getProperty("DontReplaceMe");
+        String notReplacedPathNoSpec = config
+                .getProperty("DontReplaceMeNoSpec");
+
+        assertNotNull(notReplacedPath);
+        assertNotNull(notReplacedPathNoSpec);
+        assertEquals(notReplacedPath, notReplacedPathNoSpec);
+
+        String expected = "[HOME]/my/path";
+        assertEquals("The path: [" + notReplacedPath + "] is not equal to the "
+                + "expected value: [" + expected + "]", expected,
+                notReplacedPath);
+
+    }
+
+    public void testMultipleConditions() {
+        WorkflowTask multiTask = null;
+
+        try {
+            multiTask = workflowRepository
+                    .getWorkflowTaskById("urn:oodt:TestMultiConditionTask");
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+
+        assertNotNull(multiTask);
+        assertNotNull(multiTask.getConditions());
+        assertEquals(2, multiTask.getConditions().size());
+
+        boolean gotTrueCond = false, gotFalseCond = false;
+
+        for (int i = 0; i < multiTask.getConditions().size(); i++) {
+            WorkflowCondition c = (WorkflowCondition) multiTask.getConditions()
+                    .get(i);
+            assertNotNull(c);
+            if (c.getConditionName().equals("True Condition")) {
+                gotTrueCond = true;
+            } else if (c.getConditionName().equals("False Condition")) {
+                gotFalseCond = true;
+            }
+        }
+
+        assertTrue(gotTrueCond && gotFalseCond);
+    }
+    
+    public void testConditionsConfiguration() {
+        WorkflowCondition condition = null;
+
+        try {
+            condition = workflowRepository
+                    .getWorkflowConditionById("urn:oodt:CheckForMetadataKeys");
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+
+        assertNotNull(condition);
+        assertNotNull(condition.getTaskConfig());
+
+        Metadata m = new Metadata();
+        m.addMetadata("Met1", "Val1");
+        m.addMetadata("Met2", "Val2");
+        m.addMetadata("Met3", "Val3");
+        GenericWorkflowObjectFactory.getConditionObjectFromClassName(
+                condition.getConditionInstanceClassName()).evaluate(m,
+                condition.getTaskConfig());
+    }
+
+    private void validateBackwardsWorkflow(Workflow w) {
+        assertNotNull(w);
+        assertNotNull(w.getId());
+        assertEquals("urn:oodt:backwardsTestWorkflow", w.getId());
+        assertNotNull(w.getName());
+        assertEquals("backwardsTestWorkflow", w.getName());
+        validateBackwardsWorkflowTasks(w.getTasks());
+    }
+
+    private void validateBackwardsWorkflowTasks(List tasks) {
+        assertNotNull(tasks);
+        assertEquals(2, tasks.size());
+
+        WorkflowTask t1 = (WorkflowTask) tasks.get(0);
+        assertEquals("Goodbye World", t1.getTaskName());
+        assertEquals("urn:oodt:GoodbyeWorld", t1.getTaskId());
+        assertEquals(1, t1.getOrder());
+        validateTaskConfiguration(t1.getTaskConfig());
+        validateTaskCondition(t1.getConditions());
+
+        WorkflowTask t2 = (WorkflowTask) tasks.get(1);
+        assertEquals("Hello World", t2.getTaskName());
+        assertEquals("urn:oodt:HelloWorld", t2.getTaskId());
+        assertEquals(2, t2.getOrder());
+        validateTaskConfiguration(t2.getTaskConfig());
+        validateTaskCondition(t2.getConditions());
+
+    }
+
+    private void validateTaskCondition(List conditions) {
+        assertNotNull(conditions);
+        assertEquals(1, conditions.size());
+        WorkflowCondition c = (WorkflowCondition) conditions.get(0);
+        assertEquals("urn:oodt:TrueCondition", c.getConditionId());
+        assertEquals("True Condition", c.getConditionName());
+        assertEquals(1, c.getOrder());
+        assertEquals(-1L, c.getTimeoutSeconds());
+        assertEquals(false, c.isOptional());
+    }
+
+    private void validateTaskConfiguration(WorkflowTaskConfiguration config) {
+        assertNotNull(config);
+        assertNotNull(config.getProperties());
+        assertNotNull(config.getProperties().get("Person"));
+        assertEquals("Chris", (String) config.getProperties().get("Person"));
+    }
+
+}

Added: 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/structs/TestFILOPrioritySorter.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/structs/TestFILOPrioritySorter.java?rev=1653721&view=auto
==============================================================================
--- 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/structs/TestFILOPrioritySorter.java
 (added)
+++ 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/structs/TestFILOPrioritySorter.java
 Thu Jan 22 00:14:55 2015
@@ -0,0 +1,87 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.oodt.cas.workflow.structs;
+
+//JDK imports
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Vector;
+
+//OODT imports
+import org.apache.oodt.cas.workflow.engine.processor.SequentialProcessor;
+import org.apache.oodt.cas.workflow.engine.processor.WorkflowProcessor;
+import org.apache.oodt.cas.workflow.lifecycle.WorkflowLifecycleManager;
+
+//Junit imports
+import junit.framework.TestCase;
+
+/**
+ * 
+ * Tests the {@link FILOPrioritySorter}.
+ * 
+ * @author mattmann
+ * @version $Revision$
+ * 
+ */
+public class TestFILOPrioritySorter extends TestCase {
+  
+  private int dateGen;
+  
+  public TestFILOPrioritySorter(){
+    this.dateGen = 0;
+  }
+
+  public void testSort() throws InstantiationException {
+    FILOPrioritySorter sorter = new FILOPrioritySorter();
+    WorkflowProcessor proc = getProcessor(2.0);
+    WorkflowProcessor proc2 = getProcessor(7.0);
+    WorkflowProcessor proc3 = getProcessor(9.0);
+    List<WorkflowProcessor> candidates = new Vector<WorkflowProcessor>();
+    candidates.add(proc3);
+    candidates.add(proc2);
+    candidates.add(proc);    
+    sorter.sort(candidates);
+    
+    assertNotNull(candidates);
+    assertEquals(3, candidates.size());
+    assertEquals(2.0, candidates.get(0).getWorkflowInstance().getPriority()
+        .getValue());
+    assertEquals(7.0, candidates.get(1).getWorkflowInstance().getPriority()
+        .getValue());
+    assertEquals(9.0, candidates.get(2).getWorkflowInstance().getPriority()
+        .getValue());
+  }
+
+  private WorkflowProcessor getProcessor(double priority) throws 
InstantiationException {
+    WorkflowLifecycleManager lifecycleManager = new 
WorkflowLifecycleManager("./src/main/resources/examples/wengine/wengine-lifecycle.xml");
+    WorkflowInstance inst = new WorkflowInstance();
+    Date sd = new Date();
+    sd.setTime(sd.getTime()+(this.dateGen*5000));
+    this.dateGen++;
+    inst.setStartDate(sd);
+    inst.setId("winst-"+priority);
+    Workflow workflow = new Workflow();
+    workflow.setTasks(Collections.EMPTY_LIST);
+    inst.setWorkflow(workflow);
+    inst.setPriority(Priority.getPriority(priority));
+    SequentialProcessor processor = new SequentialProcessor(lifecycleManager, 
inst);
+    return processor;
+  }
+
+}

Added: 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/structs/TestHighestFIFOPrioritySorter.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/structs/TestHighestFIFOPrioritySorter.java?rev=1653721&view=auto
==============================================================================
--- 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/structs/TestHighestFIFOPrioritySorter.java
 (added)
+++ 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/structs/TestHighestFIFOPrioritySorter.java
 Thu Jan 22 00:14:55 2015
@@ -0,0 +1,82 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.oodt.cas.workflow.structs;
+
+//JDK imports
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Vector;
+
+//OODT imports
+import org.apache.oodt.cas.workflow.engine.processor.SequentialProcessor;
+import org.apache.oodt.cas.workflow.engine.processor.WorkflowProcessor;
+import org.apache.oodt.cas.workflow.lifecycle.WorkflowLifecycleManager;
+
+//Junit imports
+import junit.framework.TestCase;
+
+/**
+ * 
+ * Tests the {@link HighestPrioritySorter}.
+ * 
+ * @author mattmann
+ * @version $Revision$
+ * 
+ */
+public class TestHighestFIFOPrioritySorter extends TestCase {
+
+  private int dateGen;
+  
+  public TestHighestFIFOPrioritySorter(){
+    this.dateGen = 0;
+  }
+  
+  public void testSort() throws InstantiationException {
+    HighestFIFOPrioritySorter sorter = new HighestFIFOPrioritySorter(1, 15.0, 
25.0);
+    WorkflowProcessor proc = getProcessor(2.0);
+    WorkflowProcessor proc2 = getProcessor(7.0);
+    List<WorkflowProcessor> candidates = new Vector<WorkflowProcessor>();
+    candidates.add(proc);
+    candidates.add(proc2);
+    sorter.sort(candidates);
+    assertNotNull(candidates);
+    assertEquals(2, candidates.size());
+    assertEquals(7.0, candidates.get(0).getWorkflowInstance().getPriority()
+        .getValue());
+    assertEquals(2.0, candidates.get(1).getWorkflowInstance().getPriority()
+        .getValue());
+  }
+
+  private WorkflowProcessor getProcessor(double priority) throws 
InstantiationException {
+    WorkflowLifecycleManager lifecycleManager = new 
WorkflowLifecycleManager("./src/main/resources/examples/wengine/wengine-lifecycle.xml");
    
+    WorkflowInstance inst = new WorkflowInstance();
+    Date sd = new Date();
+    sd.setTime(sd.getTime()+(this.dateGen*5000));
+    this.dateGen++;
+    inst.setStartDate(new Date());
+    inst.setId("winst-"+priority);
+    Workflow workflow = new Workflow();
+    workflow.setTasks(Collections.EMPTY_LIST);
+    inst.setWorkflow(workflow);
+    inst.setPriority(Priority.getPriority(priority));
+    SequentialProcessor processor = new SequentialProcessor(lifecycleManager, 
inst);
+    return processor;
+  }
+
+}

Added: 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/structs/TestHighestPrioritySorter.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/structs/TestHighestPrioritySorter.java?rev=1653721&view=auto
==============================================================================
--- 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/structs/TestHighestPrioritySorter.java
 (added)
+++ 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/structs/TestHighestPrioritySorter.java
 Thu Jan 22 00:14:55 2015
@@ -0,0 +1,85 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.oodt.cas.workflow.structs;
+
+//JDK imports
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Vector;
+
+//OODT imports
+import org.apache.oodt.cas.workflow.engine.processor.SequentialProcessor;
+import org.apache.oodt.cas.workflow.engine.processor.WorkflowProcessor;
+import org.apache.oodt.cas.workflow.lifecycle.WorkflowLifecycleManager;
+
+//Junit imports
+import junit.framework.TestCase;
+
+/**
+ * 
+ * Tests the {@link HighestPrioritySorter}.
+ * 
+ * @author mattmann
+ * @version $Revision$
+ * 
+ */
+public class TestHighestPrioritySorter extends TestCase {
+
+  private int dateGen;
+  
+  public TestHighestPrioritySorter(){
+    this.dateGen = 0;
+  }
+  
+  
+  public void testSort() throws InstantiationException {
+    HighestPrioritySorter sorter = new HighestPrioritySorter();
+    WorkflowProcessor proc = getProcessor(2.0);
+    WorkflowProcessor proc2 = getProcessor(7.0);
+    List<WorkflowProcessor> candidates = new Vector<WorkflowProcessor>();
+    candidates.add(proc);
+    candidates.add(proc2);
+    System.out.println("BEFORE sort: ["+candidates+"]");
+    sorter.sort(candidates);
+    System.out.println("AFTER sort: ["+candidates+"]");
+    assertNotNull(candidates);
+    assertEquals(2, candidates.size());
+    assertEquals(7.0, candidates.get(0).getWorkflowInstance().getPriority()
+        .getValue());
+    assertEquals(2.0, candidates.get(1).getWorkflowInstance().getPriority()
+        .getValue());
+  }
+
+  private WorkflowProcessor getProcessor(double priority) throws 
InstantiationException {
+    WorkflowLifecycleManager lifecycleManager = new 
WorkflowLifecycleManager("./src/main/resources/examples/wengine/wengine-lifecycle.xml");
    
+    WorkflowInstance inst = new WorkflowInstance();
+    Date sd = new Date();
+    sd.setTime(sd.getTime()+(this.dateGen*5000));
+    this.dateGen++;
+    inst.setStartDate(new Date());
+    inst.setId("winst-"+priority);
+    Workflow workflow = new Workflow();
+    workflow.setTasks(Collections.EMPTY_LIST);
+    inst.setWorkflow(workflow);
+    inst.setPriority(Priority.getPriority(priority));
+    SequentialProcessor processor = new SequentialProcessor(lifecycleManager, 
inst);
+    return processor;
+  }
+
+}

Added: 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/structs/TestWorkflowInstance.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/structs/TestWorkflowInstance.java?rev=1653721&view=auto
==============================================================================
--- 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/structs/TestWorkflowInstance.java
 (added)
+++ 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/structs/TestWorkflowInstance.java
 Thu Jan 22 00:14:55 2015
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.oodt.cas.workflow.structs;
+
+//Junit imports
+import junit.framework.TestCase;
+
+/**
+ * 
+ * Test harness for WorkflowInstance methods.
+ * 
+ * @author mattmann
+ * @version $Revision$
+ * 
+ */
+public class TestWorkflowInstance extends TestCase {
+
+  /**
+   * @since OODT-486
+   */
+  public void testSetStartEndDateTimesNull() {
+    WorkflowInstance inst = new WorkflowInstance();
+    inst.setCurrentTaskEndDateTimeIsoStr(null);
+    inst.setCurrentTaskStartDateTimeIsoStr(null);
+    inst.setStartDateTimeIsoStr(null);
+    inst.setEndDateTimeIsoStr(null);
+
+    assertNull(inst.getEndDate());
+    assertNotNull(inst.getStartDate()); // only one initially set to new Date()
+    assertNull(inst.getCurrentTaskStartDateTimeIsoStr());
+    assertNull(inst.getCurrentTaskEndDateTimeIsoStr());
+  }
+
+}

Added: 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/system/MockXmlRpcWorkflowManagerClient.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/system/MockXmlRpcWorkflowManagerClient.java?rev=1653721&view=auto
==============================================================================
--- 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/system/MockXmlRpcWorkflowManagerClient.java
 (added)
+++ 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/system/MockXmlRpcWorkflowManagerClient.java
 Thu Jan 22 00:14:55 2015
@@ -0,0 +1,327 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.workflow.system;
+
+//JDK imports
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+import java.util.Vector;
+
+//OODT imports
+import org.apache.oodt.cas.metadata.Metadata;
+import org.apache.oodt.cas.workflow.repository.MockWorkflowRepository;
+import org.apache.oodt.cas.workflow.structs.Workflow;
+import org.apache.oodt.cas.workflow.structs.WorkflowCondition;
+import org.apache.oodt.cas.workflow.structs.WorkflowInstance;
+import org.apache.oodt.cas.workflow.structs.WorkflowInstancePage;
+import org.apache.oodt.cas.workflow.structs.WorkflowTask;
+
+//Google imports
+import com.google.common.collect.Lists;
+
+/**
+ * A Mock {@link XmlRpcWorkflowManagerClient}.
+ *
+ * @author bfoster (Brian Foster)
+ */
+public class MockXmlRpcWorkflowManagerClient extends
+      XmlRpcWorkflowManagerClient {
+
+   private MethodCallDetails lastMethodCallDetails;
+   private MockWorkflowRepository workflowRepo;
+
+   public MockXmlRpcWorkflowManagerClient() throws MalformedURLException {
+      super(new URL("http://localhost:9000";));
+      workflowRepo = new MockWorkflowRepository();
+   }
+
+   public MethodCallDetails getLastMethodCallDetails() {
+      return lastMethodCallDetails;
+   }
+
+   public String executeDynamicWorkflow(List<String> taskIds, Metadata 
metadata)
+         throws Exception {
+      lastMethodCallDetails = new MethodCallDetails("executeDynamicWorkflow",
+            Lists.newArrayList(taskIds, metadata));
+      return "TestId1";
+   }
+
+   public List<String> getRegisteredEvents() throws Exception {
+      lastMethodCallDetails = new MethodCallDetails("getRegisteredEvents",
+            Lists.newArrayList());
+      return workflowRepo.getRegisteredEvents();
+   }
+
+   public WorkflowInstancePage getFirstPage() throws Exception {
+      lastMethodCallDetails = new MethodCallDetails("getFirstPage",
+            Lists.newArrayList());
+      WorkflowInstancePage page = new WorkflowInstancePage();
+      page.setPageNum(1);
+      page.setPageSize(0);
+      page.setTotalPages(0);
+      page.setPageWorkflows(Lists.newArrayList());
+      return page;
+   }
+
+   public WorkflowInstancePage getNextPage(WorkflowInstancePage currentPage)
+         throws Exception {
+      lastMethodCallDetails = new MethodCallDetails("getNextPage",
+            Lists.newArrayList((Object) currentPage));
+      WorkflowInstancePage page = new WorkflowInstancePage();
+      page.setPageNum(1);
+      page.setPageSize(0);
+      page.setTotalPages(0);
+      page.setPageWorkflows(Lists.newArrayList());
+      return page;
+   }
+
+   public WorkflowInstancePage getPrevPage(WorkflowInstancePage currentPage)
+         throws Exception {
+      lastMethodCallDetails = new MethodCallDetails("getPrevPage",
+            Lists.newArrayList((Object) currentPage));
+      WorkflowInstancePage page = new WorkflowInstancePage();
+      page.setPageNum(1);
+      page.setPageSize(0);
+      page.setTotalPages(0);
+      page.setPageWorkflows(Lists.newArrayList());
+      return page;
+   }
+
+   public WorkflowInstancePage getLastPage() throws Exception {
+      lastMethodCallDetails = new MethodCallDetails("getLastPage", null);
+      WorkflowInstancePage page = new WorkflowInstancePage();
+      page.setPageNum(1);
+      page.setPageSize(0);
+      page.setTotalPages(0);
+      page.setPageWorkflows(Lists.newArrayList());
+      return page;
+   }
+
+   public WorkflowInstancePage paginateWorkflowInstances(int pageNum,
+         String status) throws Exception {
+      lastMethodCallDetails = new 
MethodCallDetails("paginateWorkflowInstances",
+            Lists.newArrayList(pageNum, (Object) status));
+      WorkflowInstancePage page = new WorkflowInstancePage();
+      page.setPageNum(1);
+      page.setPageSize(0);
+      page.setTotalPages(0);
+      page.setPageWorkflows(Lists.newArrayList());
+      return page;
+   }
+
+   public WorkflowInstancePage paginateWorkflowInstances(int pageNum)
+         throws Exception {
+      lastMethodCallDetails = new 
MethodCallDetails("paginateWorkflowInstances",
+            Lists.newArrayList((Object) pageNum));
+      WorkflowInstancePage page = new WorkflowInstancePage();
+      page.setPageNum(1);
+      page.setPageSize(0);
+      page.setTotalPages(0);
+      page.setPageWorkflows(Lists.newArrayList());
+      return page;
+   }
+
+   public List<Workflow> getWorkflowsByEvent(String eventName) throws 
Exception {
+      lastMethodCallDetails = new MethodCallDetails("getWorkflowsByEvent",
+            Lists.newArrayList((Object) eventName));
+      return workflowRepo.getWorkflowsForEvent(eventName);
+   }
+
+   public Metadata getWorkflowInstanceMetadata(String wInstId) throws 
Exception {
+      lastMethodCallDetails = new 
MethodCallDetails("getWorkflowInstanceMetadata",
+            Lists.newArrayList((Object) wInstId));
+      return new Metadata();
+   }
+
+   public synchronized boolean setWorkflowInstanceCurrentTaskStartDateTime(
+         String wInstId, String startDateTimeIsoStr) throws Exception {
+      lastMethodCallDetails = new MethodCallDetails(
+            "setWorkflowInstanceCurrentTaskStartDateTime",
+            Lists.newArrayList((Object) wInstId, startDateTimeIsoStr));
+      return true;
+   }
+
+   public double getWorkflowCurrentTaskWallClockMinutes(String workflowInstId)
+         throws Exception {
+      lastMethodCallDetails = new MethodCallDetails(
+            "getWorkflowCurrentTaskWallClockMinutes",
+            Lists.newArrayList((Object) workflowInstId));
+      return 0.0;
+   }
+
+   public double getWorkflowWallClockMinutes(String workflowInstId)
+         throws Exception {
+      lastMethodCallDetails = new MethodCallDetails(
+            "getWorkflowWallClockMinutes",
+            Lists.newArrayList((Object) workflowInstId));
+      return 0.0;
+   }
+
+   public synchronized boolean stopWorkflowInstance(String workflowInstId)
+         throws Exception {
+      lastMethodCallDetails = new MethodCallDetails(
+            "stopWorkflowInstance",
+            Lists.newArrayList((Object) workflowInstId));
+      return true;
+   }
+
+   public synchronized boolean pauseWorkflowInstance(String workflowInstId)
+         throws Exception {
+      lastMethodCallDetails = new MethodCallDetails(
+            "pauseWorkflowInstance",
+            Lists.newArrayList((Object) workflowInstId));
+      return true;
+   }
+
+   public synchronized boolean resumeWorkflowInstance(String workflowInstId)
+         throws Exception {
+      lastMethodCallDetails = new MethodCallDetails(
+            "resumeWorkflowInstance",
+            Lists.newArrayList((Object) workflowInstId));
+      return true;
+   }
+
+   public synchronized boolean setWorkflowInstanceCurrentTaskEndDateTime(
+         String wInstId, String endDateTimeIsoStr) throws Exception {
+      lastMethodCallDetails = new MethodCallDetails(
+            "setWorkflowInstanceCurrentTaskEndDateTime",
+            Lists.newArrayList((Object) wInstId, endDateTimeIsoStr));
+      return true;
+   }
+
+   public synchronized boolean updateWorkflowInstanceStatus(
+         String workflowInstId, String status) throws Exception {
+      lastMethodCallDetails = new MethodCallDetails(
+            "updateWorkflowInstanceStatus",
+            Lists.newArrayList((Object) workflowInstId, status));
+      return true;
+   }
+
+   public synchronized boolean updateWorkflowInstance(WorkflowInstance 
instance)
+         throws Exception {
+      lastMethodCallDetails = new MethodCallDetails(
+            "updateWorkflowInstance",
+            Lists.newArrayList((Object) instance));
+      return true;
+   }
+
+   public synchronized boolean updateMetadataForWorkflow(String workflowInstId,
+         Metadata metadata) throws Exception {
+      lastMethodCallDetails = new MethodCallDetails(
+            "updateMetadataForWorkflow",
+            Lists.newArrayList((Object) workflowInstId, metadata));
+      return true;
+   }
+
+   public boolean sendEvent(String eventName, Metadata metadata)
+         throws Exception {
+      lastMethodCallDetails = new MethodCallDetails(
+            "sendEvent",
+            Lists.newArrayList((Object) eventName, metadata));
+      return true;
+   }
+
+   public WorkflowTask getTaskById(String taskId) throws Exception {
+      lastMethodCallDetails = new MethodCallDetails(
+            "getTaskById",
+            Lists.newArrayList((Object) taskId));
+      return workflowRepo.getWorkflowTaskById(taskId);
+   }
+
+   public WorkflowCondition getConditionById(String conditionId)
+         throws Exception {
+      lastMethodCallDetails = new MethodCallDetails(
+            "getConditionById",
+            Lists.newArrayList((Object) conditionId));
+      return workflowRepo.getWorkflowConditionById(conditionId);
+   }
+
+   public WorkflowInstance getWorkflowInstanceById(String wInstId)
+         throws Exception {
+      lastMethodCallDetails = new MethodCallDetails(
+            "getWorkflowInstanceById",
+            Lists.newArrayList((Object) wInstId));
+      WorkflowInstance wInst = new WorkflowInstance();
+      wInst.setStatus("Running");
+      wInst.setId("TestId");
+      wInst.setWorkflow(workflowRepo.getWorkflowById(
+            MockWorkflowRepository.WORKFLOW1_ID));
+      wInst.setCurrentTaskId(MockWorkflowRepository.TASK1_ID);
+      return wInst;
+   }
+
+   public Workflow getWorkflowById(String workflowId) throws Exception {
+      lastMethodCallDetails = new MethodCallDetails(
+            "getWorkflowById",
+            Lists.newArrayList((Object) workflowId));
+      return workflowRepo.getWorkflowById(workflowId);
+   }
+
+   public Vector<Workflow> getWorkflows() throws Exception {
+      lastMethodCallDetails = new MethodCallDetails(
+            "getWorkflows",
+            Lists.newArrayList());
+      return new Vector<Workflow>(workflowRepo.getWorkflows());
+   }
+
+   public int getNumWorkflowInstancesByStatus(String status) throws Exception {
+      lastMethodCallDetails = new MethodCallDetails(
+            "getNumWorkflowInstancesByStatus",
+            Lists.newArrayList((Object) status));
+      return 1;
+   }
+
+   public int getNumWorkflowInstances() throws Exception {
+      lastMethodCallDetails = new MethodCallDetails(
+            "getNumWorkflowInstances",
+            Lists.newArrayList());
+      return 1;
+   }
+
+   public Vector<WorkflowInstance> getWorkflowInstancesByStatus(String status) 
throws Exception {
+      lastMethodCallDetails = new MethodCallDetails(
+            "getWorkflowInstancesByStatus",
+            Lists.newArrayList((Object) status));
+      return new Vector<WorkflowInstance>();
+   }
+
+   public Vector<WorkflowInstance> getWorkflowInstances() throws Exception {
+      lastMethodCallDetails = new MethodCallDetails(
+            "getWorkflowInstances",
+            Lists.newArrayList());
+      return new Vector<WorkflowInstance>();
+   }
+
+   public class MethodCallDetails {
+      private String methodName;
+      private List<Object> args;
+
+      public MethodCallDetails(String methodName, List<Object> args) {
+         this.methodName = methodName;
+         this.args = args;
+      }
+
+      public String getMethodName() {
+         return methodName;
+      }
+
+      public List<Object> getArgs() {
+         return args;
+      }
+   }
+}

Added: 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/system/TestXmlRpcWorkflowManager.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/system/TestXmlRpcWorkflowManager.java?rev=1653721&view=auto
==============================================================================
--- 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/system/TestXmlRpcWorkflowManager.java
 (added)
+++ 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/system/TestXmlRpcWorkflowManager.java
 Thu Jan 22 00:14:55 2015
@@ -0,0 +1,162 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.oodt.cas.workflow.system;
+
+//JDK imports
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Vector;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+//Junit imports
+import junit.framework.TestCase;
+
+//OODT imports
+import org.apache.commons.io.FileUtils;
+import org.apache.oodt.cas.metadata.Metadata;
+
+/**
+ * 
+ * 
+ * Test harness for the {@link XmlRpcWorkflowManager}.
+ * 
+ * @author sherylj
+ * @author mattmann
+ * @version $Revision$
+ * 
+ */
+public class TestXmlRpcWorkflowManager extends TestCase {
+
+  private static final int WM_PORT = 50002;
+
+  private XmlRpcWorkflowManager wmgr;
+
+  private String luceneCatLoc;
+
+  private static final Logger LOG = Logger
+      .getLogger(TestXmlRpcWorkflowManager.class.getName());
+
+  public void testGetWorkflowInstances() {
+
+    Vector workflowInsts = null;
+
+    int numInsts = -1;
+    while (numInsts != 2) {
+      try {
+        workflowInsts = wmgr.getWorkflowInstances();
+      } catch (Exception e) {
+        e.printStackTrace();
+      }
+
+      assertNotNull(workflowInsts);
+      numInsts = workflowInsts.size();
+    }
+
+    assertEquals(2, workflowInsts.size());
+  }
+
+  protected void setUp() throws Exception {
+    startXmlRpcWorkflowManager();
+    startWorkflow();
+  }
+
+  protected void tearDown() throws Exception {
+
+  }
+
+  private void startWorkflow() {
+    XmlRpcWorkflowManagerClient client = null;
+    try {
+      client = new XmlRpcWorkflowManagerClient(new URL("http://localhost:";
+          + WM_PORT));
+    } catch (Exception e) {
+      fail(e.getMessage());
+    }
+
+    try {
+      client.sendEvent("long", new Metadata());
+    } catch (Exception e) {
+      e.printStackTrace();
+      throw new RuntimeException(e);
+    }
+
+  }
+
+  private void startXmlRpcWorkflowManager() {
+    System.setProperty("java.util.logging.config.file", new File(
+        "./src/main/resources/logging.properties").getAbsolutePath());
+
+    try {
+      System.getProperties().load(
+          new FileInputStream("./src/main/resources/workflow.properties"));
+    } catch (Exception e) {
+      fail(e.getMessage());
+    }
+
+    try {
+      luceneCatLoc = File.createTempFile("blah", "txt").getParentFile()
+          .getCanonicalPath();
+      luceneCatLoc = !luceneCatLoc.endsWith("/") ? luceneCatLoc + "/"
+          : luceneCatLoc;
+      luceneCatLoc += "repo";
+      LOG.log(Level.INFO, "Lucene instance repository: [" + luceneCatLoc + 
"]");
+    } catch (Exception e) {
+      fail(e.getMessage());
+    }
+
+    if (new File(luceneCatLoc).exists()) {
+      // blow away lucene cat
+      LOG.log(Level.INFO, "Removing workflow instance repository: ["
+          + luceneCatLoc + "]");
+      try {
+        FileUtils.deleteDirectory(new File(luceneCatLoc));
+      } catch (IOException e) {
+        fail(e.getMessage());
+      }
+    }
+
+    System
+        .setProperty("workflow.engine.instanceRep.factory",
+            
"org.apache.oodt.cas.workflow.instrepo.LuceneWorkflowInstanceRepositoryFactory");
+    System
+        .setProperty("org.apache.oodt.cas.workflow.instanceRep.lucene.idxPath",
+            luceneCatLoc);
+
+    try {
+      System.setProperty("org.apache.oodt.cas.workflow.repo.dirs", "file://"
+          + new File("./src/main/resources/examples").getCanonicalPath());
+      System.setProperty("org.apache.oodt.cas.workflow.lifecycle.filePath",
+          new File("./src/main/resources/examples/workflow-lifecycle.xml")
+              .getCanonicalPath());
+    } catch (Exception e) {
+      fail(e.getMessage());
+    }
+
+    try {
+      wmgr = new XmlRpcWorkflowManager(WM_PORT);
+    } catch (Exception e) {
+      e.printStackTrace();
+      fail(e.getMessage());
+    }
+
+  }
+
+}

Added: 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/system/TestXmlRpcWorkflowManagerClient.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/system/TestXmlRpcWorkflowManagerClient.java?rev=1653721&view=auto
==============================================================================
--- 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/system/TestXmlRpcWorkflowManagerClient.java
 (added)
+++ 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/system/TestXmlRpcWorkflowManagerClient.java
 Thu Jan 22 00:14:55 2015
@@ -0,0 +1,172 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.oodt.cas.workflow.system;
+
+//OODT imports
+import org.apache.commons.io.FileUtils;
+import org.apache.oodt.cas.metadata.Metadata;
+import org.apache.oodt.cas.workflow.instrepo.LuceneWorkflowInstanceRepository;
+import org.apache.oodt.cas.workflow.structs.Workflow;
+import org.apache.oodt.cas.workflow.structs.WorkflowCondition;
+import org.apache.oodt.cas.workflow.structs.WorkflowInstance;
+import org.apache.oodt.cas.workflow.structs.WorkflowTask;
+import org.apache.oodt.cas.workflow.structs.WorkflowTaskConfiguration;
+import 
org.apache.oodt.cas.workflow.structs.exceptions.InstanceRepositoryException;
+
+//JDK imports
+import java.io.File;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+//Junit imports
+import junit.framework.TestCase;
+
+/**
+ * 
+ * Test harness for the {@link XmlRpcWorkflowManagerClient}.
+ * 
+ */
+public class TestXmlRpcWorkflowManagerClient extends TestCase {
+
+  private static final String catalogPath = new File("./target/instTestMetCat")
+      .getAbsolutePath();
+
+  private LuceneWorkflowInstanceRepository repo = null;
+  private WorkflowInstance testWrkInst = null;
+  private Workflow testWrkFlw;
+  private WorkflowTask testTask;
+  private WorkflowCondition testCond;
+
+  private static final int stdPgSz = 20;
+
+  public TestXmlRpcWorkflowManagerClient() {
+
+    testWrkInst = new WorkflowInstance();
+    testWrkFlw = new Workflow();
+    testTask = new WorkflowTask();
+    testCond = new WorkflowCondition();
+    Metadata sharedContext = new Metadata();
+
+    // to check if the path already exists and to delete if it does exist
+    if (new File(catalogPath).exists()) {
+      try {
+        FileUtils.deleteDirectory(new File(catalogPath));
+      } catch (IOException e) {
+        fail(e.getMessage());
+      }
+    }
+    repo = new LuceneWorkflowInstanceRepository(catalogPath, stdPgSz);
+
+    testWrkFlw.setName("test.getMetadataWorkflow");
+    testWrkFlw.setId("test.id");
+    List tasks = new Vector();
+    List conds = new Vector();
+
+    testCond.setConditionId("test.cond.id");
+    testCond.setConditionInstanceClassName("test.class");
+    testCond.setConditionName("test.cond.name");
+    testCond.setOrder(1);
+    conds.add(testCond);
+
+    testTask.setTaskConfig(new WorkflowTaskConfiguration());
+    testTask.setTaskId("test.task.id");
+    testTask.setConditions(conds);
+    testTask.setOrder(1);
+    testTask.setTaskInstanceClassName("test.class");
+    testTask.setTaskName("test.task.name");
+    tasks.add(testTask);
+    testWrkFlw.setTasks(tasks);
+
+    testWrkInst.setCurrentTaskId("test.task");
+    testWrkInst.setStatus("STARTED");
+    testWrkInst.setWorkflow(testWrkFlw);
+
+    sharedContext.addMetadata("key1", "val1");
+    sharedContext.addMetadata("key1", "val2");
+    sharedContext.addMetadata("key1", "val3");
+    sharedContext.addMetadata("key2", "val4");
+    sharedContext.addMetadata("key2", "val5");
+    testWrkInst.setSharedContext(sharedContext);
+
+  }
+
+  public void testGetWorkflowInstanceMetadata() {
+
+    try {
+      repo.addWorkflowInstance(testWrkInst);
+    } catch (InstanceRepositoryException e) {
+      fail(e.getMessage());
+    }
+    String testWrkInstId = testWrkInst.getId();
+    assertNotNull(testWrkInstId);
+
+    // get workflow instance from instance id
+    WorkflowInstance WInst = null;
+    try {
+      WInst = repo.getWorkflowInstanceById(testWrkInstId);
+    } catch (InstanceRepositoryException e) {
+      fail(e.getMessage());
+    }
+
+    assertNotNull(WInst);
+
+    // get Metadata for the workflow instance
+    Metadata met = null;
+    met = WInst.getSharedContext();
+    assertNotNull(met);
+
+    assertNotNull(met.getHashtable());
+    assertEquals(2, met.getHashtable().keySet().size());
+    assertNotNull(met.getAllMetadata("key1"));
+    assertEquals(3, met.getAllMetadata("key1").size());
+    assertNotNull(met.getAllMetadata("key2"));
+    assertEquals(2, met.getAllMetadata("key2").size());
+
+    // check key-values for key1
+    boolean checkVal1 = false, checkVal2 = false, checkVal3 = false;
+
+    for (Iterator i = met.getAllMetadata("key1").iterator(); i.hasNext();) {
+      String val = (String) i.next();
+      if (val.equals("val1")) {
+        checkVal1 = true;
+      } else if (val.equals("val2")) {
+        checkVal2 = true;
+      } else if (val.equals("val3")) {
+        checkVal3 = true;
+      }
+    }
+
+    assert (checkVal1 && checkVal2 && checkVal3);
+
+    // check key-values for key2
+    boolean checkVal4 = false, checkVal5 = false;
+
+    for (Iterator i = met.getAllMetadata("key2").iterator(); i.hasNext();) {
+      String val = (String) i.next();
+      if (val.equals("val4")) {
+        checkVal4 = true;
+      } else if (val.equals("val5")) {
+        checkVal5 = true;
+      }
+    }
+
+    assertTrue(checkVal4 && checkVal5);
+  }
+}

Added: 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/tools/TestInstanceRepoCleaner.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/tools/TestInstanceRepoCleaner.java?rev=1653721&view=auto
==============================================================================
--- 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/tools/TestInstanceRepoCleaner.java
 (added)
+++ 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/tools/TestInstanceRepoCleaner.java
 Thu Jan 22 00:14:55 2015
@@ -0,0 +1,105 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.oodt.cas.workflow.tools;
+
+//JDK imports
+import java.io.File;
+import java.util.List;
+
+//APACHE imports
+import org.apache.commons.io.FileUtils;
+
+//OODT imports
+import org.apache.oodt.cas.workflow.instrepo.LuceneWorkflowInstanceRepository;
+import org.apache.oodt.cas.workflow.instrepo.WorkflowInstanceRepository;
+import org.apache.oodt.cas.workflow.structs.WorkflowInstance;
+import org.apache.oodt.cas.workflow.structs.WorkflowStatus;
+import 
org.apache.oodt.cas.workflow.structs.exceptions.InstanceRepositoryException;
+
+//Junit imports
+import junit.framework.TestCase;
+
+/**
+ * 
+ * Test harness for the {@link InstanceRepoCleaner}.
+ * 
+ * @author mattmann
+ * @version $Revision$
+ * @since 
+ * 
+ */
+public class TestInstanceRepoCleaner extends TestCase {
+
+  private String instRepoPath;
+
+  public void testClean() {
+    InstanceRepoCleaner cleaner = new InstanceRepoCleaner();
+    cleaner.setInstanceRepo(instRepoPath);
+    try {
+      cleaner.cleanRepository();
+    } catch (Exception e) {
+      fail(e.getMessage());
+    }
+
+    WorkflowInstanceRepository repo = new LuceneWorkflowInstanceRepository(
+        instRepoPath, 20);
+    try {
+      assertEquals(10, repo.getNumWorkflowInstances());
+      for (WorkflowInstance inst : (List<WorkflowInstance>) repo
+          .getWorkflowInstances()) {
+        if (!inst.getStatus().equals(WorkflowStatus.FINISHED)) {
+          fail("Workflow Instance: [" + inst.getId()
+              + "] does was not marked as finished by the cleaner: status: ["
+              + inst.getStatus() + "]");
+        }
+      }
+
+    } catch (InstanceRepositoryException e) {
+      fail(e.getMessage());
+    }
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @see junit.framework.TestCase#setUp()
+   */
+  @Override
+  protected void setUp() throws Exception {
+    // get a temp directory path
+    File tempDir = File.createTempFile("bogus", "txt").getParentFile();
+    FileUtils.copyDirectory(new File("./src/test/resources/testinstrepo"), new 
File(
+        tempDir.getAbsolutePath() + "/" + "testinstrepo"));
+    instRepoPath = tempDir.getAbsolutePath().endsWith("/") ? (tempDir
+        .getAbsolutePath() + "testinstrepo")
+        : (tempDir.getAbsolutePath() + "/" + "testinstrepo");
+
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @see junit.framework.TestCase#tearDown()
+   */
+  @Override
+  protected void tearDown() throws Exception {
+    FileUtils.deleteDirectory(new File(instRepoPath));
+
+  }
+
+}

Added: 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/util/TestGenericWorkflowObjectFactory.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/util/TestGenericWorkflowObjectFactory.java?rev=1653721&view=auto
==============================================================================
--- 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/util/TestGenericWorkflowObjectFactory.java
 (added)
+++ 
oodt/trunk/workflow/src/test/java/org/apache/oodt/cas/workflow/util/TestGenericWorkflowObjectFactory.java
 Thu Jan 22 00:14:55 2015
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.oodt.cas.workflow.util;
+
+//OODT imports
+import org.apache.oodt.cas.workflow.structs.WorkflowConditionInstance;
+import org.apache.oodt.cas.workflow.structs.WorkflowTaskInstance;
+
+//Junit imports
+import junit.framework.TestCase;
+
+/**
+ * @author mattmann
+ * @version $Revision$
+ * 
+ * <p>
+ * A Test Suite for the GenericWorkflowObjectFactory class.
+ * </p>.
+ */
+public class TestGenericWorkflowObjectFactory extends TestCase {
+
+       public void testCreateTask() {
+               String taskClass = 
"org.apache.oodt.cas.workflow.examples.LongTask";
+
+               WorkflowTaskInstance taskInst = GenericWorkflowObjectFactory
+                               .getTaskObjectFromClassName(taskClass);
+               assertNotNull(taskInst);
+               assertEquals("The class: [" + taskInst.getClass().getName()
+                               + "] is not " + "equal to the expected class 
name: ["
+                               + taskClass + "]", taskClass, 
taskInst.getClass().getName());
+       }
+
+       public void testCreateCondition() {
+               String condClass = 
"org.apache.oodt.cas.workflow.examples.LongCondition";
+
+               WorkflowConditionInstance condInst = 
GenericWorkflowObjectFactory
+                               .getConditionObjectFromClassName(condClass);
+               assertNotNull(condInst);
+               assertEquals(condClass, condInst.getClass().getName());
+       }
+
+}

Added: oodt/trunk/workflow/src/test/resources/myScript-Output.txt
URL: 
http://svn.apache.org/viewvc/oodt/trunk/workflow/src/test/resources/myScript-Output.txt?rev=1653721&view=auto
==============================================================================
--- oodt/trunk/workflow/src/test/resources/myScript-Output.txt (added)
+++ oodt/trunk/workflow/src/test/resources/myScript-Output.txt Thu Jan 22 
00:14:55 2015
@@ -0,0 +1 @@
+Hi my first name is Faranak and my last name is Davoodi.

Added: oodt/trunk/workflow/src/test/resources/myScript.sh
URL: 
http://svn.apache.org/viewvc/oodt/trunk/workflow/src/test/resources/myScript.sh?rev=1653721&view=auto
==============================================================================
--- oodt/trunk/workflow/src/test/resources/myScript.sh (added)
+++ oodt/trunk/workflow/src/test/resources/myScript.sh Thu Jan 22 00:14:55 2015
@@ -0,0 +1,16 @@
+#!/bin/sh
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE.txt file distributed with
+# this work for additional information regarding copyright ownership.  The ASF
+# licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.    
+echo Hi my first name is  $1 and my last name is $2. > 
./src/testdata/myScript-Output.txt
\ No newline at end of file

Added: oodt/trunk/workflow/src/test/resources/test.logging.properties
URL: 
http://svn.apache.org/viewvc/oodt/trunk/workflow/src/test/resources/test.logging.properties?rev=1653721&view=auto
==============================================================================
--- oodt/trunk/workflow/src/test/resources/test.logging.properties (added)
+++ oodt/trunk/workflow/src/test/resources/test.logging.properties Thu Jan 22 
00:14:55 2015
@@ -0,0 +1,53 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE.txt file distributed with
+# this work for additional information regarding copyright ownership.  The ASF
+# licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.    
+
+# Specify the handlers to create in the root logger
+# (all loggers are children of the root logger)
+# The following creates two handlers
+handlers = java.util.logging.ConsoleHandler
+
+# Set the default logging level for the root logger
+.level = ALL
+    
+# Set the default logging level for new ConsoleHandler instances
+java.util.logging.ConsoleHandler.level = ALL
+        
+# Set the default formatter for new ConsoleHandler instances
+java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
+    
+# Set the default logging level for the subsystems
+
+# data structures subsystem
+org.apache.oodt.cas.workflow.structs.level = INFO
+
+# engine subsystem
+org.apache.oodt.cas.workflow.engine.level = INFO
+
+# instance repository subsystem
+org.apache.oodt.cas.workflow.instrepo.level = INFO
+
+# repository subsystem
+org.apache.oodt.cas.workflow.repository.level = INFO
+
+# system subsystem
+org.apache.oodt.cas.workflow.system.level = FINE
+
+# control the underlying commons-httpclient transport layer for xmlrpc 
+org.apache.commons.httpclient.level = INFO
+httpclient.wire.header.level = INFO
+httpclient.wire.level = INFO
+sun.net.level = OFF
+sun.net.www.level = OFF
+

Added: oodt/trunk/workflow/src/test/resources/testinstrepo/_43.cfs
URL: 
http://svn.apache.org/viewvc/oodt/trunk/workflow/src/test/resources/testinstrepo/_43.cfs?rev=1653721&view=auto
==============================================================================
Binary file - no diff available.

Propchange: oodt/trunk/workflow/src/test/resources/testinstrepo/_43.cfs
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: oodt/trunk/workflow/src/test/resources/testinstrepo/deletable
URL: 
http://svn.apache.org/viewvc/oodt/trunk/workflow/src/test/resources/testinstrepo/deletable?rev=1653721&view=auto
==============================================================================
Binary file - no diff available.

Propchange: oodt/trunk/workflow/src/test/resources/testinstrepo/deletable
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: oodt/trunk/workflow/src/test/resources/testinstrepo/segments
URL: 
http://svn.apache.org/viewvc/oodt/trunk/workflow/src/test/resources/testinstrepo/segments?rev=1653721&view=auto
==============================================================================
Binary file - no diff available.

Propchange: oodt/trunk/workflow/src/test/resources/testinstrepo/segments
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream


Reply via email to