Package

Source Code of BasicJavaScriptFormatTest

/*
* Name:    BasicJavaScriptFormatTest
* Authors: Richard Rodger
*
* Copyright (c) 2006 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 BasicJavaScriptJavaFormat
*/
public class BasicJavaScriptFormatTest extends BasicFormatTestSupport {

  public static final boolean RUN_ONLY_COMMENTED_OUT = false;


  public static final String JAVASCRIPT_FOLDER           = "javascript";
  public static final String JAVASCRIPT_TEMPLATE_SUFFIX  = "_js.jtm";


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

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

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


  public String getTestFolder() {
    return JAVASCRIPT_FOLDER;
  }


  public String getJostracaCodeWriterFileName() {
    return "Writer.js";
  }




  // test methods

  public void testMethodInsert() throws Exception {
    if( RUN_ONLY_COMMENTED_OUT ) { return; }
    generateTemplate( TEST_MethodInsert );
    assertTrue( validateMethodInsert() );

    PropertySet        testPS = getTestPS();
    PropertySet refPS  = getReferencePS();
    refPS.clear();

    refPS.set("boolean", "false");
    assertTrue( testPS.contains( refPS ) );
  }


  /*
  public void testInternalController() throws Exception {
    if( RUN_ONLY_COMMENTED_OUT ) { return; }
    generateTemplate( TEST_InternalController );
    iControllerClass = "org.jostraca.process.InternalJavaScriptController";
    assertTrue( validateInternalController() );
  }


  public void testExternalController() throws Exception {
    if( RUN_ONLY_COMMENTED_OUT ) { return; }
    generateTemplate( TEST_ExternalController );
    iControllerClass = "org.jostraca.process.ExternalJavaScriptController";
    assertTrue( validateExternalController() );
  }
  */


  public void testVersion_0_1() throws Exception {
    // not used
  }


  public void testVersion_0_2() throws Exception {
    // not used
  }


  public void testVersion_0_3() throws Exception {
    // not used
  }



  // protected methods

  protected String makeCMDForTemplate( String  pTemplateNameSansSuffix,
                                       String  pExtraJostracaArgs,
                                       String  pCodeWriterArgs,
                                       boolean pSetOutputFolder
                                       ) {

    String codeWriterArgs = "";
    if( 0 < pCodeWriterArgs.length() ) {
      codeWriterArgs = " "+pCodeWriterArgs+" ";
    }

   
    String templateName     = PREFIX_TEST + pTemplateNameSansSuffix + JAVASCRIPT_TEMPLATE_SUFFIX;
    File   templateFilePath = new File( JAVASCRIPT_FOLDER, templateName );

    String setOutputFolder = "";
    if( pSetOutputFolder ) {
      setOutputFolder = " " + "-o " + getTestFolder();
    }

    String cmd             
      = getJostracaCmd()
      + " -gB "
      + setOutputFolder
      + " " + pExtraJostracaArgs
      + " " + templateFilePath.getPath()
      + " " + codeWriterArgs;

    return cmd;
  }

}
TOP

Related Classes of BasicJavaScriptFormatTest

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.