/**
*============================================================================
*  Copyright The Ohio State University Research Foundation, The University of Chicago - 
*	Argonne National Laboratory, Emory University, SemanticBits LLC, and 
*	Ekagra Software Technologies Ltd.
*
*  Distributed under the OSI-approved BSD 3-Clause License.
*  See http://ncip.github.com/cagrid-core/LICENSE.txt for details.
*============================================================================
**/
package org.cagrid.workflow.helper.tests.system;

import gov.nih.nci.cagrid.testing.system.deployment.ContainerException;
import gov.nih.nci.cagrid.testing.system.deployment.ServiceContainer;
import gov.nih.nci.cagrid.testing.system.deployment.ServiceContainerFactory;
import gov.nih.nci.cagrid.testing.system.deployment.ServiceContainerType;
import gov.nih.nci.cagrid.testing.system.deployment.steps.DeployServiceStep;
import gov.nih.nci.cagrid.testing.system.deployment.steps.StartContainerStep;
import gov.nih.nci.cagrid.testing.system.deployment.steps.UnpackContainerStep;
import gov.nih.nci.cagrid.testing.system.deployment.story.ServiceStoryBase;

import java.io.File;
import java.io.IOException;
import java.util.Vector;

import junit.framework.Assert;
import junit.framework.TestResult;
import junit.framework.TestSuite;
import junit.textui.TestRunner;

import org.apache.axis.message.addressing.EndpointReference;
import org.apache.axis.types.URI;
import org.apache.axis.types.URI.MalformedURIException;
import org.apache.log4j.PropertyConfigurator;
import org.cagrid.workflow.helper.tests.system.steps.CreateTestWorkflowsStep;


public class BasicWorkflowServicesTest extends ServiceStoryBase {
    private EndpointReference helperEPR = null;

   // private static final String XSD_NAMESPACE = "http://www.w3.org/2001/XMLSchema";
    private static final String HELPER_PATH_IN_CONTAINER = "/cagrid/WorkflowHelper";


    private boolean enableVerboseOutput = false;

    public BasicWorkflowServicesTest(ServiceContainer container) {
        super(container);

        if( this.enableVerboseOutput ){
        	PropertyConfigurator.configure("." + File.separator + "conf" +
        			File.separator
        			+ "log4j.properties");
        }
    }

    public BasicWorkflowServicesTest() {
        super();
        try {
            ServiceContainer cont = ServiceContainerFactory.createContainer(ServiceContainerType.TOMCAT_CONTAINER);
            setContainer(cont);
        } catch (IOException e) {

            e.printStackTrace();
            Assert.fail();
        }

        if( this.enableVerboseOutput ){
        	PropertyConfigurator.configure("." + File.separator + "conf" +
        			File.separator
        			+ "log4j.properties");
        }
    }


    public String getDescription() {
        return "Basic (non-secure) Wokflows Testing";
    }


    protected Vector steps() {

        System.out.println("BEGIN DeployWorkflowServicesTest");

        Vector steps = new Vector();

        // Set workflow services' directories
        String tests_basedir = System.getProperty("resources.dir") + File.separator;
        if( (tests_basedir == null) || tests_basedir.trim().equals("") ){
            System.err.println("ERROR: System property 'resources.dir' not set");
            return null;
        }
        File services_dirs[] = new File[]{
              	new File(tests_basedir + "Service1"),
                new File(tests_basedir + "Service2"),
                new File(tests_basedir + "Service3"),
                new File(tests_basedir + "Service4"),
                new File(tests_basedir + "Service5"), // */
                new File(tests_basedir + "ReceiveArrayService"),
                new File(tests_basedir + "CreateArrayService"),
                new File(tests_basedir + "AssertService"),
                new File(".." + File.separator + ".." + File.separatorChar + ".." + File.separator + "incubator"
                    + File.separator + "projects" + File.separator + "workflowHelper")};

        // Create container
        System.out.println("Adding unpack task");
        steps.add(new UnpackContainerStep(getContainer()));

        // Deploy each service
        System.out.println("Adding deploy services task");
        for (int i = 0; i < services_dirs.length; i++) {
            String curr_service_dir = null;
            try {
                curr_service_dir = services_dirs[i].getCanonicalPath();
            } catch (IOException e) {
                e.printStackTrace();
            }
            System.out.println("Adding deploy for service in directory '" + curr_service_dir + "'");
            steps.add(new DeployServiceStep(getContainer(), curr_service_dir));
        }
        System.out.println("END DeployWorkflowServicesTest");

        // Start a container before anything else
        StartContainerStep start_step = new StartContainerStep(getContainer());
        steps.add(start_step);

        // Configure the workflows that are part of the system test
        try {
            URI helper_uri = getContainer().getContainerBaseURI();
            String container_base_url = "http://"+ helper_uri.getHost() + ':' + helper_uri.getPort();
            helper_uri.appendPath(HELPER_PATH_IN_CONTAINER);
            this.helperEPR = new EndpointReference(helper_uri);
            CreateTestWorkflowsStep create_workflows = new CreateTestWorkflowsStep(this.helperEPR, container_base_url);
             steps.add(create_workflows);
        } catch (MalformedURIException e) {
            e.printStackTrace();
            Assert.fail();
        }

        return steps;
    }


    public boolean storySetUp() {

        return true;
    }


    public void storyTearDown() {
        if (getContainer() != null) {
            try {

            	System.out.println("Stopping container after executing tests");
            	if( getContainer().isStarted() ){

            		getContainer().stopContainer();
            	}

            	if( getContainer().isUnpacked() ){

            		getContainer().deleteContainer();
            	}
            } catch (ContainerException e) {
                e.printStackTrace();
                Assert.fail();
            }
        } else
            System.err.println("getContainer returned null. Have the container been set?");
        // */

    }

    /**
     * Convenience method for running all the Steps in this Story.
     */
    public static void main(String args[]) {

    	try{

    		TestRunner runner = new TestRunner();
    		TestResult result = runner.doRun(new TestSuite(BasicWorkflowServicesTest.class));
    		System.exit(result.errorCount() + result.failureCount());
    	}
    	catch(Throwable t){
    		t.printStackTrace();
    		Assert.fail(t.getMessage());
    	}

    }

	/* (non-Javadoc)
	 * @see junit.framework.TestCase#getName()
	 */
	public String getName() {

		return "testHelperUnsecureWorkflows";
	}

}

@@ -1,11 +1,12 @@
 /**
+%0D
 %0A*======
@@ -75,16 +75,17 @@
 ========
+%0D
 %0A*  Copy
@@ -89,16 +89,26 @@
 opyright
+ (c) 2008,
  The Ohi
@@ -147,19 +147,26 @@
 dation, 
-The
+Emory %0D%0A* 
  Univers
@@ -172,132 +172,66 @@
 sity
- of Chicago - %0A*%09Argonne National Laboratory, Emory University, SemanticBits LLC, and %0A*%09Ekagra Software Technologies Ltd.
+, the University of Minnesota Supercomputing Institute%0D
 %0A*
+%0D
 %0A*  
@@ -286,16 +286,17 @@
 License.
+%0D
 %0A*  See 
@@ -354,16 +354,17 @@
 details.
+%0D
 %0A*======
@@ -437,12 +437,14 @@
 ====
+%0D
 %0A**/
+%0D
 %0Apac

Update BasicWorkflowServicesTest.java