use of com.gargoylesoftware.htmlunit.Page in project core by weld.
the class SimpleAsyncListenerTest method testOnCompleteCalledSuccesfully.
@Test
public void testOnCompleteCalledSuccesfully() throws Exception {
WebClient webClient = new WebClient();
webClient.getPage(getPath(AsyncServlet.TEST_COMPLETE));
Page results = webClient.getPage(contextPath + "Status");
assertTrue(results.getWebResponse().getContentAsString().contains("onComplete: true"));
}
use of com.gargoylesoftware.htmlunit.Page in project core by weld.
the class SimpleAsyncListenerTest method testOnErrorCalledSuccesfully.
@Test
// enable when WELD-1774 is fixed
@Ignore
public void testOnErrorCalledSuccesfully() throws Exception {
WebClient webClient = new WebClient();
webClient.setThrowExceptionOnFailingStatusCode(false);
webClient.getPage(getPath(AsyncServlet.TEST_ERROR));
Page results = webClient.getPage(contextPath + "Status");
assertTrue(results.getWebResponse().getContentAsString(), results.getWebResponse().getContentAsString().contains("onError: true"));
}
use of com.gargoylesoftware.htmlunit.Page in project core by weld.
the class SimpleAsyncListenerTest method testOnStartAsyncCalledSuccesfully.
@Test
public void testOnStartAsyncCalledSuccesfully() throws Exception {
WebClient webClient = new WebClient();
webClient.getPage(getPath(AsyncServlet.TEST_LOOP));
Page results = webClient.getPage(contextPath + "Status");
assertTrue(results.getWebResponse().getContentAsString().contains("onComplete: true"));
assertTrue(results.getWebResponse().getContentAsString().contains("onStartAsync: true"));
}
use of com.gargoylesoftware.htmlunit.Page in project core by weld.
the class BootstrapNotNeededTest method testBootstrapNotNeeded.
@Test
public void testBootstrapNotNeeded() throws Exception {
String id = UUID.randomUUID().toString();
// First boostrap Weld SE
try (WeldContainer container = new Weld(id).initialize()) {
TestBean testBean = container.instance().select(TestBean.class).get();
assertNotNull(testBean);
// @Initialized(ApplicationScoped.class) ContainerInitialized
List<Object> initEvents = testBean.getInitEvents();
assertEquals(1, initEvents.size());
Object event = initEvents.get(0);
assertTrue(event instanceof ContainerInitialized);
assertEquals(id, ((ContainerInitialized) event).getContainerId());
// Test CDIProvider
CDI<Object> cdi = CDI.current();
assertTrue(cdi instanceof WeldContainer);
// Then start Jetty
Server server = new Server(InetSocketAddress.createUnresolved("localhost", 8080));
try {
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
server.setHandler(context);
context.addServlet(TestServlet.class, "/test");
context.setAttribute(WeldServletLifecycle.BEAN_MANAGER_ATTRIBUTE_NAME, container.getBeanManager());
context.addEventListener(new Listener());
server.start();
// @Initialized(ApplicationScoped.class) ServletContext not fired
assertEquals(1, initEvents.size());
WebClient webClient = new WebClient();
webClient.setThrowExceptionOnFailingStatusCode(true);
Page page = webClient.getPage("http://localhost:8080/test");
assertEquals(testBean.getId(), page.getWebResponse().getContentAsString().trim());
} finally {
server.stop();
}
}
}
use of com.gargoylesoftware.htmlunit.Page in project core by weld.
the class CrossContextForwardTest method testCrossContextForward.
@Test
public void testCrossContextForward(@ArquillianResource @OperateOnDeployment(FIRST) URL firstContext) throws IOException {
Page page = new WebClient().getPage(firstContext + "forwarding");
assertEquals(200, page.getWebResponse().getStatusCode());
assertEquals("<h1>Hello World</h1>", page.getWebResponse().getContentAsString());
}
Aggregations