-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMyIntegrationTest.java
More file actions
59 lines (47 loc) · 1.82 KB
/
Copy pathMyIntegrationTest.java
File metadata and controls
59 lines (47 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package de.thi.enterprisejava;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.formatter.Formatters;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import java.io.File;
import java.net.URL;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
/**
* Wildfly must be running!
*
* The test uses htmlUnit by default.
* You can change the webdriver (browser) by amending the arquillian.xml or
* define a system property e. g.
* {@code -Darq.extension.webdriver.browserCapabilities=firefox}
*/
@RunWith(Arquillian.class)
public class MyIntegrationTest {
@Deployment(testable = false)
public static WebArchive createDeployment() {
WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "test.war")
.addAsWebResource(new File("src/main/webapp/index.xhtml"))
.addAsWebInfResource(new File("src/main/webapp/WEB-INF/faces-config.xml"));
System.out.println(webArchive.toString(Formatters.VERBOSE));
return webArchive;
}
@Drone
WebDriver browser;
@ArquillianResource
URL deploymentUrl;
@Test
public void thatHelloWorldIsRendered() throws Exception {
browser.get(deploymentUrl.toExternalForm() + "index.xhtml");
// Log the complete page source
System.out.println(browser.getPageSource());
assertThat(browser.getTitle(), is("Welcome"));
assertThat(browser.findElement(By.id("welcome")).getText(), is("Hello World"));
}
}