Package org.jostraca.process.test

Source Code of org.jostraca.process.test.BasicProcessManagerTest

/*
* Name:    BasicProcessManagerTest
* Author:  Richard Rodger
*
* Copyright (c) 2004 Richard Rodger
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/


// package
package org.jostraca.process.test;


// import
import org.jostraca.Property;
import org.jostraca.Service;
import org.jostraca.Template;

import org.jostraca.process.BasicProcessManager;
import org.jostraca.process.TemplateHandlerManager;

import org.jostraca.util.ListUtil;
import org.jostraca.util.PropertySet;
import org.jostraca.util.UserMessageHandler;
import org.jostraca.util.CommandLineUserMessageHandler;

import junit.framework.TestCase;
import junit.framework.TestSuite;
import junit.textui.TestRunner;

import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;


/** Test cases for TemplateHandlerManager.
*/
public class BasicProcessManagerTest extends TestCase {

  // test framework

  public BasicProcessManagerTest( String pName ) {
    super( pName );
  }

  public static TestSuite suite() {
    return new TestSuite( BasicProcessManagerTest.class );
  }

  public static void main( String[] pArgs ) {
    TestRunner.run( suite() );
  }


  // test methods

  public void testProcessManager() throws Exception {
    CommandLineUserMessageHandler cm = new CommandLineUserMessageHandler();

    Template tm01 = PackageTest.makeTemplate("tm01");
    Template tm02 = PackageTest.makeTemplate("tm02");
    ArrayList tmlist = ListUtil.make( tm01, tm02 );

    preprocess( cm, tmlist );

    PropertySet sysps = PackageTest.getSystemPropertySet();
    sysps.set( Property.main_ProcessStages, "Preparer,Parser,Merger,Saver,Compiler,Controller" );

    BasicProcessManager bpsm = new BasicProcessManager( sysps );
    bpsm.setUserMessageHandler( cm );
    bpsm.process( tmlist );

  }



  public void preprocess( UserMessageHandler pCM, List pTmList ) {
    for( Iterator tmT = pTmList.iterator(); tmT.hasNext(); ) {
      Template tm = (Template) tmT.next();
      tm.getPropertySet( Service.CONF_template )
        .set( TemplateHandlerManager.PROPERTY_PREFIX+"Preparer", "org.jostraca.process.GenericPreparer" );
      tm.getPropertySet(Service.CONF_template)
        .set( TemplateHandlerManager.PROPERTY_PREFIX+"Parser", "org.jostraca.process.GenericParser" );
      tm.getPropertySet(Service.CONF_template)
        .set( TemplateHandlerManager.PROPERTY_PREFIX+"Merger", "org.jostraca.process.GenericMerger" );
      tm.getPropertySet(Service.CONF_template)
        .set( TemplateHandlerManager.PROPERTY_PREFIX+"Saver", "org.jostraca.process.GenericSaver" );
      tm.getPropertySet(Service.CONF_template)
        .set( TemplateHandlerManager.PROPERTY_PREFIX+"Compiler", "org.jostraca.process.InternalJavaCompiler" );
      tm.getPropertySet(Service.CONF_template)
        .set( TemplateHandlerManager.PROPERTY_PREFIX+"Controller", "org.jostraca.process.InternalJavaController" );
    }
  }


}
TOP

Related Classes of org.jostraca.process.test.BasicProcessManagerTest

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.