/*
* Name: BasicRebolFormatTest
* Authors: Richard Rodger
*
* Copyright (c) 2000-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
// none
// import
import org.jostraca.util.FileUtil;
import org.jostraca.util.PropertySet;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
import java.io.PrintWriter;
import java.io.File;
/**
* Test cases for BasicRebolFormat
* NOTE: folder handling is a bit wierd as rebol executes
* with the folder of the script as the current folder
*/
public class BasicRebolFormatTest extends BasicFormatTestSupport {
public static final boolean RUN_ONLY_COMMENTED_OUT = false;
public static final String REBOL_FOLDER = "rebol";
public static final String REBOL_TEMPLATE_SUFFIX = "_r.jtm";
public BasicRebolFormatTest( String rName ) {
super( rName );
}
public static TestSuite suite() {
return new TestSuite( BasicRebolFormatTest.class );
}
public static void main( String[] rArgs ) {
handleArgs( rArgs );
TestRunner.run( suite() );
}
public String getTestFolder() {
return REBOL_FOLDER;
}
public String getWriterFolder() {
return ".";
}
public String getJostracaCodeWriterFileName() {
return "Writer.r";
}
// test methods
public void testMethodInsert() throws Exception {
if( RUN_ONLY_COMMENTED_OUT ) { return; }
generateTemplate( TEST_MethodInsert );
PropertySet testPS = getTestPS();
testPS.load( new File( getTestFolder(), PREFIX_RESULT + TEST_MethodInsert + DOT + TXT ) );
PropertySet refPS = getReferencePS();
refPS.clear();
refPS.set( "string", "string" );
refPS.set( "char", "'c'" );
refPS.set( "integer", "123" );
refPS.set( "float", "4.56" );
refPS.set( "insert", "insert" );
refPS.set( "boolean", "false" );
boolean result = testPS.contains( refPS );
assertTrue( result );
}
public void testArgOutputFolder() throws Exception {
if( RUN_ONLY_COMMENTED_OUT ) { return; }
generateTemplate( TEST_ArgOutputFolder,
" -w " + getTestFolder()
+ " -o " + SLASH + new File( getTestFolder(), ARGOUTPUTFOLDER_FOLDER_NAME ).getAbsolutePath(), false );
assertTrue( validateArgOutputFolder() );
}
public void testArgWorkFolder() throws Exception {
if( RUN_ONLY_COMMENTED_OUT ) { return; }
generateTemplate( TEST_ArgWorkFolder,
"-o .. -w " + getTestFolder() + SLASH + ARGWORKFOLDER_FOLDER_NAME );
assertTrue( validateArgWorkFolder() );
}
public void testArgOutputAndWorkFolders() throws Exception {
//if( RUN_ONLY_COMMENTED_OUT ) { return; }
generateTemplate( TEST_ArgOutputAndWorkFolders,
"-o " + SLASH + new File( getTestFolder(), ARGOUTPUTFOLDER_FOLDER_NAME ).getAbsolutePath()
+ " -w " + getTestFolder() + SLASH + ARGWORKFOLDER_FOLDER_NAME, false );
assertTrue( validateArgOutputAndWorkFolders() );
}
public void testVersion_0_1() throws Exception {
// no version 0.1 produced
}
public void testVersion_0_2() throws Exception {
// no version 0.2 produced
}
// protected methods
protected String makeCMDForTemplate( String rTemplateNameSansSuffix,
String rExtraJostracaArgs,
String rCodeWriterArgs,
boolean rSetOutputFolder
) {
String codeWriterArgs = "";
if( 0 < rCodeWriterArgs.length() ) {
codeWriterArgs = rCodeWriterArgs;
}
String templateName = PREFIX_TEST + rTemplateNameSansSuffix + REBOL_TEMPLATE_SUFFIX;
File templateFilePath = new File( REBOL_FOLDER, templateName );
// rebol uses script folder as current folder
String setOutputFolder = "";
if( rSetOutputFolder ) {
setOutputFolder = " " + "-w " + getTestFolder();
}
String cmd
= getJostracaCmd()
+ " " + "-gB "
//+ " " + "-Djostraca.support.ForceScriptByPath=yes"
+ setOutputFolder
+ " " + rExtraJostracaArgs
+ " " + templateFilePath.getPath()
+ " " + codeWriterArgs;
return cmd;
}
}