Package org.apache.tapestry5.dom

Examples of org.apache.tapestry5.dom.Document


                {
                    setupRequestFromLink(link);
                    continue;
                }

                Document result = response.getRenderedDocument();

                if (result == null)
                    throw new RuntimeException(String.format("Render of page '%s' did not result in a Document.",
                            pageName));
View Full Code Here


                {
                    setupRequestFromLink(link);
                    continue;
                }

                Document result = response.getRenderedDocument();

                if (result == null)
                    throw new RuntimeException(String.format("Render request '%s' did not result in a Document.",
                            request.getPath()));
View Full Code Here

        PageTester tester = new PageTester(appPackage, appName, "src/test/resources/webapp");
       
        EasyMock.expect(MockFactory.getInstance().getMockedServletRequest().getUserPrincipal()).andReturn(null).times(2);
       
        EasyMock.replay(MockFactory.getInstance().getMockedObjects());
        Document dom = tester.renderPage("LoggedIn");
        EasyMock.verify(MockFactory.getInstance().getMockedObjects());
       
        assertTrue(dom.toString().contains("Welcome back anonymous"));
       
        EasyMock.reset(MockFactory.getInstance().getMockedObjects());
       
       
        EasyMock.expect(MockFactory.getInstance().getMockedServletRequest().getUserPrincipal()).andReturn(new Principal() {

      @Override
      public String getName() {
        return "User1";
      }}).times(2);
       
        EasyMock.replay(MockFactory.getInstance().getMockedObjects());
        dom = tester.renderPage("LoggedIn");
        EasyMock.verify(MockFactory.getInstance().getMockedObjects());
        EasyMock.reset(MockFactory.getInstance().getMockedObjects());
         assertTrue(dom.toString().contains("Welcome back user"));
       
  }
View Full Code Here

    }

    @Test
    public void do_nothing_if_no_body()
    {
        Document document = new Document();

        document.newRootElement("not-html").text("not an HTML document");

        DocumentLinkerImpl linker = new DocumentLinkerImpl(true);

        linker.addScript("foo.js");
        linker.addScript("doSomething();");

        linker.updateDocument(document);

        assertEquals(document.toString(), "<not-html>not an HTML document</not-html>");
    }
View Full Code Here

    }

    @Test
    public void add_script_links() throws Exception
    {
        Document document = new Document(new XMLMarkupModel());

        document.newRootElement("html").element("body").element("p").text("Ready to be updated with scripts.");

        DocumentLinkerImpl linker = new DocumentLinkerImpl(true);

        linker.addScriptLink("foo.js");
        linker.addScriptLink("bar/baz.js");
View Full Code Here

    }

    @Test
    public void add_style_links() throws Exception
    {
        Document document = new Document(new XMLMarkupModel());

        document.newRootElement("html").element("body").element("p").text("Ready to be updated with styles.");

        DocumentLinkerImpl linker = new DocumentLinkerImpl(true);

        linker.addStylesheetLink("foo.css", null);
        linker.addStylesheetLink("bar/baz.css", "print");
View Full Code Here

    }

    @Test
    public void duplicate_scripts_ignored_first_media_wins() throws Exception
    {
        Document document = new Document(new XMLMarkupModel());

        document.newRootElement("html").element("body").element("p").text("Ready to be updated with styles.");

        DocumentLinkerImpl linker = new DocumentLinkerImpl(true);

        linker.addStylesheetLink("foo.css", null);
        linker.addStylesheetLink("bar/baz.css", "print");
View Full Code Here

    }

    @Test
    public void existing_head_used_if_present() throws Exception
    {
        Document document = new Document(new XMLMarkupModel());

        document.newRootElement("html").element("head").comment("existing head").getParent()
                .element("body").text("body content");

        DocumentLinkerImpl linker = new DocumentLinkerImpl(true);

        linker.addStylesheetLink("foo.css", null);
View Full Code Here

    }

    @Test
    public void duplicate_script_links_ignored() throws Exception
    {
        Document document = new Document();

        document.newRootElement("html").element("body").element("p").text("Ready to be updated with scripts.");

        DocumentLinkerImpl linker = new DocumentLinkerImpl(true);

        for (int i = 0; i < 3; i++)
        {
View Full Code Here

    }

    @Test
    public void add_script() throws Exception
    {
        Document document = new Document();

        document.newRootElement("html").element("body").element("p").text("Ready to be updated with scripts.");

        DocumentLinkerImpl linker = new DocumentLinkerImpl(true);

        linker.addScript("doSomething();");
        linker.addScript("doSomethingElse();");

        linker.updateDocument(document);

        assertEquals(document.toString(), readFile("add_script.txt").trim());
    }
View Full Code Here

TOP

Related Classes of org.apache.tapestry5.dom.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.