public void testProcessScript() throws Exception {
TemplateActionHandlerStub tahs = new TemplateActionHandlerStub();
PropertySet ps = new PropertySet();
ps.load( new File( "../../../../conf/system.conf" ) );
BasicScriptElementProcessor bsep = create( ps, tahs );
// REVIEW: this will have to change
ps.set( Property.jostraca_old, "yes" );
tahs.clear();
String s01 = "foo = bar;";
Block b01 = new Block( Block.TYPE_script, s01 );
assertTrue( bsep.isMatch( b01 ) );
bsep.process( b01 );
assertEquals( (s01+BasicTemplateElementProcessor.NEWLINE), tahs.getLastAppendedContent() );
tahs.clear();
String s02 = "!foo bar;";
Block b02 = new Block( Block.TYPE_script, s02 );
assertTrue( bsep.isMatch( b02 ) );
bsep.process( b02 );
assertTrue( ("foo bar;"+BasicTemplateElementProcessor.NEWLINE).equals( tahs.getLastAppendedContent() ) );
assertTrue( Section.NAME_declare.equals( tahs.getLastSectionName() ) );
tahs.clear();
String s03 = " ! foo bar;";
Block b03 = new Block( Block.TYPE_script, s03 );
assertTrue( bsep.isMatch( b03 ) );
bsep.process( b03 );
assertTrue( (" foo bar;"+BasicTemplateElementProcessor.NEWLINE).equals( tahs.getLastAppendedContent() ) );
assertTrue( Section.NAME_declare.equals( tahs.getLastSectionName() ) );
tahs.clear();
String s04 = "foo! bar;";
Block b04 = new Block( Block.TYPE_script, s04 );
assertTrue( bsep.isMatch( b04 ) );
bsep.process( b04 );
assertTrue( (" bar;"+BasicTemplateElementProcessor.NEWLINE).equals( tahs.getLastAppendedContent() ) );
assertTrue( "foo".equals( tahs.getLastSectionName() ) );
tahs.clear();
String s05 = "foo ! bar;";
Block b05 = new Block( Block.TYPE_script, s05 );
assertTrue( bsep.isMatch( b05 ) );
bsep.process( b05 );
assertTrue( ("foo ! bar;"+BasicTemplateElementProcessor.NEWLINE).equals( tahs.getLastAppendedContent() ) );
assertEquals( Section.NAME_body, tahs.getLastSectionName() );
}