summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Suhren <suhren.stefan@fh-swf.de>2015-12-14 01:10:44 +0100
committerStefan Suhren <suhren.stefan@fh-swf.de>2015-12-14 01:10:44 +0100
commitbeb8b65652d4e44256aa95dce8d431b093b40543 (patch)
treed38850414338dfb639224bec47041b337f72ceb5
parent188c3afc3b8396fba1d5d7767b5ec8f21b6d9732 (diff)
downloadJCatalog-beb8b65652d4e44256aa95dce8d431b093b40543.tar.gz
JCatalog-beb8b65652d4e44256aa95dce8d431b093b40543.zip
Add tests for products and categoriesportToJWebUnit
-rw-r--r--WebContent/pages/categories.xhtml2
-rw-r--r--WebContent/pages/products.xhtml2
-rw-r--r--WebContent/templates/common.xhtml2
-rw-r--r--test/htmlunit/JCatalogTest.java31
4 files changed, 34 insertions, 3 deletions
diff --git a/WebContent/pages/categories.xhtml b/WebContent/pages/categories.xhtml
index 7c3ecac..9e9ad4f 100644
--- a/WebContent/pages/categories.xhtml
+++ b/WebContent/pages/categories.xhtml
@@ -39,7 +39,7 @@
<h:outputText value="" />
</f:facet>
<h:commandLink value="View Details ..." immediate="true"
- actionListener="#{CategoryManager.select}" action="select">
+ actionListener="#{CategoryManager.select}" action="select" id="detailsLink">
<f:param name="selectedId" value="#{category.id}" />
</h:commandLink>
</h:column>
diff --git a/WebContent/pages/products.xhtml b/WebContent/pages/products.xhtml
index 8050c30..ac1ed63 100644
--- a/WebContent/pages/products.xhtml
+++ b/WebContent/pages/products.xhtml
@@ -46,7 +46,7 @@
<h:outputText value="" />
</f:facet>
<h:commandLink value="View Details ..." immediate="true"
- actionListener="#{ProductManager.select}" action="select">
+ actionListener="#{ProductManager.select}" action="select" id="detailsLink">
<f:param name="selectedId" value="#{product.id}" />
</h:commandLink>
</h:column>
diff --git a/WebContent/templates/common.xhtml b/WebContent/templates/common.xhtml
index 39139d6..467c015 100644
--- a/WebContent/templates/common.xhtml
+++ b/WebContent/templates/common.xhtml
@@ -31,7 +31,7 @@
</h:commandLink>
</li>
<li>
- <h:commandLink action="categories">
+ <h:commandLink action="categories" id="catalogLink">
<h:outputText id="catalog" value="Catalog" />
</h:commandLink>
</li>
diff --git a/test/htmlunit/JCatalogTest.java b/test/htmlunit/JCatalogTest.java
index 152109d..38cbea0 100644
--- a/test/htmlunit/JCatalogTest.java
+++ b/test/htmlunit/JCatalogTest.java
@@ -2,6 +2,7 @@ package htmlunit;
import static net.sourceforge.jwebunit.junit.JWebUnit.assertLinkNotPresent;
import static net.sourceforge.jwebunit.junit.JWebUnit.assertLinkPresent;
+import static net.sourceforge.jwebunit.junit.JWebUnit.assertTextFieldEquals;
import static net.sourceforge.jwebunit.junit.JWebUnit.assertTextInElement;
import static net.sourceforge.jwebunit.junit.JWebUnit.assertTitleEquals;
import static net.sourceforge.jwebunit.junit.JWebUnit.beginAt;
@@ -62,4 +63,34 @@ public class JCatalogTest
assertLinkPresent("navcontainer:loginLink");
assertLinkNotPresent("navcontainer:logoutLink");
}
+
+ @Test
+ public void testCategoriesPage()
+ {
+ beginAt("home.jsf");
+
+ clickLink("navcontainer:catalogLink");
+
+ assertTextInElement("categories:categoriestable", "Category One");
+ }
+
+ @Test
+ public void testProductsPage()
+ {
+ testCategoriesPage();
+
+ clickLink("categories:categoriestable:0:detailsLink");
+
+ assertTextInElement("products:producttable", "Product1");
+ }
+
+ @Test
+ public void testProductPage()
+ {
+ testProductsPage();
+
+ clickLink("products:producttable:0:detailsLink");
+
+ assertTextFieldEquals("j_idt17:name", "Product1");
+ }
}