summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.classpath23
-rw-r--r--.settings/org.eclipse.wst.common.component4
-rw-r--r--lib/commons-codec-1.8.jarbin0 -> 263865 bytes
-rw-r--r--lib/commons-collections-3.2.1.jarbin0 -> 575389 bytes
-rw-r--r--lib/commons-io-2.4.jarbin0 -> 185140 bytes
-rw-r--r--lib/commons-lang3-3.1.jarbin0 -> 315805 bytes
-rw-r--r--lib/commons-logging-1.1.3.jarbin0 -> 62050 bytes
-rw-r--r--lib/cssparser-0.9.11.jarbin0 -> 354562 bytes
-rw-r--r--lib/htmlunit-2.13.jarbin0 -> 1289147 bytes
-rw-r--r--lib/htmlunit-core-js-2.13.jarbin0 -> 1032764 bytes
-rw-r--r--lib/httpclient-4.3.1.jarbin0 -> 585602 bytes
-rw-r--r--lib/httpcore-4.3.jarbin0 -> 282160 bytes
-rw-r--r--lib/httpmime-4.3.1.jarbin0 -> 37078 bytes
-rw-r--r--lib/jetty-http-8.1.12.v20130726.jarbin0 -> 96042 bytes
-rw-r--r--lib/jetty-io-8.1.12.v20130726.jarbin0 -> 104233 bytes
-rw-r--r--lib/jetty-util-8.1.12.v20130726.jarbin0 -> 287536 bytes
-rw-r--r--lib/jetty-websocket-8.1.12.v20130726.jarbin0 -> 125946 bytes
-rw-r--r--lib/nekohtml-1.9.19.jarbin0 -> 124915 bytes
-rw-r--r--lib/sac-1.3.jarbin0 -> 15808 bytes
-rw-r--r--lib/serializer-2.7.1.jarbin0 -> 278281 bytes
-rw-r--r--lib/xalan-2.7.1.jarbin0 -> 3176148 bytes
-rw-r--r--lib/xercesImpl-2.11.0.jarbin0 -> 1367760 bytes
-rw-r--r--lib/xml-apis-1.4.01.jarbin0 -> 220536 bytes
-rw-r--r--test/htmlunit/JCatalogTest.java101
24 files changed, 126 insertions, 2 deletions
diff --git a/.classpath b/.classpath
index 0168508..931fd8a 100644
--- a/.classpath
+++ b/.classpath
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="test"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="oracle.eclipse.tools.glassfish.lib.system">
<attributes>
@@ -12,5 +13,27 @@
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
+ <classpathentry kind="lib" path="lib/commons-codec-1.8.jar"/>
+ <classpathentry kind="lib" path="lib/commons-collections-3.2.1.jar"/>
+ <classpathentry kind="lib" path="lib/commons-io-2.4.jar"/>
+ <classpathentry kind="lib" path="lib/commons-lang3-3.1.jar"/>
+ <classpathentry kind="lib" path="lib/commons-logging-1.1.3.jar"/>
+ <classpathentry kind="lib" path="lib/cssparser-0.9.11.jar"/>
+ <classpathentry kind="lib" path="lib/htmlunit-2.13.jar"/>
+ <classpathentry kind="lib" path="lib/htmlunit-core-js-2.13.jar"/>
+ <classpathentry kind="lib" path="lib/httpclient-4.3.1.jar"/>
+ <classpathentry kind="lib" path="lib/httpcore-4.3.jar"/>
+ <classpathentry kind="lib" path="lib/httpmime-4.3.1.jar"/>
+ <classpathentry kind="lib" path="lib/jetty-http-8.1.12.v20130726.jar"/>
+ <classpathentry kind="lib" path="lib/jetty-io-8.1.12.v20130726.jar"/>
+ <classpathentry kind="lib" path="lib/jetty-util-8.1.12.v20130726.jar"/>
+ <classpathentry kind="lib" path="lib/jetty-websocket-8.1.12.v20130726.jar"/>
+ <classpathentry kind="lib" path="lib/nekohtml-1.9.19.jar"/>
+ <classpathentry kind="lib" path="lib/sac-1.3.jar"/>
+ <classpathentry kind="lib" path="lib/serializer-2.7.1.jar"/>
+ <classpathentry kind="lib" path="lib/xalan-2.7.1.jar"/>
+ <classpathentry kind="lib" path="lib/xercesImpl-2.11.0.jar"/>
+ <classpathentry kind="lib" path="lib/xml-apis-1.4.01.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component
index 320180b..4c63d6e 100644
--- a/.settings/org.eclipse.wst.common.component
+++ b/.settings/org.eclipse.wst.common.component
@@ -1,8 +1,8 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project-modules id="moduleCoreId" project-version="1.5.0">
+<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="JCatalog">
<wb-resource deploy-path="/" source-path="/WebContent"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
+ <wb-resource deploy-path="/WEB-INF/classes" source-path="/test"/>
<property name="context-root" value="JCatalog"/>
<property name="java-output-path" value="build/classes"/>
</wb-module>
diff --git a/lib/commons-codec-1.8.jar b/lib/commons-codec-1.8.jar
new file mode 100644
index 0000000..32f84c9
--- /dev/null
+++ b/lib/commons-codec-1.8.jar
Binary files differ
diff --git a/lib/commons-collections-3.2.1.jar b/lib/commons-collections-3.2.1.jar
new file mode 100644
index 0000000..c35fa1f
--- /dev/null
+++ b/lib/commons-collections-3.2.1.jar
Binary files differ
diff --git a/lib/commons-io-2.4.jar b/lib/commons-io-2.4.jar
new file mode 100644
index 0000000..90035a4
--- /dev/null
+++ b/lib/commons-io-2.4.jar
Binary files differ
diff --git a/lib/commons-lang3-3.1.jar b/lib/commons-lang3-3.1.jar
new file mode 100644
index 0000000..a85e539
--- /dev/null
+++ b/lib/commons-lang3-3.1.jar
Binary files differ
diff --git a/lib/commons-logging-1.1.3.jar b/lib/commons-logging-1.1.3.jar
new file mode 100644
index 0000000..ab51254
--- /dev/null
+++ b/lib/commons-logging-1.1.3.jar
Binary files differ
diff --git a/lib/cssparser-0.9.11.jar b/lib/cssparser-0.9.11.jar
new file mode 100644
index 0000000..49eea5c
--- /dev/null
+++ b/lib/cssparser-0.9.11.jar
Binary files differ
diff --git a/lib/htmlunit-2.13.jar b/lib/htmlunit-2.13.jar
new file mode 100644
index 0000000..c233adb
--- /dev/null
+++ b/lib/htmlunit-2.13.jar
Binary files differ
diff --git a/lib/htmlunit-core-js-2.13.jar b/lib/htmlunit-core-js-2.13.jar
new file mode 100644
index 0000000..ad61e8b
--- /dev/null
+++ b/lib/htmlunit-core-js-2.13.jar
Binary files differ
diff --git a/lib/httpclient-4.3.1.jar b/lib/httpclient-4.3.1.jar
new file mode 100644
index 0000000..cdd1e38
--- /dev/null
+++ b/lib/httpclient-4.3.1.jar
Binary files differ
diff --git a/lib/httpcore-4.3.jar b/lib/httpcore-4.3.jar
new file mode 100644
index 0000000..ddfe6da
--- /dev/null
+++ b/lib/httpcore-4.3.jar
Binary files differ
diff --git a/lib/httpmime-4.3.1.jar b/lib/httpmime-4.3.1.jar
new file mode 100644
index 0000000..2b26d7a
--- /dev/null
+++ b/lib/httpmime-4.3.1.jar
Binary files differ
diff --git a/lib/jetty-http-8.1.12.v20130726.jar b/lib/jetty-http-8.1.12.v20130726.jar
new file mode 100644
index 0000000..30adfb5
--- /dev/null
+++ b/lib/jetty-http-8.1.12.v20130726.jar
Binary files differ
diff --git a/lib/jetty-io-8.1.12.v20130726.jar b/lib/jetty-io-8.1.12.v20130726.jar
new file mode 100644
index 0000000..e37e715
--- /dev/null
+++ b/lib/jetty-io-8.1.12.v20130726.jar
Binary files differ
diff --git a/lib/jetty-util-8.1.12.v20130726.jar b/lib/jetty-util-8.1.12.v20130726.jar
new file mode 100644
index 0000000..41a76e0
--- /dev/null
+++ b/lib/jetty-util-8.1.12.v20130726.jar
Binary files differ
diff --git a/lib/jetty-websocket-8.1.12.v20130726.jar b/lib/jetty-websocket-8.1.12.v20130726.jar
new file mode 100644
index 0000000..1b93315
--- /dev/null
+++ b/lib/jetty-websocket-8.1.12.v20130726.jar
Binary files differ
diff --git a/lib/nekohtml-1.9.19.jar b/lib/nekohtml-1.9.19.jar
new file mode 100644
index 0000000..979ffde
--- /dev/null
+++ b/lib/nekohtml-1.9.19.jar
Binary files differ
diff --git a/lib/sac-1.3.jar b/lib/sac-1.3.jar
new file mode 100644
index 0000000..39b92b1
--- /dev/null
+++ b/lib/sac-1.3.jar
Binary files differ
diff --git a/lib/serializer-2.7.1.jar b/lib/serializer-2.7.1.jar
new file mode 100644
index 0000000..99f98db
--- /dev/null
+++ b/lib/serializer-2.7.1.jar
Binary files differ
diff --git a/lib/xalan-2.7.1.jar b/lib/xalan-2.7.1.jar
new file mode 100644
index 0000000..458fa73
--- /dev/null
+++ b/lib/xalan-2.7.1.jar
Binary files differ
diff --git a/lib/xercesImpl-2.11.0.jar b/lib/xercesImpl-2.11.0.jar
new file mode 100644
index 0000000..0aaa990
--- /dev/null
+++ b/lib/xercesImpl-2.11.0.jar
Binary files differ
diff --git a/lib/xml-apis-1.4.01.jar b/lib/xml-apis-1.4.01.jar
new file mode 100644
index 0000000..4673346
--- /dev/null
+++ b/lib/xml-apis-1.4.01.jar
Binary files differ
diff --git a/test/htmlunit/JCatalogTest.java b/test/htmlunit/JCatalogTest.java
new file mode 100644
index 0000000..a1c8f40
--- /dev/null
+++ b/test/htmlunit/JCatalogTest.java
@@ -0,0 +1,101 @@
+package htmlunit;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.xml.sax.SAXException;
+
+import com.gargoylesoftware.htmlunit.BrowserVersion;
+import com.gargoylesoftware.htmlunit.BrowserVersionFeatures;
+import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
+import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
+import com.gargoylesoftware.htmlunit.html.HtmlForm;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlPasswordInput;
+import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
+import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
+
+public class JCatalogTest extends TestCase
+{
+ public void testWelcomePage() throws Exception
+ {
+ HtmlPage page = gotoHomePage();
+ assertEquals("JCatalog Application", page.getTitleText());
+
+ List<HtmlForm> forms = (List<HtmlForm>) page.getForms();
+ assertEquals(1, forms.size());
+ assertEquals("navcontainer", forms.get(0).getId());
+ }
+
+ public void testLinkToLoginPage() throws Exception
+ {
+ HtmlPage response = navigateToLoginPage();
+ assertEquals("JCatalog Login", response.getTitleText());
+ }
+
+ public void testLoginPage() throws Exception
+ {
+ HtmlPage response = login();
+ assertEquals("JCatalog Welcome", response.getTitleText());
+ }
+
+ /**
+ * Test logout link, does not work correctly.
+ *
+ * @throws Exception
+ */
+ public void testLogout() throws Exception
+ {
+ HtmlPage response = login();
+ HtmlAnchor login = response.getAnchorByText("Logout");
+ //getFirstAnchorByText("Logout");
+ response = (HtmlPage) login.click();
+ // test fails, clicking on links with href="#" seems not to work
+ // unfortunately JSF generates lots of them :-(
+ assertEquals("JCatalog Application", response.getTitleText());
+ }
+
+ private HtmlPage gotoHomePage() throws FailingHttpStatusCodeException,
+ IOException
+ {
+ WebClient webClient = new WebClient(BrowserVersion.CHROME);
+// webClient.setJavaScriptEnabled(true);
+ //webClient.setRedirectEnabled(true); // does not work :-(
+ URL url = new URL("http://localhost:8080/JCatalog/pages/home.jsf");
+ return (HtmlPage) webClient.getPage(url);
+ }
+
+ private HtmlPage navigateToLoginPage() throws MalformedURLException,
+ IOException, SAXException
+ {
+ // HtmlPage response = gotoHomePage();
+ // HtmlAnchor login = response.getFirstAnchorByText("Login");
+ // return (HtmlPage) login.click();
+ WebClient webClient = new WebClient();
+ //webClient.setRedirectEnabled(true); // does not work :-(
+ URL url = new URL("http://localhost:8080/JCatalog/pages/login.jsf");
+ return (HtmlPage) webClient.getPage(url);
+ }
+
+ private HtmlPage login() throws MalformedURLException, IOException,
+ SAXException
+ {
+ HtmlPage response = navigateToLoginPage();
+ HtmlForm form = response.getFormByName("loginForm");
+ HtmlTextInput username = (HtmlTextInput) form
+ .getInputByName("loginForm:username");
+ username.setValueAttribute("admin");
+ HtmlPasswordInput password = (HtmlPasswordInput) form
+ .getInputByName("loginForm:password");
+ password.setValueAttribute("masterkey");
+
+ HtmlSubmitInput button = (HtmlSubmitInput) form
+ .getInputByName("loginForm:submit");
+ return (HtmlPage) button.click();
+ }
+}