Package org.jostraca

Examples of org.jostraca.Generator


      simple_txt.delete();
    }


    // settings to just parse template
    Generator   g  = new Generator();
    PropertySet ps = new PropertySet();
    ps.set( Property.main_MakeBackup,        Standard.NO  );
    ps.set( Property.main_CompileCodeWriter, Standard.NO );
    ps.set( Property.main_ExecuteCodeWriter, Standard.NO );
    g.setCmdPropertySet( ps );
    Template tm = g.generate( FileUtil.findFile( "org/jostraca/test/simple.jtm" ) );

    // get full properties
    PropertySet mergedps = tm.getMergedPropertySet();
    assertEquals( ".jostraca", mergedps.get( Property.main_WorkFolder ) );

    // this is how you can get the canonical template script language name
    assertEquals( "java", tm.getCodeWriterLang() );

    // get the codewriter path
    assertEquals( ".jostraca\\SimpleWriter.java", tm.getCodeWriterPath().toString() );
   
    // get the codewriter class file / executable file
    assertEquals( ".jostraca\\SimpleWriter.class", tm.getCodeWriterExecutablePath().toString() );

    ps = new PropertySet();
    ps.set( Property.main_MakeBackup,        Standard.NO  );
    ps.set( Property.main_CompileCodeWriter, Standard.YES );
    ps.set( Property.main_ExecuteCodeWriter, Standard.YES );
    g.setCmdPropertySet( ps );
    tm = g.generate( FileUtil.findFile( "org/jostraca/test/simple.jtm" ) );

    assertEquals("[.\\simple.txt]", tm.getSavedFiles().toString() );
  }
View Full Code Here


    File simple_txt = FileUtil.findFile( "org/jostraca/test/simple.txt" );
    if( simple_txt.exists() ) {
      simple_txt.delete();
    }

    Generator   g  = new Generator();
    PropertySet ps = new PropertySet();
    ps.set( Property.main_MakeBackup,        Standard.NO  );
    ps.set( Property.main_CompileCodeWriter, Standard.YES );
    ps.set( Property.main_ExecuteCodeWriter, Standard.YES );
    g.setCmdPropertySet( ps );
    Template tm = g.generate( FileUtil.findFile( "org/jostraca/test/simple.jtm" ) );

    RecordingUserMessageHandler rumh = (RecordingUserMessageHandler) g.getUserMessageHandler();
    assertTrue( null != rumh );
    assertEquals( 7, ((Vector)rumh.get( UserMessageHandler.DEBUG )).size() );
    assertEquals( 2, ((Vector)rumh.get( UserMessageHandler.INFO  )).size() );
    assertEquals( 0, ((Vector)rumh.get( UserMessageHandler.WARN  )).size() );
    assertEquals( 0, ((Vector)rumh.get( UserMessageHandler.ERROR )).size() );
View Full Code Here

    File parse_txt = FileUtil.findFile( "org/jostraca/test/parse.txt" );
    if( parse_txt.exists() ) {
      parse_txt.delete();
    }

    Generator   g  = new Generator( org_jostraca_test );
    PropertySet ps = new PropertySet();
    ps.set( Property.main_MakeBackup,        Standard.NO    );
    ps.set( Property.parse_OpenInnerChar,    Standard.COLON );
    ps.set( Property.parse_CloseInnerChar,   Standard.COLON );
    ps.set( Property.main_CompileCodeWriter, Standard.YES );
    ps.set( Property.main_ExecuteCodeWriter, Standard.YES );
    g.setCmdPropertySet( ps );
    g.generate( FileUtil.findFile( "org/jostraca/test/parse.jtm" ) );

    RecordingUserMessageHandler rumh = (RecordingUserMessageHandler) g.getUserMessageHandler();
    assertTrue( null != rumh );
    //System.out.println( rumh );
    assertEquals( 7, ((Vector)rumh.get( UserMessageHandler.DEBUG )).size() );
    assertEquals( 2, ((Vector)rumh.get( UserMessageHandler.INFO  )).size() );
    assertEquals( 0, ((Vector)rumh.get( UserMessageHandler.WARN  )).size() );
View Full Code Here

      internal_txt.delete();
    }

    // just compile first
    RecordingUserMessageHandler rumh = null;
    Generator   g  = new Generator();
    PropertySet ps = new PropertySet();
    ps.set( Property.main_MakeBackup,         Standard.NO  );
    ps.set( Property.main_CompileCodeWriter,  Standard.YES );
    ps.set( Property.main_ExecuteCodeWriter,  Standard.NO  );
    g.setCmdPropertySet( ps );

    g.generate( FileUtil.findFile( "org/jostraca/test/internal.jtm" ) );
    rumh = (RecordingUserMessageHandler) g.getUserMessageHandler();
    assertTrue( null != rumh );
    //System.out.println( rumh );
    assertEquals( 6, ((Vector)rumh.get( UserMessageHandler.DEBUG )).size() );
    assertEquals( 1, ((Vector)rumh.get( UserMessageHandler.INFO  )).size() );
    assertEquals( 0, ((Vector)rumh.get( UserMessageHandler.WARN  )).size() );
    assertEquals( 0, ((Vector)rumh.get( UserMessageHandler.ERROR )).size() );
    assertEquals( 0, ((Vector)rumh.get( UserMessageHandler.FATAL )).size() );

    internal_txt = FileUtil.findFile( "org/jostraca/test/internal.txt" );
    assertTrue( !internal_txt.exists() );

    // and now execute
    ps.set( Property.main_CompileCodeWriter,    Standard.EMPTY );
    ps.set( Property.main_ExecuteCodeWriter,    Standard.YES  );

    g.setCmdPropertySet( ps );
    g.generate( FileUtil.findFile( "org/jostraca/test/internal.jtm" ), new RecordingUserMessageHandler() );

    rumh = (RecordingUserMessageHandler) g.getUserMessageHandler();
    assertTrue( null != rumh );
    //System.out.println( rumh );
    assertEquals( 6, ((Vector)rumh.get( UserMessageHandler.DEBUG )).size() );
    assertEquals( 2, ((Vector)rumh.get( UserMessageHandler.INFO  )).size() );
    assertEquals( 0, ((Vector)rumh.get( UserMessageHandler.WARN  )).size() );
View Full Code Here

      context_txt.delete();
    }

    // just compile first
    RecordingUserMessageHandler rumh = null;
    Generator   g  = new Generator();
    PropertySet ps = new PropertySet();
    ps.set( Property.main_MakeBackup,         Standard.NO  );
    ps.set( Property.main_CompileCodeWriter,  Standard.YES );
    ps.set( Property.main_ExecuteCodeWriter,  Standard.NO  );
    g.setCmdPropertySet( ps );
   
    String c = "context";
    g.setContext( c );

    g.generate( FileUtil.findFile( "org/jostraca/test/context.jtm" ) );
    rumh = (RecordingUserMessageHandler) g.getUserMessageHandler();
    assertTrue( null != rumh );
    //System.out.println( rumh );
    assertEquals( 6, ((Vector)rumh.get( UserMessageHandler.DEBUG )).size() );
    assertEquals( 1, ((Vector)rumh.get( UserMessageHandler.INFO  )).size() );
    assertEquals( 0, ((Vector)rumh.get( UserMessageHandler.WARN  )).size() );
    assertEquals( 0, ((Vector)rumh.get( UserMessageHandler.ERROR )).size() );
    assertEquals( 0, ((Vector)rumh.get( UserMessageHandler.FATAL )).size() );

    context_txt = FileUtil.findFile( "org/jostraca/test/context.txt" );
    assertTrue( !context_txt.exists() );

    // and now execute
    ps.set( Property.main_CompileCodeWriter,    Standard.EMPTY );
    ps.set( Property.main_ExecuteCodeWriter,    Standard.YES  );

    g.setCmdPropertySet( ps );
    g.generate( FileUtil.findFile( "org/jostraca/test/context.jtm" ), new RecordingUserMessageHandler() );

    rumh = (RecordingUserMessageHandler) g.getUserMessageHandler();
    assertTrue( null != rumh );
    //System.out.println( rumh );
    assertEquals( 6, ((Vector)rumh.get( UserMessageHandler.DEBUG )).size() );
    assertEquals( 2, ((Vector)rumh.get( UserMessageHandler.INFO  )).size() );
    assertEquals( 0, ((Vector)rumh.get( UserMessageHandler.WARN  )).size() );
View Full Code Here

    File cmdargs_txt = FileUtil.findFile( "org/jostraca/test/cmdargs.txt" );
    if( cmdargs_txt.exists() ) {
      cmdargs_txt.delete();
    }

    Generator   g  = new Generator();
    PropertySet ps = Jostraca.parseCommandLine( "-Bcg -Dfoo=bar", new ArrayList(), new ArrayList() );
    g.setCmdPropertySet( ps );
    Template tm = g.generate( FileUtil.findFile( "org/jostraca/test/cmdargs.jtm" ) );

    RecordingUserMessageHandler rumh = (RecordingUserMessageHandler) g.getUserMessageHandler();
    assertTrue( null != rumh );
    //System.out.println( rumh );
    assertEquals( 7, ((Vector)rumh.get( UserMessageHandler.DEBUG )).size() );
    assertEquals( 2, ((Vector)rumh.get( UserMessageHandler.INFO  )).size() );
    assertEquals( 0, ((Vector)rumh.get( UserMessageHandler.WARN  )).size() );
View Full Code Here

      simple_txt.delete();
    }


    // settings to just parse template
    Generator   g  = new Generator();
    PropertySet ps = new PropertySet();
    ps.set( Property.main_MakeBackup,        Standard.NO  );
    ps.set( Property.main_CompileCodeWriter, Standard.NO );
    ps.set( Property.main_ExecuteCodeWriter, Standard.NO );
    g.setCmdPropertySet( ps );
    Template tm = g.generate( FileUtil.findFile( "org/jostraca/test/simple.jtm" ) );

    // get full properties
    PropertySet mergedps = tm.getMergedPropertySet();
    assertEquals( ".jostraca", mergedps.get( Property.main_WorkFolder ) );

    // this is how you can get the canonical template script language name
    assertEquals( "java", tm.getCodeWriterLang() );


    ps = new PropertySet();
    ps.set( Property.main_MakeBackup,        Standard.NO  );
    ps.set( Property.main_CompileCodeWriter, Standard.YES );
    ps.set( Property.main_ExecuteCodeWriter, Standard.YES );
    g.setCmdPropertySet( ps );
    tm = g.generate( FileUtil.findFile( "org/jostraca/test/simple.jtm" ) );

    // get the codewriter path
    assertEquals( ".jostraca\\SimpleWriter.java", tm.getCodeWriterPath().toString() );
   
    // get the codewriter class file / executable file
View Full Code Here

    File simple_txt = new File( "simple.txt" );
    if( simple_txt.exists() ) {
      simple_txt.delete();
    }

    Generator   g  = new Generator();
    PropertySet ps = new PropertySet();
    ps.set( Property.main_MakeBackup,        Standard.NO  );
    ps.set( Property.main_CompileCodeWriter, Standard.YES );
    ps.set( Property.main_ExecuteCodeWriter, Standard.YES );
    g.setCmdPropertySet( ps );
    Template tm = g.generate( FileUtil.findFile( "org/jostraca/test/simple.jtm" ) );

    RecordingUserMessageHandler rumh = (RecordingUserMessageHandler) g.getUserMessageHandler();
    assertTrue( null != rumh );
    assertEquals( 7, ((Vector)rumh.get( UserMessageHandler.DEBUG )).size() );
    assertEquals( 2, ((Vector)rumh.get( UserMessageHandler.INFO  )).size() );
    assertEquals( 0, ((Vector)rumh.get( UserMessageHandler.WARN  )).size() );
    assertEquals( 0, ((Vector)rumh.get( UserMessageHandler.ERROR )).size() );
View Full Code Here

    File parse_txt =new File( "parse.txt" );
    if( parse_txt.exists() ) {
      parse_txt.delete();
    }

    Generator   g  = new Generator( org_jostraca_test );
    PropertySet ps = new PropertySet();
    ps.set( Property.main_MakeBackup,        Standard.NO    );
    ps.set( Property.parse_OpenInnerChar,    Standard.COLON );
    ps.set( Property.parse_CloseInnerChar,   Standard.COLON );
    ps.set( Property.main_CompileCodeWriter, Standard.YES );
    ps.set( Property.main_ExecuteCodeWriter, Standard.YES );
    g.setCmdPropertySet( ps );
    g.generate( new File( "src/org/jostraca/test/parse.jtm" ) );

    RecordingUserMessageHandler rumh = (RecordingUserMessageHandler) g.getUserMessageHandler();
    assertTrue( null != rumh );
    //System.out.println( rumh );
    assertEquals( 7, ((Vector)rumh.get( UserMessageHandler.DEBUG )).size() );
    assertEquals( 2, ((Vector)rumh.get( UserMessageHandler.INFO  )).size() );
    assertEquals( 0, ((Vector)rumh.get( UserMessageHandler.WARN  )).size() );
View Full Code Here

      internal_txt.delete();
    }

    // just compile first
    RecordingUserMessageHandler rumh = null;
    Generator   g  = new Generator();
    PropertySet ps = new PropertySet();
    ps.set( Property.main_MakeBackup,         Standard.NO  );
    ps.set( Property.main_CompileCodeWriter,  Standard.YES );
    ps.set( Property.main_ExecuteCodeWriter,  Standard.NO  );
    g.setCmdPropertySet( ps );

    g.generate( new File( "src/org/jostraca/test/internal.jtm" ) );
    rumh = (RecordingUserMessageHandler) g.getUserMessageHandler();
    assertTrue( null != rumh );
    //System.out.println( rumh );
    assertEquals( 6, ((Vector)rumh.get( UserMessageHandler.DEBUG )).size() );
    assertEquals( 1, ((Vector)rumh.get( UserMessageHandler.INFO  )).size() );
    assertEquals( 0, ((Vector)rumh.get( UserMessageHandler.WARN  )).size() );
    assertEquals( 0, ((Vector)rumh.get( UserMessageHandler.ERROR )).size() );
    assertEquals( 0, ((Vector)rumh.get( UserMessageHandler.FATAL )).size() );

    internal_txt = new File( "internal.txt" );
    assertTrue( !internal_txt.exists() );

    // and now execute
    ps.set( Property.main_CompileCodeWriter,    Standard.EMPTY );
    ps.set( Property.main_ExecuteCodeWriter,    Standard.YES  );

    g.setCmdPropertySet( ps );
    g.generate( new File( "src/org/jostraca/test/internal.jtm" ), new RecordingUserMessageHandler() );

    rumh = (RecordingUserMessageHandler) g.getUserMessageHandler();
    assertTrue( null != rumh );
    //System.out.println( rumh );
    assertEquals( 6, ((Vector)rumh.get( UserMessageHandler.DEBUG )).size() );
    assertEquals( 2, ((Vector)rumh.get( UserMessageHandler.INFO  )).size() );
    assertEquals( 0, ((Vector)rumh.get( UserMessageHandler.WARN  )).size() );
View Full Code Here

TOP

Related Classes of org.jostraca.Generator

Copyright © 2018 www.massapicom. 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.