Package electric.xml

Examples of electric.xml.Document


    public Object getDocument(String url) throws FunctionCallException
    {
        try
        {
            return new Document( new File( url ) );
        }
        catch (ParseException e)
        {
            throw new FunctionCallException( e.getMessage() );
        }
View Full Code Here


  /**
   * Convenience method - Use ElectricXML to access the HTML in the response for easy access.
   */
  protected Document getDocument( WebResponse rs ) throws IOException, SAXException, ParseException {
    return new Document( new StringReader( XMLUtils.print( rs.getDOM() ) ) );
  }
View Full Code Here

* @version $Revision: 1.2 $
*/
public class FreemarkerDecoratorTest  extends WebTest {
    public void testFreemarkerDecoratedPage() throws Exception {
    WebResponse rs = wc.getResponse( baseUrl + "/freemarker/freemarker.jsp" );
    Document doc = getDocument( rs );
    assertEquals( "[:: Simple Freemarker Page ::]", rs.getTitle() );
    assertEquals( "Hello Freemarker World", doc.getElementWithId( "p1" ).getText().toString() );
    assertEquals( "footer", doc.getElementWithId( "footer" ).getText().toString() );
    assertEquals( "Simple Freemarker Page", doc.getElementWithId( "header" ).getText().toString() );
        assertEquals( "\u0126\u0118\u0139\u0139\u0150", doc.getElementWithId( "i18n" ).getText().toString() );
  }
View Full Code Here

* @version $Revision: 1.3 $
*/
public class VelocityDecoratorTest  extends WebTest {
    public void testVelocityDecoratedPage() throws Exception {
    WebResponse rs = wc.getResponse( baseUrl + "/velocity/velocity.jsp" );
    Document doc = getDocument( rs );
    assertEquals( "[:: Simple Velocity Page ::]", rs.getTitle() );
    assertEquals( "Hello Velocity world", doc.getElementWithId( "p1" ).getText().toString() );
    assertEquals( "footer", doc.getElementWithId( "footer" ).getText().toString() );
    assertEquals( "Simple Velocity Page", doc.getElementWithId( "header" ).getText().toString() );
        assertEquals( "\u0126\u0118\u0139\u0139\u0150", doc.getElementWithId( "i18n" ).getText().toString() );
  }
View Full Code Here

*/
public class SimpleDecoratorTest extends WebTest {

  public void testCompleteHtmlPage() throws Exception {
    WebResponse rs = wc.getResponse( baseUrl + "/simple/page1.jsp" );
    Document doc = getDocument( rs );
    assertEquals( "[:: Simple page1 ::]", rs.getTitle() );
    assertEquals( "Hello world 1", doc.getElementWithId( "p1" ).getText().toString() );
    assertEquals( "footer", doc.getElementWithId( "footer" ).getText().toString() );
    assertEquals( "Simple page1", doc.getElementWithId( "header" ).getText().toString() );
  }
View Full Code Here

    assertEquals( "Simple page1", doc.getElementWithId( "header" ).getText().toString() );
  }

  public void testHtmlWithTitleAndBodyContentsOnly() throws Exception {
    WebResponse rs = wc.getResponse( baseUrl + "/simple/page2.jsp" );
    Document doc = getDocument( rs );
    assertEquals( "[:: Simple page2 ::]", rs.getTitle() );
    assertEquals( "Hello world 2", doc.getElementWithId( "p2" ).getText().toString() );
    assertEquals( "footer", doc.getElementWithId( "footer" ).getText().toString() );
    assertEquals( "Simple page2", doc.getElementWithId( "header" ).getText().toString() );
  }
View Full Code Here

    assertEquals( "Simple page2", doc.getElementWithId( "header" ).getText().toString() );
  }

  public void testHtmlWithBodyContentsOnly() throws Exception {
    WebResponse rs = wc.getResponse( baseUrl + "/simple/page3.jsp" );
    Document doc = getDocument( rs );
    assertEquals( "[:: MySite ::]", rs.getTitle() );
    assertEquals( "Hello world 3", doc.getElementWithId( "mainbody" ).getText().toString() );
    assertEquals( "footer", doc.getElementWithId( "footer" ).getText().toString() );
    assertEquals( "MySite", doc.getElementWithId( "header" ).getText().toString() );
  }
View Full Code Here

     * Internationalisation Test - using inline declaration of the page's encoding
     * @throws Exception
     */
    public void testDocumentWithInternationalizedCharactersUsingInlineEncodingDeclaration() throws Exception {
    WebResponse rs = wc.getResponse( baseUrl + "/simple/page4.jsp" );
    Document doc = getDocument( rs );
    assertEquals( "[:: MySite ::]", rs.getTitle() );
    assertEquals( "\u0126\u0118\u0139\u0139\u0150 world 4", doc.getElementWithId( "mainbody" ).getText().toString() );
    assertEquals( "footer", doc.getElementWithId( "footer" ).getText().toString() );
    assertEquals( "MySite", doc.getElementWithId( "header" ).getText().toString() );
  }
View Full Code Here

     * then you can still use your i18n'd application with sitemesh, but you need to specify the encoding in each page
     * @throws Exception
     */
    public void testDocumentWithInternationalizedCharactersUsingEncodingFilter() throws Exception {
    WebResponse rs = wc.getResponse( baseUrl + "/simple/page5.jsp" );
    Document doc = getDocument( rs );
    assertEquals( "[:: MySite ::]", rs.getTitle() );
    assertEquals( "\u0126\u0118\u0139\u0139\u0150 world 5", doc.getElementWithId( "mainbody" ).getText().toString() );
    assertEquals( "footer", doc.getElementWithId( "footer" ).getText().toString() );
    assertEquals( "MySite", doc.getElementWithId( "header" ).getText().toString() );
  }
View Full Code Here

  }

    // Test to prove SIM-149 (ignore directories when using the FileDecoratorMapper)
    public void testFileDecoratorMapperExcludesDirectories() throws Exception {
        WebResponse rs = wc.getResponse( baseUrl + "/simple/page6.jsp" );
        Document doc = getDocument( rs );
        assertEquals( "[:: Simple page6 ::]", rs.getTitle() );
        assertEquals( "Hello world 6", doc.getElementWithId( "p1" ).getText().toString() );
        assertEquals( "footer", doc.getElementWithId( "footer" ).getText().toString() );
        assertEquals( "Simple page6", doc.getElementWithId( "header" ).getText().toString() );
    }
View Full Code Here

TOP

Related Classes of electric.xml.Document

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.