Package de.danet.an.workflow.tools.test

Source Code of de.danet.an.workflow.tools.test.JSExecutorTest

/*
* This file is part of the WfMOpen project.
* Copyright (C) 2001-2006 Danet GmbH (www.danet.de), BU BTS.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*
* $Id: JSExecutorTest.java 2321 2007-03-22 15:49:45Z schnelle $
*
* $Log$
* Revision 1.1  2007/03/22 13:49:11  schnelle
* Initial release.
*
*/

package de.danet.an.workflow.tools.test;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

import de.danet.an.workflow.spis.aii.ToolAgent;
import de.danet.an.workflow.tools.rhino.JSExecutor2;

/**
* TestCase facility to test scripts for the {@link JSExecutor2} tool.
*
* @author Dirk Schnelle
*/
public abstract class JSExecutorTest extends ToolAgentTestBase {
    /**
     * Constructs a test case without a name.
     */
    public JSExecutorTest() {
        this(null);
    }

    /**
     * Constructs a test case with the specified name.
     * @param name name of the test.
     */
    public JSExecutorTest(String name) {
        super(name);
    }

    /* (non-Javadoc)
     * Comment copied from interface or super class.
     */
    public ToolAgent createToolAgent() {
        return new JSExecutor2();
    }
   
    /**
     * Retrieves the JSExecutor2 tool.
     *
     * @return The JSExecutor2 tool.
     */
    public JSExecutor2 getJSExecutorTool() {
        return (JSExecutor2) getTool();
    }
   
    /**
     * Loads the script and sets it in the tool.
     * @param script Filename of the script to load.
     * @throws IOException Error reading the script.
     */
    protected void loadScript(String script) throws IOException {
        File js = new File(script);
        FileReader reader = new FileReader(js);
        BufferedReader bufreader = new BufferedReader(reader);
       
        StringBuffer buffer = new StringBuffer();
        String line = bufreader.readLine();
        while (line != null) {
            buffer.append(line);
            buffer.append("\n");
            line = bufreader.readLine();
        }
       
        getJSExecutorTool().setScript(buffer.toString());
    }  
}
TOP

Related Classes of de.danet.an.workflow.tools.test.JSExecutorTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.