Webiyo

This page was generated using Webiyo. See its source code and unit tests.

org/webiyo/examples/sourceforge/SourceForgePageChecker.java

package org.webiyo.examples.sourceforge;

import junit.framework.Assert;
import org.webiyo.util.test.ElementChecker;
import org.webiyo.web.Renderable;
import org.webiyo.xml.XmlException;
import org.xml.sax.SAXException;

import java.io.File;
import java.io.IOException;
import java.util.Iterator;

class SourceForgePageChecker extends org.webiyo.util.test.PageChecker {

    public SourceForgePageChecker(Renderable renderable) throws IOException, SAXException {
        super(renderable);
    }

    public SourceForgePageChecker(File file) throws IOException, SAXException {
        super(file);
    }

    public void checkBasics(String expectedTitle, String pathToSiteRoot) throws XmlException {
        checkTitle(expectedTitle);
        checkStylesheetLink(pathToSiteRoot + "style.css");
        checkText("Webiyo", "/html/body//h1");

        ElementChecker nav = navigateTo("//td[@class='left-side-top']");

        Iterator<ElementChecker> linkIt = nav.select("ul/li").iterator();
        linkIt.next().checkNonBreakingLink(pathToSiteRoot + "index.html", "Home", "a");
        linkIt.next().checkNonBreakingLink(pathToSiteRoot + "changeLog.html", "Development History", "a");
        linkIt.next().checkNonBreakingLink("http://sourceforge.net/projects/webiyo/", "SourceForge Project", "a");
        Assert.assertFalse(linkIt.hasNext());

        ElementChecker sourceForgeLogo = navigateTo("/html/body//a[@href='http://sourceforge.net/']");
        String expectedImage =
                "http://sourceforge.net/sflogo.php?group_id=" + Project.WEBIYO_GROUP_ID + "&type=1";
        sourceForgeLogo.checkText(expectedImage, "img/@src");


        checkText("2", "/html/body//td[@class='right-side']/@rowspan");
    }

    public void checkSeeSource(String expectedSourceHref, String expectedUnitTestsHref) throws XmlException {

        ElementChecker seeSource = navigateTo("//td[@class='left-side-top']/div[@class='see-source']");
        seeSource.checkText("This page was generated using Webiyo.  See its source code and unit tests.", ".");

        seeSource.checkLink(expectedSourceHref, "source code", "a[1]");
        seeSource.checkLink(expectedUnitTestsHref, "unit tests.", "a[2]");

    }

}
SourceForge