Package org.jostraca.util

Examples of org.jostraca.util.PropertySet


  }


  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 );
View Full Code Here


    System.out.println( "ref:"+pRefPS );
  }


  protected boolean confirmPropertySet( String pTestRoot, PropertySet pReferencePS ) {
    PropertySet testps = new PropertySet();
    testps.load( new File( getTestFolder(), PREFIX_RESULT + pTestRoot + DOT + TXT ) );
    boolean test = testps.equals( pReferencePS );

    if( !test ) {
      displayPropertySets( testps, pReferencePS );
    }
View Full Code Here

      = null == includeBaseFolder ? pPath
          : new File( includeBaseFolder, pPath).getAbsolutePath();
   
    try {
      TemplatePath tmpath = pTemplate.getTemplatePath();
      PropertySet tmps = pTemplate.getMergedPropertySet();

      // template relative is the default
      String includeBase = tmpath.getTemplateFolder();

      if( pArguments.contains(INCLUDE_MOD_output_relative) ) {
        includeBase = tmps.get( Property.main_OutputFolder );
      }


      File includeF = new File( pPath );
      if( includeF.isAbsolute() || pPath.startsWith("/") || pPath.startsWith("\\") ) {
        includeFilePath = pPath;
      }
      else {
        // REVIEW: possible user info message that include file does not exist when "if-exists" used?
        includeFilePath = includeBase + File.separatorChar + pPath;
      }

      boolean onlyifexists = pArguments.contains( INCLUDE_MOD_if_exists );

      String includeContent = Standard.EMPTY;

      try {
        includeContent = FileUtil.readFile( includeFilePath, ( onlyifexists ? FileUtil.EMPTY_IF_IO_ERROR : FileUtil.FAIL_ON_IO_ERROR ) );
      }

      // 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

   
    Hashtable h = new Hashtable();
    h.put( "n1", "v1" );
    h.put( "n2", "v2" );

    PropertySet ps = new PropertySet( h );
    assertEquals( "v1", ps.get("n1") );
    assertEquals( "v2", ps.get("n2") );


    String[] nvp = new String[] { "n1", "v1", "n2", "v2" };
    ps = new PropertySet( nvp );
    assertEquals( "v1", ps.get("n1") );
    assertEquals( "v2", ps.get("n2") );
  }
View Full Code Here

    assertEquals( "value: v file: f", inserts );
  }


  public void testOverrideAndInherit() {
    PropertySet a = new PropertySet();
    a.set( "n1", "a1"      );
    a.set( "n2", "$<n1>"   );
    a.set( "n3", "$<n3>"   );
    a.set( "n4", "x$<n1>y" );
    a.set( "n5", "x$<n3>y" );
    a.set( "n7", "a7"      );

    assertEquals( "a1",      a.get( "n1" ) );
    assertEquals( "a1",      a.get( "n2" ) );
    assertEquals( "$<n3>",   a.get( "n3" ) );
    assertEquals( "xa1y",    a.get( "n4" ) );
    assertEquals( "x$<n3>y", a.get( "n5" ) );
    assertEquals( "a7",      a.get( "n7" ) );


    PropertySet b = new PropertySet();
    b.set( "n1", "b1" );
    b.set( "n2", "b2" );
    b.set( "n3", "b3" );
    b.set( "n6", "b6" );
    b.set( "n7", "x$<n7>y" );

    PropertySet bo = (PropertySet) b.clone();
    bo.overrideWith( a );

    System.out.println( bo );

    assertEquals( "a1",      bo.getSourceValue( "n1" ) );
    assertEquals( "a1",      bo.get( "n1" ) );

    assertEquals( "$<n1>",   bo.getSourceValue( "n2" ) );
    assertEquals( "a1",      bo.get( "n2" ) );

    assertEquals( "b3",      bo.getSourceValue( "n3" ) );
    assertEquals( "b3",      bo.get( "n3" ) );

    assertEquals( "x$<n1>y", bo.getSourceValue( "n4" ) );
    assertEquals( "xa1y",    bo.get( "n4" ) );

    assertEquals( "x$<n3>y", bo.getSourceValue( "n5" ) );
    assertEquals( "xb3y",    bo.get( "n5" ) );

    assertEquals( "b6",      bo.getSourceValue( "n6" ) );
    assertEquals( "b6",      bo.get( "n6" ) );

    assertEquals( "a7",      bo.getSourceValue( "n7" ) );
    assertEquals( "a7",      bo.get( "n7" ) );


    PropertySet bi = (PropertySet) b.clone();
    bi.inheritFrom( a );


    assertEquals( "b1",      bi.getSourceValue( "n1" ) );
    assertEquals( "b1",      bi.get( "n1" ) );

    assertEquals( "b2",      bi.getSourceValue( "n2" ) );
    assertEquals( "b2",      bi.get( "n2" ) );

    assertEquals( "b3",      bi.getSourceValue( "n3" ) );
    assertEquals( "b3",      bi.get( "n3" ) );

    assertEquals( "x$<n1>y", bi.getSourceValue( "n4" ) );
    assertEquals( "xb1y",    bi.get( "n4" ) );

    assertEquals( "x$<n3>y", bi.getSourceValue( "n5" ) );
    assertEquals( "xb3y",    bi.get( "n5" ) );

    assertEquals( "b6",      bi.getSourceValue( "n6" ) );
    assertEquals( "b6",      bi.get( "n6" ) );

    assertEquals( "xa7y",    bi.getSourceValue( "n7" ) );
    assertEquals( "xa7y",    bi.get( "n7" ) );

  }
View Full Code Here

    } catch( IllegalArgumentException iae ) {}

    PropertySetManager psm01 = new PropertySetManager();
    PropertySetManager psm02 = new PropertySetManager( defps );

    PropertySet ps01 = new PropertySet();
    defps.put( "ps01", ps01 );
    PropertySetManager psm03 = new PropertySetManager( defps );

    defps.put( "ps02", new Object() );
    try {
View Full Code Here

  }


  public void testLoad() throws Exception {
    PropertySetManager psm01 = new PropertySetManager();
    PropertySet ps01 = psm01.load( "test01", Tools.findRelativeSystemPath("src/org/jostraca/util/test/test.conf") );
    assertEquals( "0", ps01.get("a") );
    assertEquals( "1", ps01.get("b") );

    try {
      psm01.load( "test02", new File("notest.conf") );
      fail();    
    } catch( PropertySetException ioe ) {}

    try {
      psm01.load( "test02", new File("notest.conf"), PropertySetManager.FILE_MUST_EXIST );
      fail();
    } catch( PropertySetException ioe ) {}

    try {
      PropertySet ps01o = psm01.load( "test01", new File("notest.conf"), PropertySetManager.USE_DEFAULT_IF_FILE_DOES_NOT_EXIST );
      assertEquals( ps01o, ps01 );
    } catch( PropertySetException ioe ) { fail(); }
  }
View Full Code Here

  }


  public void testAdd() {
    PropertySetManager psm01 = new PropertySetManager();
    PropertySet ps01 = new PropertySet();
    psm01.put( "ps01", ps01 );

    try {
      psm01.put( null, ps01 );
      fail();
View Full Code Here

  }


  public void testGet() {
    PropertySetManager psm01 = new PropertySetManager();
    PropertySet ps01 = new PropertySet();
    psm01.put( "ps01", ps01 );

    PropertySet ps01o = psm01.get( "ps01" );
    assertEquals( ps01, ps01o );

    try {
      psm01.get( "ps02" );
      fail();
View Full Code Here

  }


  public void testRemove() {
    PropertySetManager psm01 = new PropertySetManager();
    PropertySet ps01 = new PropertySet();
    psm01.put( "ps01", ps01 );
    PropertySet ps01o = psm01.remove( "ps01" );
    assertEquals( ps01, ps01o );

    try {
      psm01.get( "ps01" );
      fail();
View Full Code Here

TOP

Related Classes of org.jostraca.util.PropertySet

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.