Refine search
@RunWith(Arquillian.class) @RunAsClient public abstract class AbstractClientArquillianTest {
@Test @RunAsClient public void testInteraction(@ArquillianResource URL deploymentURL) throws Exception { URL url = renderURL(deploymentURL, ActionErrorPortlet.class); driver.get(url.toString()); WebElement link = driver.findElement(By.id("url")); url = new URL(link.getAttribute("href")); HttpURLConnection conn = (HttpURLConnection)url.openConnection(); conn.connect(); Assert.assertEquals(500, conn.getResponseCode()); String s = new String(IOTools.getBytes(conn.getErrorStream())); Assert.assertTrue(s + " does not contain the _ActionError_ string", s.contains("_ActionError_")); } }
@Test @RunAsClient public void test() throws Exception { URL applicationURL = applicationURL(); driver.get(applicationURL.toString()); WebElement elt = driver.findElement(By.id("Foo")); URL url = new URL(applicationURL.getProtocol(), applicationURL.getHost(), applicationURL.getPort(), elt.getText()); HttpGet get = new HttpGet(url.toURI()); HttpResponse response = HttpClientBuilder.create().build().execute(get); Header[] cacheControl = response.getHeaders("Cache-Control"); assertEquals(1, cacheControl.length); assertEquals("max-age=1000", cacheControl[0].getValue()); } }
@Test @RunAsClient public void testWeather7() throws Exception { URL url = getApplicationURL("weather7"); driver.get(url.toString()); WebElement link = driver.findElement(By.tagName("link")); String href = link.getAttribute("href"); url = new URL(href); HttpURLConnection conn = (HttpURLConnection)url.openConnection(); assertEquals(200, conn.getResponseCode()); }
/** * Tests that a {@link ServletRequestListener} is called symmetrically with respect to the calling thread. * See https://issues.apache.org/bugzilla/show_bug.cgi?id=57314 for details * * @author Jozef Hartinger * */ @RunAsClient @RunWith(Arquillian.class) public class ListenerSymmetryTest { @ArquillianResource private URL contextPath; @Deployment public static WebArchive createTestArchive() { return baseDeployment().addClasses(SimpleServlet.class, SimpleListener.class); } @Test public void testListenerCalledSymmetrically() throws FailingHttpStatusCodeException, MalformedURLException, IOException { WebClient webClient = new WebClient(); assertEquals("Async OK", webClient.getPage(contextPath + "async").getWebResponse().getContentAsString().trim()); assertEquals("OK", webClient.getPage(contextPath + "result").getWebResponse().getContentAsString().trim()); } }
@Test @RunAsClient public void test() throws Exception { driver.get(applicationURL().toString()); WebElement script = driver.findElement(By.tagName("script")); assertEquals("http://localhost:" + getContainerPort() + "/juzu/assets/juzu/webjar/assets/jquery/1.10.2/jquery.js", script.getAttribute("src")); } }
@Test @RunAsClient @InSequence(3) public void testInteraction() throws Exception { WebElement link = driver.findElement(By.id("url")); URL url = new URL(link.getAttribute("href")); HttpURLConnection conn = (HttpURLConnection)url.openConnection(); conn.connect(); Assert.assertEquals(200, conn.getResponseCode()); String s = new String(IOTools.getBytes(conn.getInputStream())); Assert.assertEquals("SERVE_RESOURCE", s); Map<String, String> headers = responseHeaders(conn); Assert.assertEquals("text/plain;charset=utf-8", headers.get("Content-Type")); }
@Test @InSequence(0) @RunAsClient public void login(@ArquillianResource URL deploymentURL) throws Exception { URL url = deploymentURL.toURI().resolve("embed/BookingPortlet").toURL(); driver.get(url.toString()); WebElement loginForm = driver.findElement(By.className("formLogin")); assertNotNull(loginForm); loginForm.findElement(By.name("username")).sendKeys("demo"); loginForm.findElement(By.name("password")).sendKeys("demo"); loginForm.submit(); WebElement messageBoard = driver.findElement(By.className("fSuccess")); assertNotNull(messageBoard); assertEquals("Welcome, Demo User", messageBoard.getText()); }
@Test @InSequence(3) @RunAsClient public void refreshAfterLogout(@ArquillianResource URL deploymentURL) throws Exception { URL url = deploymentURL.toURI().resolve("embed/BookingPortlet").toURL(); driver.get(url.toString()); WebElement login = driver.findElement(By.className("login")); assertNotNull(login); assertTrue(login.getText().contains("(try with demo/demo)")); assertNotNull(login.findElement(By.tagName("form"))); } }
@Test @RunAsClient public void testLoginSuccess() throws Exception { driver.get(deploymentURL.toString()); WebElement username = driver.findElement(By.id("uname")); username.sendKeys("root"); WebElement password = driver.findElement(By.id("passwd")); password.sendKeys("secret"); WebElement submit = driver.findElement(By.id("submit")); submit.click(); assertNull(exception); waitForPresent(driver, "root logged"); }
@Test @RunAsClient public void testWeather1() throws Exception { URL url = getApplicationURL("weather1"); // <1> Retrieve the application driver.get(url.toString()); WebElement body = driver.findElement(By.tagName("body")); assertTrue(body.getText().contains("The weather application")); // <2> Check markup is correct } // end::testWeather1[]
@Test @RunAsClient @InSequence(1) public void display(@ArquillianResource URL deploymentURL) throws Exception { URL url = renderURL(deploymentURL, EventSetParameterPortlet.class); driver.get(url.toString()); }
@Test @RunAsClient public void testWeather5() throws Exception { URL url = getApplicationURL("weather5"); driver.get(url.toString()); WebElement locationElt = driver. findElement(By.cssSelector("input[name='location']")); locationElt.sendKeys("bastia"); locationElt.submit(); WebElement body = driver.findElement(By.tagName("body")); assertTrue(body.getText().contains("temperature in bastia")); assertTrue(body.getText().contains("10 degrees")); }
@Test @RunAsClient public void testWeather4() throws Exception { URL url = getApplicationURL("weather4"); driver.get(url.toString()); WebElement body = driver.findElement(By.tagName("body")); assertTrue(body.getText().contains("temperature in marseille")); assertTrue("Was expecting to find <10 degrees> in " + body.getText(), body.getText().contains("10 degrees")); WebElement parisElt = driver. findElement(By.linkText("Paris")); parisElt.click(); body = driver.findElement(By.tagName("body")); assertTrue(body.getText().contains("temperature in paris")); assertTrue(body.getText().contains("10 degrees")); }
@Test @RunAsClient public void testRpc(@ArquillianResource URL url) throws Exception { driver.get(url.toExternalForm()); WebElement getButton = driver.findElement(By.id("getButton")); Graphene.waitModel(driver).until().element(getButton).is().enabled(); getButton.click(); final WebElement response = driver.findElement(By.id("response")); Graphene.waitModel(driver).until(new Predicate<WebDriver>() { public boolean apply(WebDriver input) { return response.getText().length() > 0; } }); } }
@Test @RunAsClient @InSequence(3) public void interaction() throws Exception { WebElement link = driver.findElement(By.id("submit")); link.click(); }
@Test @InSequence(4) @RunAsClient public void showHotel() throws Exception { WebElement bookForm = driver.findElement(By.tagName("form")); assertNotNull(bookForm); bookForm.findElement(By.className("buttons")).findElement(By.name("confirm")).click(); }
@Test @InSequence(5) @RunAsClient public void checkBooking() throws Exception { WebElement success = driver.findElement(By.className("fSuccess")); assertNotNull(success); assertNotNull("Thank you, demo, your confimation number for Marriott Courtyard is 0", success.findElement(By.tagName("strong")).getText()); } }
@Test @RunAsClient public void testDeployDroolsFails() { try { deployer.deploy("deployment"); Assert.fail("exception expected"); }catch (Exception e) { // expected } }
@Test @RunAsClient public void testInteraction(@ArquillianResource URL deploymentURL) throws Exception { URL url = renderURL(deploymentURL, ResourceErrorPortlet.class); driver.get(url.toString()); WebElement link = driver.findElement(By.id("url")); url = new URL(link.getAttribute("href")); HttpURLConnection conn = (HttpURLConnection)url.openConnection(); conn.connect(); Assert.assertEquals(500, conn.getResponseCode()); String s = new String(IOTools.getBytes(conn.getErrorStream())); Assert.assertTrue(s + " does not contain the _ResourceError_ string", s.contains("_ResourceError_")); } }