Package org.jostraca

Examples of org.jostraca.Block



  public void testParseScriptEnds() throws Exception {
    String p01 = "<% script1 %> text1 <% script2 %>";
    BlockList bl01 = new BlockList();
    bl01.add( new Block( Block.TYPE_script, " script1 " ) );
    bl01.add( new Block( Block.TYPE_text,   " text1 "   ) );
    bl01.add( new Block( Block.TYPE_script, " script2 " ) );

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



  public void testParseCommentEnds() throws Exception {
    String p01 = "<%-- comment1 --%><% script1 %> text1 <% script2 %><%-- comment2 --%>";
    BlockList bl01 = new BlockList();
    bl01.add( new Block( Block.TYPE_script, " script1 " ) );
    bl01.add( new Block( Block.TYPE_text,   " text1 "   ) );
    bl01.add( new Block( Block.TYPE_script, " script2 " ) );

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


  public void testParseCommentInsides() throws Exception {
    String p01 = "<% script1 %> text1 <%--<%foo%>--%> <%--<%--%> <%--%>--%> <% script2 %>";
    BlockList bl01 = new BlockList();
    bl01.add( new Block( Block.TYPE_script, " script1 " ) );
    bl01.add( new Block( Block.TYPE_text,   " text1 "   ) );
    bl01.add( new Block( Block.TYPE_text,   " "   ) );
    bl01.add( new Block( Block.TYPE_text,   " "   ) );
    bl01.add( new Block( Block.TYPE_text,   " "   ) );
    bl01.add( new Block( Block.TYPE_script, " script2 " ) );

    BlockList bl01o = parse( p01 );
    //System.out.println( bl01o );
    assertEquals( bl01, bl01o );
  }
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

  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

    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 testList() {
    BlockList bl = new BlockList();

    String c1 = "c1";
    String c2 = "c2";
    bl.add( new Block( Block.TYPE_text, c1 ) );
    bl.add( new Block( Block.TYPE_script, c2 ) );

    Block b;
    assertTrue( bl.hasMoreBlocks() );
    b = bl.nextBlock();
    assertTrue( c1.equals( b.getContent() ) );
    assertTrue( b.isText() );

    assertTrue( bl.hasMoreBlocks() );
    b = bl.nextBlock();
    assertTrue( c2.equals( b.getContent() ) );
    assertTrue( b.isScript() );

    assertTrue( !bl.hasMoreBlocks() );
  }
View Full Code Here

    assertTrue( !bl.hasMoreBlocks() );
  }

  public void testEquals() {
    BlockList bl1 = new BlockList();
    bl1.add( new Block( Block.TYPE_text, "c1" ) );
    bl1.add( new Block( Block.TYPE_script, "c2" ) );

    BlockList bl2 = new BlockList();
    bl2.add( new Block( Block.TYPE_text, "c1" ) );
    bl2.add( new Block( Block.TYPE_script, "c2" ) );

    assertEquals( bl1, bl2 );

    BlockList bl3 = new BlockList();
    bl3.add( new Block( Block.TYPE_text, "c1x" ) );
    bl3.add( new Block( Block.TYPE_script, "c2" ) );

    assertTrue( !bl1.equals(bl3) );
    assertTrue( !bl3.equals(bl2) );

    BlockList bl4 = new BlockList();
    bl4.add( new Block( Block.TYPE_script, "c1" ) );
    bl4.add( new Block( Block.TYPE_text, "c2" ) );

    assertTrue( !bl1.equals(bl4) );
    assertTrue( !bl4.equals(bl2) );
    assertTrue( !bl3.equals(bl4) );
  }
View Full Code Here

    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

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.