Search in sources :

Example 36 with Page

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"));
}
Also used : Page(com.gargoylesoftware.htmlunit.Page) WebClient(com.gargoylesoftware.htmlunit.WebClient) Test(org.junit.Test)

Example 37 with Page

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"));
}
Also used : Page(com.gargoylesoftware.htmlunit.Page) WebClient(com.gargoylesoftware.htmlunit.WebClient) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 38 with Page

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"));
}
Also used : Page(com.gargoylesoftware.htmlunit.Page) WebClient(com.gargoylesoftware.htmlunit.WebClient) Test(org.junit.Test)

Example 39 with Page

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();
        }
    }
}
Also used : Listener(org.jboss.weld.environment.servlet.Listener) Server(org.eclipse.jetty.server.Server) WeldContainer(org.jboss.weld.environment.se.WeldContainer) Page(com.gargoylesoftware.htmlunit.Page) ContainerInitialized(org.jboss.weld.environment.se.events.ContainerInitialized) WebClient(com.gargoylesoftware.htmlunit.WebClient) Weld(org.jboss.weld.environment.se.Weld) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler) Test(org.junit.Test)

Example 40 with Page

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());
}
Also used : Page(com.gargoylesoftware.htmlunit.Page) WebClient(com.gargoylesoftware.htmlunit.WebClient) Test(org.junit.Test)

Aggregations

Page (com.gargoylesoftware.htmlunit.Page)62 Test (org.junit.Test)39 WebClient (com.gargoylesoftware.htmlunit.WebClient)33 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)15 PublicAtsApi (com.axway.ats.common.PublicAtsApi)9 HtmlForm (com.gargoylesoftware.htmlunit.html.HtmlForm)5 File (java.io.File)5 IOException (java.io.IOException)5 URL (java.net.URL)5 JenkinsRule (org.jvnet.hudson.test.JenkinsRule)5 VerificationException (com.axway.ats.uiengine.exceptions.VerificationException)4 ConfirmHandler (com.gargoylesoftware.htmlunit.ConfirmHandler)4 Map (java.util.Map)4 JSONObject (net.sf.json.JSONObject)4 RsaJsonWebKey (org.jose4j.jwk.RsaJsonWebKey)4 JsonWebSignature (org.jose4j.jws.JsonWebSignature)4 JwtClaims (org.jose4j.jwt.JwtClaims)4 JwtConsumer (org.jose4j.jwt.consumer.JwtConsumer)4 JwtConsumerBuilder (org.jose4j.jwt.consumer.JwtConsumerBuilder)4 JsonWebStructure (org.jose4j.jwx.JsonWebStructure)4