Skip to content

Instantly share code, notes, and snippets.

@mkouba
Created November 26, 2012 13:28
Show Gist options
  • Save mkouba/4148202 to your computer and use it in GitHub Desktop.
Save mkouba/4148202 to your computer and use it in GitHub Desktop.
WELD-1247
@WarpTest
@Category(Integration.class)
@RunWith(Arquillian.class)
public class Weld1247Test {
@Deployment
public static WebArchive deployment() {
return ShrinkWrap.create(WebArchive.class, "test.war")
.addClass(Bean.class)
.addAsWebResource(Weld1247Test.class.getPackage(), "index.xhtml", "index.xhtml")
.addAsWebInfResource(Weld1247Test.class.getPackage(), "web.xml", "web.xml")
.addAsWebInfResource(Weld1247Test.class.getPackage(), "faces-config.xml", "faces-config.xml")
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
}
@Test
@RunAsClient
public void testPreRenderViewExecutedExactlyOnce(@ArquillianResource URL url) throws Exception {
final WebClient client = new WebClient();
Warp.execute(new ClientAction() {
@Override
public void action() {
try {
client.getPage(url + "/index.faces");
} catch (Exception e) {
fail(e.getMessage());
}
}
}).verify(new BeanInvocationAssertion());
}
public static class BeanInvocationAssertion extends ServerAssertion {
private static final long serialVersionUID = 1L;
@AfterServlet
public void testInvocationCount() {
assertEquals(1, Bean.invocationCount);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment