private void verifyNonexistentConversationExceptionThrown(Page page) { if(page instanceof TextPage) { TextPage textPage = (TextPage) page; assertTrue(textPage.getContent().contains("NonexistentConversationException thrown properly")); assertTrue(textPage.getContent().contains("Conversation.isTransient: true")); assertTrue(textPage.getContent().contains("Cloud: " + Cloud.NAME)); } else { fail("Unexpected response type: "+page.getClass().getName()); } } }
@Test @SpecAssertion(section = PROCESS_INJECTION_TARGET_EE, id = "ec") public void testWrappedInjectionTargetUsedForServletListener() throws Exception { TextPage page = invokeContextPath("test?type=listener", TextPage.class); assertTrue(page.getContent().contains(Sheep.class.getName())); assertTrue(page.getContent().contains("true")); }
@Test @SpecAssertion(section = OBSERVER_ORDERING, id = "b") public void testContextLifecycleEventOrdering() throws IOException { WebClient client = new WebClient(); TextPage page = client.getPage(contextPath); Assert.assertTrue(page.getContent().toString().contains("Initialized observer sequence: " + seq)); TextPage page2 = client.getPage(contextPath); Assert.assertTrue(page2.getContent().toString().contains("Initialized observer sequence: " + seq + seq)); Assert.assertTrue(page2.getContent().toString().contains("Destroyed observer sequence: " + seq)); }
@Test @SpecAssertion(section = CONVERSATION_CONTEXT_EE, id = "aa") public void testTransientConversation() throws Exception { WebClient client = new WebClient(); TextPage page = client.getPage(getPath("/display", null)); assertTrue(page.getContent().contains("message: Hello")); assertTrue(page.getContent().contains("cid: [null]")); assertTrue(page.getContent().contains("transient: true")); }
@Test @SpecAssertion(section = ACTIVATING_REQUEST_CONTEXT, id = "db") public void requestContextCannotBeActivatedTwice() throws Exception { WebClient webClient = new WebClient(); TextPage results = webClient.getPage(contextPath + "test"); assertTrue(results.getContent().contains("Activated: false")); assertTrue(results.getContent().contains("Active: true")); }
@Test @SpecAssertion(section = APPLICATION_CONTEXT_EE, id = "ga") public void testInitializedApplicationScopedEventObserved() throws IOException { WebClient client = new WebClient(); TextPage page1 = client.getPage(context + "/" + TEST1_ARCHIVE_NAME + "/ping"); TextPage page2 = client.getPage(context + "/" + TEST2_ARCHIVE_NAME + "/ping"); Assert.assertTrue(page1.getContent().toString().contains(ObserverNames.OBSERVER2_NAME)); Assert.assertTrue(page2.getContent().toString().contains(ObserverNames.OBSERVER3_NAME)); } }
@Test @SpecAssertion(section = PROCESS_INJECTION_TARGET_EE, id = "ee") public void testWrappedInjectionTargetUsedForTagLibraryListener() throws Exception { TextPage page = invokeContextPath("test?type=taglibrary", TextPage.class); assertTrue(page.getContent().contains("true")); }
@Test @SpecAssertion(section = PROCESS_INJECTION_TARGET_EE, id = "ef") public void testWrappedInjectionTargetUsedForEjbInterceptor() throws Exception { TextPage page = invokeContextPath("test?type=interceptor", TextPage.class); assertTrue(page.getContent().contains("true")); }
@Test @SpecAssertion(section = PROCESS_INJECTION_TARGET_EE, id = "ei") public void testWrappedInjectionTargetIsUsedForFilter() throws Exception { TextPage page = invokeContextPath("test?type=filter", TextPage.class); assertTrue(page.getContent().contains("true")); }
@Test(groups = INTEGRATION) @SpecAssertion(section = REQUEST_CONTEXT, id = "db") @SpecAssertion(section = REQUEST_CONTEXT, id = "eb") public void testEagerSingletonPostConstructCallback() throws Exception { WebClient client = new WebClient(); TextPage page = client.getPage(contextPath + "eager"); // Context was active assertTrue(page.getContent().contains("Active:true")); // Only singleton callback, current request not destroyed yet assertTrue(page.getContent().contains("Destroyed requests:1")); }
@Test(groups = {INTEGRATION, ASYNC_SERVLET}) @SpecAssertion(section = APPLICATION_CONTEXT_EE, id = "ae") public void testApplicationContextActiveOnStartAsync() throws Exception { WebClient webClient = new WebClient(); webClient.getPage(getPath(AsyncServlet.TEST_LOOP)); TextPage results = webClient.getPage(contextPath + "Status"); assertTrue(results.getContent().contains("onStartAsync: true")); assertTrue(results.getContent().contains("onComplete: true")); }
private void assertComponentInstancesNotEqual(String mode) throws Exception { WebClient webClient = new WebClient(); webClient.setThrowExceptionOnFailingStatusCode(true); TextPage page = webClient.getPage(contextPath + "test?mode=" + mode); String[] ids = page.getContent().split(":"); System.out.println(Arrays.toString(ids)); assertEquals(ids.length, 2); assertNotEquals(ids[0], ids[1]); }
@Test(groups = { JAVAEE_FULL, JAX_WS }) @SpecAssertion(section = FIELDS_INITIALIZER_METHODS_EE, id = "br") public void testFilterInitCalledAfterResourceInjection() throws Exception { WebClient webClient = new WebClient(); webClient.setThrowExceptionOnFailingStatusCode(true); TextPage page = webClient.getPage(contextPath + "TestFilter2?test=wsresource"); assertTrue(page.getContent().contains("Filter init: true")); } }
@Test(groups = {INTEGRATION, ASYNC_SERVLET}) @SpecAssertion(section = APPLICATION_CONTEXT_EE, id = "ae") public void testApplicationContextActiveOnTimeout() throws Exception { WebClient webClient = new WebClient(); webClient.setThrowExceptionOnFailingStatusCode(false); webClient.getPage(getPath(AsyncServlet.TEST_TIMEOUT)); TextPage results = webClient.getPage(contextPath + "Status"); assertTrue(results.getContent().contains("onTimeout: true")); }
@Test(groups = {INTEGRATION, ASYNC_SERVLET}) @SpecAssertion(section = REQUEST_CONTEXT_EE, id = "ad") public void testRequestContextActiveOnError() throws Exception { WebClient webClient = new WebClient(); webClient.setThrowExceptionOnFailingStatusCode(false); webClient.getPage(getPath(AsyncServlet.TEST_ERROR)); TextPage results = webClient.getPage(contextPath + "Status"); assertTrue(results.getContent().contains("onError: true")); }
@Test @SpecAssertion(section = REQUEST_CONTEXT_EE, id = "je") public void testEventsFired() throws Exception { WebClient client = new WebClient(); TextPage page = client.getPage(contextPath + "info"); String content = page.getContent(); // Test request and timeout request checkContent(content, "(Initialized:)(\\w+)", "true"); // Timeout request only checkContent(content, "(Destroyed:)(\\w+)", "true"); }
public void testArbitraryWebMethodName() throws Exception { WebClient wc = new WebClient(); TextPage p = wc.getPage(new URL(url, "arbitraryWebMethodName")); assertEquals("I'm index", p.getContent()); p = wc.getPage(new URL(url, "arbitraryWebMethodName/theNeedful")); assertEquals("DTN", p.getContent()); }
/** * Makes sure @WebMethod(name="") has the intended effect of occupying the root of the object in the URL space. */ public void testIndexDispatchByName() throws Exception { WebClient wc = new WebClient(); TextPage p = wc.getPage(new URL(url, "indexDispatchByName")); assertEquals("Hello world", p.getContent()); }
public void testOverloads() throws Exception { TextPage p = new WebClient().getPage(new URL(url, "overloaded/x")); assertEquals("doX(StaplerRequest)", p.getContent()); } public final Object overloaded = new Overloaded();
public void testInheritance() throws Exception { WebClient wc = new WebClient(); // the request should get to the overriding method and it should still see all the annotations in the base type TextPage p = wc.getPage(new URL(url, "inheritance/foo?q=abc")); assertEquals("abc", p.getContent()); // doBar is a web method for 'foo', so bar endpoint shouldn't respond try { wc.getPage(new URL(url, "inheritance/bar")); fail(); } catch (FailingHttpStatusCodeException e) { assertEquals(404,e.getStatusCode()); } }