Package org.jostraca

Examples of org.jostraca.BasicTemplatePath


  }


  public void testSetTemplateName() throws Exception {

    BasicTemplatePath btp = new BasicTemplatePath( "file.txt" );

    try {
      btp.setTemplateName( null );
      fail();
    } catch( IllegalArgumentException e ) {}

    try {
      btp.setTemplateName( "nonexistent-file.txt" );
      btp.resolve( new String[] {} );
      fail();
    } catch( TemplateException tpe ) {
      assertEquals( StandardException.Code.CAT_user, tpe.getCat() );
    }

    try {
      btp.setTemplateName( "/tmp" );
      btp.resolve( new String[] {} );
      fail();
    } catch( TemplateException tpe ) {
      assertEquals( StandardException.Code.CAT_user, tpe.getCat() );
    }

    try {
      btp.setTemplateName( "file.txt" );
      btp.resolve( new String[] {} );
      assertTrue( "file.txt".equals( btp.getTemplateName() ) );
      assertTrue( "file.txt".equals( btp.getTemplateFileName() ) );
      btp.resolve( new String[] {} );
    } catch( TemplateException tpe ) {
      fail();
    }

  }
View Full Code Here




  public void testSetTemplateNameFromFile() throws Exception {

    BasicTemplatePath btp = new BasicTemplatePath( "file.txt" );

    try {
      btp.setTemplateNameFromFile( null, null );
      fail();
    } catch( IllegalArgumentException e ) {}
    try {
      btp.setTemplateNameFromFile( "", null );
      fail();
    } catch( IllegalArgumentException e ) {}

    try {
      btp.setTemplateNameFromFile( null, "" );
      fail();
    } catch( IllegalArgumentException e ) {}


    try {
      btp.setTemplateNameFromFile( "nonexistent-file.txt", "nonexistant-folder/filelist.txt"  );
      btp.resolve( new String[] {} );
      fail();
    } catch( TemplateException tpe ) {
      assertEquals( StandardException.Code.CAT_user, tpe.getCat() );
    }

    // REVIEW: file.txt is found because it exists in the current folder - is this good?
    try {
      btp.setTemplateNameFromFile( "file.txt", "nonexistent-folder/filelist.txt"  );
      btp.resolve( new String[] {} );
    } catch( TemplateException tpe ) {
      fail();
    }
    try {
      btp.setTemplateNameFromFile( "some-file.txt", "nonexistent-folder/filelist.txt"  );
      btp.resolve( new String[] {} );
      fail();
    } catch( TemplateException tpe ) {
      assertEquals( StandardException.Code.CAT_user, tpe.getCat() );
    }


    try {
      btp.setTemplateNameFromFile( "nonexistent-file.txt", "folder/filelist.txt" );
      btp.resolve( new String[] {} );
      fail();
    } catch( TemplateException tpe ) {
      assertEquals( StandardException.Code.CAT_user, tpe.getCat() );
    }

    try {
      btp.setTemplateNameFromFile( "file.txt", "folder/filelist.txt" );
      btp.resolve( new String[] {} );
      assertTrue( ("folder"+File.separator+"file.txt").equals( btp.getTemplatePath() ) );
    }
    catch( TemplateException tpe ) {
      fail();
    }

    try {
      File tmpFile = File.createTempFile( "jostraca", "test" );
      btp.setTemplateNameFromFile( tmpFile.getAbsolutePath(), "folder/filelist.txt" );
      btp.resolve( new String[] {} );
      assertTrue( tmpFile.getAbsolutePath().equals( btp.getTemplatePath() ) );
    }
    catch( TemplateException tpe ) {
      fail();
    }

    try {
      btp.setTemplateNameFromFile( "file.txt", "filelist.txt" );
      assertTrue( "file.txt".equals( btp.getTemplateName() ) );
    } catch( TemplateException tpe ) {
      fail();
    }
   
  }
View Full Code Here

      }

      // HACK
      // try to load from template path
      catch( Throwable t ) {
        BasicTemplatePath includeRef = new BasicTemplatePath( pPath );
        includeRef.resolve( tmps.getList( Property.main_TemplatePath, Standard.COMMA  ));
        includeFilePath = includeRef.getTemplatePath();
        includeContent = FileUtil.readFile( includeFilePath, ( onlyifexists ? FileUtil.EMPTY_IF_IO_ERROR : FileUtil.FAIL_ON_IO_ERROR ) );
      }

      pTemplate.addFileBuildResource( includeFilePath );
     
View Full Code Here



  public void generate( String pTemplate, String pOptions ) throws Exception {
    Service s = new Service();
    s.setTemplatePaths( ListUtil.make( new BasicTemplatePath( iDependsFolder+pTemplate ) ) );
    s.setConfigFolder( iConfigFolder );
    s.addPropertySet( Service.CONF_system,  s.loadBaseConfigFiles( new File( iConfigFolder, "system.conf" ) ) );

    PropertySet props = new PropertySet();
    props.set( Property.main_OutputFolder,      iDependsFolder );
View Full Code Here

    PropertySet systemps = getSystemPropertySet();
    BasicTemplate tm = new BasicTemplate();
    tm.setPropertySet( Constants.CONF_system, systemps );

    String            tmfp = base+"/basic.jtm";
    BasicTemplatePath tmp01  = new BasicTemplatePath( tmfp );
    tmp01.resolve( new String[]{} );

    tm.load( tmp01 );

    //System.out.println( Constants.CONF_system+":\n"+tm.getPropertySet( Constants.CONF_system ) );
    //System.out.println( Constants.CONF_template+" after:\n"+tm.getPropertySet( Constants.CONF_template ) );
View Full Code Here

  }


  public void testSetTemplateName() throws Exception {

    BasicTemplatePath btp = new BasicTemplatePath( "file.txt" );

    try {
      btp.setTemplateName( null );
      fail();
    } catch( IllegalArgumentException e ) {}

    try {
      btp.setTemplateName( "nonexistent-file.txt" );
      btp.resolve( new String[] {} );
      fail();
    } catch( TemplateException tpe ) {
      assertEquals( StandardException.Code.CAT_user, tpe.getCat() );
    }

    try {
      btp.setTemplateName( "/tmp" );
      btp.resolve( new String[] {} );
      fail();
    } catch( TemplateException tpe ) {
      assertEquals( StandardException.Code.CAT_user, tpe.getCat() );
    }

    try {
      btp.setTemplateName( "src/org/jostraca/test/file.txt" );
      btp.resolve( new String[] {} );
      assertEquals( "src/org/jostraca/test/file.txt", btp.getTemplateName() );
      assertEquals( "file.txt", btp.getTemplateFileName() );
      btp.resolve( new String[] {} );
    } catch( TemplateException tpe ) {
      tpe.printStackTrace();
      fail();
    }
View Full Code Here



  public void testSetTemplateNameFromFile() throws Exception {

    BasicTemplatePath btp = new BasicTemplatePath( "src/org/jostraca/test/file.txt" );

    try {
      btp.setTemplateNameFromFile( null, null );
      fail();
    } catch( IllegalArgumentException e ) {}
    try {
      btp.setTemplateNameFromFile( "", null );
      fail();
    } catch( IllegalArgumentException e ) {}

    try {
      btp.setTemplateNameFromFile( null, "" );
      fail();
    } catch( IllegalArgumentException e ) {}


    try {
      btp.setTemplateNameFromFile( "nonexistent-file.txt", "nonexistant-folder/filelist.txt"  );
      btp.resolve( new String[] {} );
      fail();
    } catch( TemplateException tpe ) {
      assertEquals( StandardException.Code.CAT_user, tpe.getCat() );
    }

    // REVIEW: file.txt is found because it exists  - is this good?
    try {
      btp.setTemplateNameFromFile( "src/org/jostraca/test/file.txt", "nonexistent-folder/filelist.txt"  );
      btp.resolve( new String[] {} );
    } catch( TemplateException tpe ) {
      fail();
    }
    try {
      btp.setTemplateNameFromFile( "some-file.txt", "nonexistent-folder/filelist.txt"  );
      btp.resolve( new String[] {} );
      fail();
    } catch( TemplateException tpe ) {
      assertEquals( StandardException.Code.CAT_user, tpe.getCat() );
    }


    try {
      btp.setTemplateNameFromFile( "nonexistent-file.txt", "src/org/jostraca/test/folder/filelist.txt" );
      btp.resolve( new String[] {} );
      fail();
    } catch( TemplateException tpe ) {
      assertEquals( StandardException.Code.CAT_user, tpe.getCat() );
    }

    try {
      btp.setTemplateNameFromFile( "src/org/jostraca/test/file.txt", "src/org/jostraca/test/folder/filelist.txt" );
      btp.resolve( new String[] {} );
      //assertTrue( ("folder"+File.separator+"file.txt").equals( btp.getTemplatePath() ) );
    }
    catch( TemplateException tpe ) {
      fail();
    }

    try {
      File tmpFile = File.createTempFile( "jostraca", "test" );
      btp.setTemplateNameFromFile( tmpFile.getAbsolutePath(), "src/org/jostraca/test/folder/filelist.txt" );
      btp.resolve( new String[] {} );
      assertTrue( tmpFile.getAbsolutePath().equals( btp.getTemplatePath() ) );
    }
    catch( TemplateException tpe ) {
      fail();
    }

    try {
      btp.setTemplateNameFromFile( "src/org/jostraca/test/file.txt", "src/org/jostraca/test/filelist.txt" );
      assertTrue( "src/org/jostraca/test/file.txt".equals( btp.getTemplateName() ) );
    } catch( TemplateException tpe ) {
      fail();
    }
   
  }
View Full Code Here

    PropertySet systemps = getSystemPropertySet();
    BasicTemplate tm = new BasicTemplate();
    tm.setPropertySet( Constants.CONF_system, systemps );

    String            tmfp = base+"/tm/"+pName+".jtm";
    BasicTemplatePath tmp01  = new BasicTemplatePath( tmfp );
    tmp01.resolve( new String[]{} );

    tm.load( tmp01 );

    return tm;
  }
View Full Code Here

TOP

Related Classes of org.jostraca.BasicTemplatePath

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.