|
| 1 | +/** Copyright Payara Services Limited **/ |
| 2 | +package org.javaee8.jsf.hello.world; |
| 3 | + |
| 4 | +import static org.jboss.shrinkwrap.api.ShrinkWrap.create; |
| 5 | +import static org.junit.Assert.assertTrue; |
| 6 | + |
| 7 | +import java.io.File; |
| 8 | +import java.io.IOException; |
| 9 | +import java.net.URL; |
| 10 | + |
| 11 | +import org.javaee8.jsf.hello.world.ApplicationInit; |
| 12 | +import org.jboss.arquillian.container.test.api.Deployment; |
| 13 | +import org.jboss.arquillian.container.test.api.RunAsClient; |
| 14 | +import org.jboss.arquillian.junit.Arquillian; |
| 15 | +import org.jboss.arquillian.test.api.ArquillianResource; |
| 16 | +import org.jboss.shrinkwrap.api.spec.WebArchive; |
| 17 | +import org.junit.After; |
| 18 | +import org.junit.Before; |
| 19 | +import org.junit.Test; |
| 20 | +import org.junit.runner.RunWith; |
| 21 | + |
| 22 | +import com.gargoylesoftware.htmlunit.WebClient; |
| 23 | +import com.gargoylesoftware.htmlunit.html.HtmlPage; |
| 24 | + |
| 25 | +/** |
| 26 | + * |
| 27 | + * @author Arjan Tijms |
| 28 | + * |
| 29 | + */ |
| 30 | +@RunWith(Arquillian.class) |
| 31 | +public class JSFHelloWorldTest { |
| 32 | + |
| 33 | + @ArquillianResource |
| 34 | + private URL base; |
| 35 | + |
| 36 | + private WebClient webClient; |
| 37 | + |
| 38 | + @Before |
| 39 | + public void setup() { |
| 40 | + webClient = new WebClient(); |
| 41 | + } |
| 42 | + |
| 43 | + @After |
| 44 | + public void teardown() { |
| 45 | + webClient.close(); |
| 46 | + } |
| 47 | + |
| 48 | + @Deployment |
| 49 | + public static WebArchive deploy() { |
| 50 | + WebArchive war = |
| 51 | + create(WebArchive.class) |
| 52 | + .addClasses(ApplicationInit.class, HelloBacking.class) |
| 53 | + .addAsWebResource(new File("src/main/webapp/hello.xhtml")) |
| 54 | + ; |
| 55 | + |
| 56 | + System.out.println("War to be deployed contains: \n" + war.toString(true)); |
| 57 | + |
| 58 | + return war; |
| 59 | + } |
| 60 | + |
| 61 | + |
| 62 | + @Test |
| 63 | + @RunAsClient |
| 64 | + public void testHelloWorld() throws IOException { |
| 65 | + HtmlPage page = webClient.getPage(base + "hello.xhtml"); |
| 66 | + |
| 67 | + assertTrue(page.asXml().contains("Hello world, from JSF!")); |
| 68 | + } |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | +} |
0 commit comments