/*
* Name: TemplateHandlerManagerTest
* 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.BasicTemplate;
import org.jostraca.process.TemplateHandler;
import org.jostraca.process.TemplateHandlerManager;
import org.jostraca.util.ListUtil;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
/** Test cases for TemplateHandlerManager.
*/
public class TemplateHandlerManagerTest extends TestCase {
// test framework
public TemplateHandlerManagerTest( String pName ) {
super( pName );
}
public static TestSuite suite() {
return new TestSuite( TemplateHandlerManagerTest.class );
}
public static void main( String[] pArgs ) {
TestRunner.run( suite() );
}
// test methods
public void testGet() throws Exception {
TemplateHandlerManager thm = new TemplateHandlerManager( "Parser" );
BasicTemplate tm01 = new BasicTemplate();
tm01.getPropertySet(Service.CONF_template)
.set( TemplateHandlerManager.PROPERTY_PREFIX+"Parser", "org.jostraca.process.test.TestParser" );
TemplateHandler th = thm.getTemplateHandler( tm01 );
assertTrue( th instanceof TestParser );
TestParser tp = (TestParser) th;
th.process( tm01 );
assertEquals( "TestParser:new, process:[Template[p:[]]], ", tp.toString() );
th.complete( ListUtil.make( tm01 ) );
assertEquals( "TestParser:new, process:[Template[p:[]]], complete:[[Template[p:[]]]], ", tp.toString() );
}
}