This page (revision-21) was last changed on 26-Jun-2012 13:47 by Dieter Käppel

This page was created on 27-Apr-2012 07:09 by Dieter Käppel

Only authorized users are allowed to rename pages.

Only authorized users are allowed to delete pages.

Page revision history

Version Date Modified Size Author Changes ... Change note
21 26-Jun-2012 13:47 5 KB Dieter Käppel to previous

Page References

Incoming links Outgoing links

Version management

Difference between version and

At line 44 added 39 lines
!Integrations-Test
Das [HttpUnitProtocol] kann auch als Integrationstest eingesetzt werden, also nicht auf dem Quellverzeichnis /src/main/webapp/ sondern unter /target/<name>/. Dies ist sinnvoll, wenn Ressourcen gefiltert oder generiert werden.
Zunächst wird das Output-Directory in das Build-Verzeichnis gelegt, sodass das exploded WAR-Verzeichnis komplett ist:
{{{
<build>
<finalName>name</finalName>
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
...
</build>
}}}
Der Test kann dann so aussehen:
{{{
public class ITCheck {
@BeforeClass
public static void beforeClass() {
HttpUnitProtocol protocol = new HttpUnitProtocol("/name");
protocol.setWebXmlFile("target/name/WEB-INF/web.xml");
ProtocolFactory.register(protocol);
}
@Test
public void test() {
}
@Test
public void testLocalhost() throws Exception {
HtmlClient client = new HtmlClient(new UrlClient());
URL url = new URL("unit://localhost/");
Page page = client.begin(url, null, false);
Element error = page.getElement("/HTML/BODY/H2[1]");
Assert.assertNull(error);
}
}
}}}