/*
* Name: MergerProcessStageTest
* 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.Service;
import org.jostraca.Template;
import org.jostraca.process.TemplateHandlerManager;
import org.jostraca.process.PreparerProcessStage;
import org.jostraca.process.ParserProcessStage;
import org.jostraca.process.MergerProcessStage;
import org.jostraca.util.ListUtil;
import org.jostraca.util.CommandLineUserMessageHandler;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
import java.util.ArrayList;
/** Test cases for TemplateHandlerManager.
*/
public class MergerProcessStageTest extends TestCase {
// test framework
public MergerProcessStageTest( String pName ) {
super( pName );
}
public static TestSuite suite() {
return new TestSuite( MergerProcessStageTest.class );
}
public static void main( String[] pArgs ) {
TestRunner.run( suite() );
}
// test methods
public void testMerger() throws Exception {
CommandLineUserMessageHandler cm = new CommandLineUserMessageHandler();
Template tm01 = PackageTest.makeTemplate("tm01");
tm01.getPropertySet( Service.CONF_template )
.set( TemplateHandlerManager.PROPERTY_PREFIX+"Preparer", "org.jostraca.process.GenericPreparer" );
tm01.getPropertySet( Service.CONF_template )
.set( TemplateHandlerManager.PROPERTY_PREFIX+"Parser", "org.jostraca.process.GenericParser" );
tm01.getPropertySet( Service.CONF_template )
.set( TemplateHandlerManager.PROPERTY_PREFIX+"Merger", "org.jostraca.process.GenericMerger" );
ArrayList tmlist = ListUtil.make( tm01 );
PreparerProcessStage prps = new PreparerProcessStage();
prps.setUserMessageHandler( cm );
prps.process( tmlist );
ParserProcessStage pps = new ParserProcessStage();
pps.setUserMessageHandler( cm );
pps.process( tmlist );
MergerProcessStage mps = new MergerProcessStage();
mps.setUserMessageHandler( cm );
mps.process( tmlist );
String cwsrc = tm01.getCodeWriterSource();
assertTrue( -1 != cwsrc.indexOf("tm01") );
}
}