Package org.jostraca

Examples of org.jostraca.Block


    TemplateActionHandlerStub tahs  = new TemplateActionHandlerStub();
    PropertySet               ps    = new PropertySet();
    ps.load( new File( "../../../../conf/system.conf" ) );
    BasicTextElementProcessor btep = create( ps, tahs );
    String content   = "content";
    Block  textBlock = new Block( Block.TYPE_text, content );

    assertTrue( btep.isMatch( textBlock ) );

    btep.process( textBlock );
View Full Code Here


  public void testProcessText() throws Exception {
    TemplateActionHandlerStub     tahs  = new TemplateActionHandlerStub();
    BasicTemplateElementProcessor btep = create( tahs );
    String content   = "content";
    Block  textBlock = new Block( Block.TYPE_text, content );
    btep.process( textBlock );

    assertTrue( content.equals( tahs.getLastAppendedContent() ) );
  }
View Full Code Here

    ps.load( new File( "../../../../conf/system.conf" ) );
    BasicDirectiveElementProcessor bdep = create( ps, tahs );

    tahs.clear();
    String s01 = "foo = bar;";
    Block  b01 = new Block( Block.TYPE_script, s01 );
    assertTrue( ! bdep.isMatch( b01 ) );

    tahs.clear();
    String s02 = "@foo bar;";
    Block  b02 = new Block( Block.TYPE_script, s02 );
    assertTrue( bdep.isMatch( b02 ) );

    tahs.clear();
    String s03 = " @section bar ";
    Block  b03 = new Block( Block.TYPE_script, s03 );
    assertTrue( bdep.isMatch( b03 ) );
    bdep.process( b03 );
    assertTrue( "bar".equals( tahs.getDefaultSectionName() ) );
    String s04 = " @section ";
    Block  b04 = new Block( Block.TYPE_script, s04 );
    assertTrue( bdep.isMatch( b04 ) );
    bdep.process( b04 );
    assertTrue( Section.NAME_body.equals( tahs.getDefaultSectionName() ) );

  }
View Full Code Here

    // REVIEW: this will have to change
    ps.set( Property.jostraca_old, "yes" );

    BasicExpressionElementProcessor beep = create( ps, tahs );
    String content  = "=exp";
    Block  expBlock = new Block( Block.TYPE_script, content );

    assertTrue( beep.isMatch( expBlock ) );

    beep.process( expBlock );
View Full Code Here

    ps.set( Property.jostraca_old, "yes" );


    tahs.clear();
    String s01 = "foo = bar;";
    Block  b01 = new Block( Block.TYPE_script, s01 );
    assertTrue( bsep.isMatch( b01 ) );
    bsep.process( b01 );
    assertEquals( (s01+BasicTemplateElementProcessor.NEWLINE), tahs.getLastAppendedContent() );

    tahs.clear();
    String s02 = "!foo bar;";
    Block  b02 = new Block( Block.TYPE_script, s02 );
    assertTrue( bsep.isMatch( b02 ) );
    bsep.process( b02 );
    assertTrue( ("foo bar;"+BasicTemplateElementProcessor.NEWLINE).equals( tahs.getLastAppendedContent() ) );
    assertTrue( Section.NAME_declare.equals( tahs.getLastSectionName() ) );

    tahs.clear();
    String s03 = " ! foo bar;";
    Block  b03 = new Block( Block.TYPE_script, s03 );
    assertTrue( bsep.isMatch( b03 ) );
    bsep.process( b03 );
    assertTrue( (" foo bar;"+BasicTemplateElementProcessor.NEWLINE).equals( tahs.getLastAppendedContent() ) );
    assertTrue( Section.NAME_declare.equals( tahs.getLastSectionName() ) );

    tahs.clear();
    String s04 = "foo! bar;";
    Block  b04 = new Block( Block.TYPE_script, s04 );
    assertTrue( bsep.isMatch( b04 ) );
    bsep.process( b04 );
    assertTrue( (" bar;"+BasicTemplateElementProcessor.NEWLINE).equals( tahs.getLastAppendedContent() ) );
    assertTrue( "foo".equals( tahs.getLastSectionName() ) );

    tahs.clear();
    String s05 = "foo ! bar;";
    Block  b05 = new Block( Block.TYPE_script, s05 );
    assertTrue( bsep.isMatch( b05 ) );
    bsep.process( b05 );
    assertTrue( ("foo ! bar;"+BasicTemplateElementProcessor.NEWLINE).equals( tahs.getLastAppendedContent() ) );
    assertEquals( Section.NAME_body, tahs.getLastSectionName() );
View Full Code Here



  public void testContent() {
    String c1 = "c1";
    Block b1 = new Block( Block.TYPE_text, c1 );
    assertTrue( c1.equals( b1.getContent() ) );

    String c2 = "c2";
    Block b2 = new Block( Block.TYPE_script, c2 );
    assertTrue( c2.equals( b2.getContent() ) );
  }
View Full Code Here



  public void testTypeAndEquals() {
    String c1 = "c1";
    Block b1 = new Block( Block.TYPE_text, c1 );
    assertTrue( b1.isText() );
    assertTrue( !b1.isScript() );
    assertTrue( Block.TYPE_text == b1.getType() );
    Block b1e = new Block( Block.TYPE_text, c1 );
    assertEquals( b1, b1e );

    String c2 = "c2";
    Block b2 = new Block( Block.TYPE_script, c2 );
    assertTrue( b2.isScript() );
    assertTrue( !b2.isText() );
    assertTrue( Block.TYPE_script == b2.getType() );
    Block b2e = new Block( Block.TYPE_script, c2 );
    assertEquals( b2, b2e );

    assertTrue( !b1.equals( b2 ) );
  }
View Full Code Here


  public void testParseText() throws Exception {
    String p01 = "text";
    BlockList bl01 = new BlockList();
    bl01.add( new Block( Block.TYPE_text, p01 ) );

    BlockList bl01o = parse( p01 );
    //System.out.println( bl01o );
    assertEquals( bl01, bl01o );
  }
View Full Code Here

  }

  public void testParseScript() throws Exception {
    String p01 = "<%script%>";
    BlockList bl01 = new BlockList();
    bl01.add( new Block( Block.TYPE_script, "script" ) );

    BlockList bl01o = parse( p01 );
    //System.out.println( bl01o );
    assertEquals( bl01, bl01o );
  }
View Full Code Here


  public void testParseUsual() throws Exception {
    String p01 = "text1\n<% script1 %>\n<% @d foo %>\ntext2 \ntext3<%-- a comment --%>\n<% script3 %> text4\n";
    BlockList bl01 = new BlockList();
    bl01.add( new Block( Block.TYPE_text,   "text1\n"   ) );
    bl01.add( new Block( Block.TYPE_script, " script1 " ) );
    bl01.add( new Block( Block.TYPE_text,   "\n"        ) );
    bl01.add( new Block( Block.TYPE_script, " @d foo "  ) );
    bl01.add( new Block( Block.TYPE_text,   "\ntext2 \ntext3" ) );
    bl01.add( new Block( Block.TYPE_text,   "\n"              ) );
    bl01.add( new Block( Block.TYPE_script, " script3 "       ) );
    bl01.add( new Block( Block.TYPE_text,   " text4\n"        ) );

    BlockList bl01o = parse( p01 );
    //System.out.println( bl01o );
    assertEquals( bl01, bl01o );
  }
View Full Code Here

TOP

Related Classes of org.jostraca.Block

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.