Skip to content
This repository was archived by the owner on Apr 7, 2022. It is now read-only.

Commit f2bcd51

Browse files
author
Jim Weaver
committed
Removed xercesImpl.jar, updated site, added tests to sample tree
1 parent 71afb9b commit f2bcd51

7 files changed

Lines changed: 130 additions & 6 deletions

File tree

jWebUnit/doc/css/jwebunit.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@ h2 {color: #3333ff;
1212
text-align: left;}
1313

1414
.default {font-family: Helvetica, Arial, sans-serif; font-size: 10pt;}
15+
.blueText {font-family: Helvetica, Arial, sans-serif; font-size: 10pt; color: #3333ff;}
16+
.smallCode {font-family: sans-serif; font-size: 8pt; background-color: #CCCCCC;}
1517

jWebUnit/doc/index.html

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,75 @@ <h2>What is jWebUnit?</h2>
3333
<br>
3434
<br>
3535
<h2>What does jWebUnit provide?</h2>
36-
jWebUnit provides a high-level API for navigating a web application, and a set
36+
jWebUnit provides a high-level API for navigating a web application combined with a set
3737
of assertions to verify the application's correctness. This includes navigation
3838
via links, form entry and submission, validation of table contents, and other
39-
typical business web application features. This code is using HttpUnit behind
39+
typical business web application features. This code utilizes HttpUnit behind
4040
the scenes. The simple navigation methods and ready-to-use assertions allow for
4141
more rapid test creation than using only JUnit and HttpUnit.
42+
<p>
43+
The following sample testcases illustrate the conciseness of jWebUnit versus HttpUnit
44+
and JUnit alone. The tests perform a google search
45+
for the HttpUnit home page, navigate to that page from Google, and validate that
46+
there is a link to the user manual on the HttpUnit home page. The code in the
47+
first column is pure HttpUnit / JUnit, while the second column uses the jWebUnit framework.
48+
<p>
4249
<br>
50+
<table class="default" cellspacing="2" border="0">
51+
<tr class="blueText"><td>JUnit/HttpUnit Test</td><td>jWebUnit Test</td></tr>
52+
<tr>
53+
<td valign="top" class="smallCode" NOWRAP>
54+
package net.sourceforge.jwebunit.sample;<br>
55+
<br>
56+
import junit.framework.TestCase;<br>
57+
import com.meterware.httpunit.WebResponse;<br>
58+
import com.meterware.httpunit.WebConversation;<br>
59+
import com.meterware.httpunit.WebForm;<br>
60+
import com.meterware.httpunit.WebRequest;<br>
61+
<br>
62+
public class SearchExample extends TestCase {<br>
63+
<br>
64+
&nbsp;&nbsp;&nbsp;public void testSearch() throws Exception {<br>
65+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WebConversation wc = new WebConversation();<br>
66+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WebResponse resp = wc.getResponse( "http://www.google.com");<br>
67+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WebForm form = resp.getForms()[0];<br>
68+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;form.setParameter("q", "HttpUnit");<br>
69+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WebRequest req = form.getRequest("btnG");<br>
70+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;resp = wc.getResponse(req);<br>
71+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;assertNotNull(resp.getLinkWith("HttpUnit"));<br>
72+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;resp = resp.getLinkWith("HttpUnit").click();<br>
73+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;assertEquals(resp.getTitle(), "HttpUnit");<br>
74+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;assertNotNull(resp.getLinkWith("User's Manual"));<br>
75+
&nbsp;&nbsp;&nbsp;}<br>
76+
}<br>
77+
</td>
78+
<td valign="top" class="smallCode" NOWRAP>
79+
package net.sourceforge.jwebunit.sample;<br>
80+
<br>
81+
import net.sourceforge.jwebunit.WebTestCase;<br>
82+
<br>
83+
public class JWebUnitSearchExample extends WebTestCase {<br>
84+
<br>
85+
&nbsp;&nbsp;&nbsp;public JWebUnitSearchExample(String name) {<br>
86+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;super(name);<br>
87+
&nbsp;&nbsp;&nbsp;}<br>
88+
<br>
89+
&nbsp;&nbsp;&nbsp;public void setUp() {<br>
90+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;getTestContext().setBaseUrl("http://www.google.com");<br>
91+
&nbsp;&nbsp;&nbsp;}<br>
92+
<br>
93+
&nbsp;&nbsp;&nbsp;public void testSearch() {<br>
94+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;beginAt("/");<br>
95+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setFormElement("q", "httpunit");<br>
96+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;submit("btnG");<br>
97+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;clickLinkWithText("HttpUnit");<br>
98+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;assertTitleEquals("HttpUnit");<br>
99+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;assertLinkPresentWithText("User's Manual");<br>
100+
&nbsp;&nbsp;&nbsp;}<br>
101+
}<br>
102+
</td>
103+
</tr>
104+
</table>
43105
<!-- End Main -->
44106
</td>
45107
</tr>

jWebUnit/doc/installation.html

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,13 @@
2828
</td>
2929
<td valign="top">
3030
<!-- Begin Main -->
31-
First download jWebUnit from the <a href="http://sourceforge.net/projects/jwebunit/files">files area</a>.
32-
Expand the zip onto your machine. There is a jWebUnit jar in the root directory. You can use this
33-
jar to run jWebUnit, but only if you already have all of jWebUnit's dependencies in your target project.
34-
jWebUnit includes jars for the projects it is dependent on in its lib directory.
31+
First download jWebUnit from the <a href="http://sourceforge.net/projects/jwebunit/files">files area</a>
32+
and expand to a local directory.<p>
33+
Next, copy the jars needed below to the project you wish to test, or include them in that
34+
project's classpath from where you expanded them too. There is a jWebUnit jar in the root directory. You can use this
35+
jar alone to run jWebUnit, but only if you already have the jars for jWebUnit's dependencies in your target project.
36+
jWebUnit includes jars for the projects it is dependent on in its lib directory, so if your project
37+
is not already using them you can get them there. The dependencies are as follows:
3538
<p>
3639
<h2>Dependencies</h2>
3740
<table class="default" cellspacing="2" border="1">
@@ -40,6 +43,7 @@ <h2>Dependencies</h2>
4043
<tr><td><a href="http://www.mozilla.org/rhino/">Rhino</a></td><td>js.jar</td><td>Java javascript implementation used by httpunit. Only needed if javascript in target application must be tested.</td></tr>
4144
<tr><td><a href="http://sourceforge.net/projects/jtidy">jTidy</a></td><td>Tidy.jar</td><td>Java html parser and beautifier used by httpunit.</td></tr>
4245
<tr><td><a href="http://www.junit.org">JUnit 3.8.1</a></td><td>junit.jar, optional.jar</td><td>Java testing framework.</td></tr>
46+
<tr><td><a href="http://www.apache.org">Apache XML API</a></td><td>xml-apis.jar</td><td>Common XML stuff needed by Tidy/HttpUnit.</td></tr>
4347
</table>
4448
<br>
4549
<!-- End Main -->

jWebUnit/lib/xercesImpl.jar

-912 KB
Binary file not shown.

jWebUnit/lib/xml-apis.jar

-106 KB
Binary file not shown.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package net.sourceforge.jwebunit.sample;
2+
3+
import net.sourceforge.jwebunit.WebTestCase;
4+
5+
/**
6+
* Google search test with jWebUnit.
7+
*
8+
* @author Jim Weaver
9+
*/
10+
public class JWebUnitSearchExample extends WebTestCase {
11+
12+
public JWebUnitSearchExample(String name) {
13+
super(name);
14+
}
15+
16+
public void setUp() {
17+
getTestContext().setBaseUrl("http://www.google.com");
18+
}
19+
20+
public void testSearch() {
21+
beginAt("/");
22+
setFormElement("q", "httpunit");
23+
submit("btnG");
24+
clickLinkWithText("HttpUnit");
25+
assertTitleEquals("HttpUnit");
26+
assertLinkPresentWithText("User's Manual");
27+
}
28+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package net.sourceforge.jwebunit.sample;
2+
3+
import junit.framework.TestCase;
4+
import com.meterware.httpunit.WebResponse;
5+
import com.meterware.httpunit.WebConversation;
6+
import com.meterware.httpunit.WebForm;
7+
import com.meterware.httpunit.WebRequest;
8+
9+
/**
10+
* HttpUnit and JUnit search test.
11+
*
12+
* @author Jim Weaver
13+
*/
14+
public class SearchExample extends TestCase {
15+
16+
public void testSearch() throws Exception {
17+
WebConversation wc = new WebConversation();
18+
WebResponse resp = wc.getResponse( "http://www.google.com");
19+
WebForm form = resp.getForms()[0];
20+
form.setParameter("q", "HttpUnit");
21+
WebRequest req = form.getRequest("btnG");
22+
resp = wc.getResponse(req);
23+
assertNotNull(resp.getLinkWith("HttpUnit"));
24+
resp = resp.getLinkWith("HttpUnit").click();
25+
assertEquals(resp.getTitle(), "HttpUnit");
26+
assertNotNull(resp.getLinkWith("User's Manual"));
27+
}
28+
}

0 commit comments

Comments
 (0)