org.jboss.arquillian.test.api.ArquillianResource Java Examples
The following examples show how to use
org.jboss.arquillian.test.api.ArquillianResource.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PersonsIT.java From jaxrs-beanvalidation-javaee7 with Apache License 2.0 | 6 votes |
@Test @RunAsClient @InSequence(40) public void shouldReturnAValidationErrorWhenCreatingAPerson(@ArquillianResource URL baseURL) { Form form = new Form(); Client client = ClientBuilder.newBuilder() .register(JsonProcessingFeature.class) .property(JsonGenerator.PRETTY_PRINTING, true) .build(); Response response = client.target(baseURL + "r/persons/create") .request(MediaType.APPLICATION_JSON) .header("Accept-Language", "pt") .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED)); response.bufferEntity(); logResponse("shouldReturnAValidationErrorWhenCreatingAPerson", response, JsonObject.class); Assert.assertEquals(HttpServletResponse.SC_BAD_REQUEST, response.getStatus()); }
Example #2
Source File: ChannelTest.java From appengine-tck with Apache License 2.0 | 6 votes |
@Test @RunAsClient @InSequence(20) public void testTimeout(@ArquillianResource URL url) throws Exception { // 1. Create our test with a unique channel id. final String channelId = "" + System.currentTimeMillis(); // Set timeout for 1 minute. String params = String.format("/channelPage.jsp?test-channel-id=%s&timeout-minutes=%d", channelId, 1); driver.get(url + params); // 2. Verify that the server received our channel id and is using it for this tests. WebElement channel = driver.findElement(By.id("channel-id")); assertEquals(channelId, channel.getText()); // 3. Verify that the channel gets closed after the 1 minute timeout. Graphene.waitModel(driver).until().element(By.id("status")).text().equalTo("opened"); // This should put us over the 1 minute timeout. Graphene.waitModel(driver).withTimeout(90, TimeUnit.SECONDS).until().element(By.id("status")).text().equalTo("closed"); }
Example #3
Source File: SeatsResourceTest.java From packt-java-ee-7-code-samples with GNU General Public License v2.0 | 6 votes |
@Test public void testasd() { Warp.initiate(new Activity() { @Override public void perform() { final String response = target.request(MediaType.APPLICATION_JSON_TYPE).get(String.class); assertNotNull(response); } }).inspect(new Inspection() { private static final long serialVersionUID = 1L; @ArquillianResource private RestContext restContext; @AfterServlet public void testGetSeats() { assertEquals(200, restContext.getHttpResponse().getStatusCode()); assertEquals(MediaType.APPLICATION_JSON, restContext.getHttpResponse().getContentType()); assertNotNull(restContext.getHttpResponse().getEntity()); } }); }
Example #4
Source File: ServerFrontendITest.java From ldp4j with Apache License 2.0 | 6 votes |
@Test @Category({ HappyPath.class }) @OperateOnDeployment(DEPLOYMENT) public void testQuerySupport(@ArquillianResource final URL url) throws Exception { LOGGER.info("Started {}",testName.getMethodName()); HELPER.base(url); HELPER.setLegacy(false); HttpGet get = HELPER.newRequest(MyApplication.ROOT_QUERYABLE_RESOURCE_PATH,HttpGet.class); Metadata getResponse=HELPER.httpRequest(get); assertThat(getResponse.status,equalTo(HttpStatus.SC_OK)); assertThat(getResponse.body,notNullValue()); assertThat(getResponse.contentType,startsWith("text/turtle")); HttpGet get2 = HELPER.newRequest(MyApplication.ROOT_QUERYABLE_RESOURCE_PATH+"?param1=value1¶m2=value2¶m2=value3¶m3",HttpGet.class); Metadata getResponse2=HELPER.httpRequest(get2); assertThat(getResponse2.status,equalTo(HttpStatus.SC_OK)); assertThat(getResponse2.body,notNullValue()); assertThat(getResponse2.contentType,startsWith("text/turtle")); LOGGER.info("Completed {}",testName.getMethodName()); }
Example #5
Source File: PersonsIT.java From jaxrs-beanvalidation-javaee7 with Apache License 2.0 | 6 votes |
@Test @RunAsClient @InSequence(10) public void shouldReturnAllPersons(@ArquillianResource URL baseURL) { Client client = ClientBuilder.newBuilder() .register(JsonProcessingFeature.class) .property(JsonGenerator.PRETTY_PRINTING, true) .build(); Response response = client.target(baseURL + "r/persons") .request(MediaType.APPLICATION_JSON) .get(); response.bufferEntity(); logResponse("shouldReturnAllPersons", response, JsonArray.class); Assert.assertEquals(Collections.emptyList(), response.readEntity(new GenericType<Collection<Person>>() {})); }
Example #6
Source File: ServerFrontendITest.java From ldp4j with Apache License 2.0 | 6 votes |
@Test @Category({ ExceptionPath.class }) @OperateOnDeployment(DEPLOYMENT) public void testConstraintReportNotFound(@ArquillianResource final URL url) throws Exception { LOGGER.info("Started {}",testName.getMethodName()); HELPER.base(url); HELPER.setLegacy(false); HttpGet get = HELPER.newRequest(MyApplication.ROOT_PERSON_CONTAINER_PATH+"?ldp:constrainedBy=12312312321",HttpGet.class); Metadata getResponse=HELPER.httpRequest(get); assertThat(getResponse.status,equalTo(HttpStatus.SC_NOT_FOUND)); assertThat(getResponse.body,equalTo("Unknown constraint report '12312312321'")); assertThat(getResponse.contentType,startsWith("text/plain")); assertThat(getResponse.language,equalTo(Locale.ENGLISH)); }
Example #7
Source File: ServerFrontendITest.java From ldp4j with Apache License 2.0 | 6 votes |
@Test @Category({ HappyPath.class }) @OperateOnDeployment(DEPLOYMENT) public void testSupportForQueriesWithoutValuedParameters(@ArquillianResource final URL url) throws Exception { LOGGER.info("Started {}",testName.getMethodName()); Query query=queryResource(url, "ldp4j/api/"+MyApplication.ROOT_QUERYABLE_RESOURCE_PATH+"?param1¶m2"); assertThat(query.size(),equalTo(2)); assertThat(query.hasParameter("param1"),equalTo(true)); assertThat(query.getParameter("param1").cardinality(),equalTo(1)); assertThat(query.getParameter("param1").rawValues(),hasItems("")); assertThat(query.hasParameter("param2"),equalTo(true)); assertThat(query.getParameter("param2").cardinality(),equalTo(1)); assertThat(query.getParameter("param2").rawValues(),hasItems("")); LOGGER.info("Completed {}",testName.getMethodName()); }
Example #8
Source File: PersonsIT.java From jaxrs-beanvalidation-javaee7 with Apache License 2.0 | 6 votes |
@Test @RunAsClient @InSequence(20) public void shouldReturnAValidationErrorWhenGettingAPerson(@ArquillianResource URL baseURL) { Client client = ClientBuilder.newBuilder() .register(JsonProcessingFeature.class) .property(JsonGenerator.PRETTY_PRINTING, true) .build(); Response response = client.target(baseURL + "r/persons/{id}") .resolveTemplate("id", "test") .request(MediaType.APPLICATION_JSON) .header("Accept-Language", "en") .get(); response.bufferEntity(); logResponse("shouldReturnAValidationErrorWhenGettingAPerson", response, JsonObject.class); Assert.assertEquals(HttpServletResponse.SC_BAD_REQUEST, response.getStatus()); }
Example #9
Source File: ServerFrontendITest.java From ldp4j with Apache License 2.0 | 6 votes |
@Test @Category({ ExceptionPath.class }) @OperateOnDeployment(DEPLOYMENT) public void testCannotSpecifyMultipleConstraintReports(@ArquillianResource final URL url) throws Exception { LOGGER.info("Started {}",testName.getMethodName()); HELPER.base(url); HELPER.setLegacy(false); HttpGet get = HELPER.newRequest(MyApplication.ROOT_PERSON_CONTAINER_PATH+"?ldp:constrainedBy=12312312321&ldp:constrainedBy=asdasdasd",HttpGet.class); Metadata getResponse=HELPER.httpRequest(get); assertThat(getResponse.status,equalTo(HttpStatus.SC_BAD_REQUEST)); assertThat(getResponse.body,equalTo("Only one constraint report identifier is allowed (12312312321, asdasdasd)")); assertThat(getResponse.contentType,startsWith("text/plain")); assertThat(getResponse.language,equalTo(Locale.ENGLISH)); }
Example #10
Source File: PersonsIT.java From jaxrs-beanvalidation-javaee7 with Apache License 2.0 | 6 votes |
@Test @RunAsClient @InSequence(30) public void shouldReturnAnEmptyPerson(@ArquillianResource URL baseURL) { Client client = ClientBuilder.newBuilder() .register(JsonProcessingFeature.class) .property(JsonGenerator.PRETTY_PRINTING, true) .build(); Response response = client.target(baseURL + "r/persons/{id}") .resolveTemplate("id", "10") .request(MediaType.APPLICATION_JSON) .get(); response.bufferEntity(); logResponse("shouldReturnAnEmptyPerson", response, JsonObject.class); Assert.assertEquals(null, response.readEntity(Person.class)); }
Example #11
Source File: ServerFrontendITest.java From ldp4j with Apache License 2.0 | 6 votes |
@Test @Category({ HappyPath.class }) @OperateOnDeployment(DEPLOYMENT) public void testDynamicResourceHandler(@ArquillianResource final URL url) throws Exception { LOGGER.info("Started {}",testName.getMethodName()); HELPER.base(url); HELPER.setLegacy(false); while(WATCH.elapsed(TimeUnit.SECONDS)<10) { } HttpGet get = HELPER.newRequest(MyApplication.ROOT_DYNAMIC_RESOURCE_PATH,HttpGet.class); Metadata getResponse=HELPER.httpRequest(get); assertThat(getResponse.status,equalTo(OK)); assertThat(getResponse.body,notNullValue()); assertThat(getResponse.contentType,startsWith(TEXT_TURTLE)); DynamicResponseHelper helper = new DynamicResponseHelper(url,MyApplication.ROOT_DYNAMIC_RESOURCE_PATH,getResponse.body); assertThat(helper.getUpdates(),not(hasSize(0))); assertThat(helper.getResolution(),equalTo(DynamicResourceResolver.CANONICAL_BASE.resolve(MyApplication.ROOT_DYNAMIC_RESOURCE_PATH).toString())); assertThat(helper.getRoundtrip(),equalTo("OK")); }
Example #12
Source File: ArqITSessionWithCookie.java From HttpSessionReplacer with MIT License | 6 votes |
@RunAsClient @Test public void testSessionSwitched(@ArquillianResource URL baseURL) throws IOException { URL urlTest = url(baseURL, "TestServlet", "testSessionSwitched"); String originalCookie = callWebapp(urlTest); HttpURLConnection connection = (HttpURLConnection) urlTest.openConnection(); setSessionCookie(connection, originalCookie); connection.connect(); List<String> cookies = connection.getHeaderFields().get("Set-Cookie"); assertThat(connection, matchLines("Previous value of attribute: B")); assertThat(cookies, hasItem(originalCookie)); URL urlOther = url(baseURL, "SwitchServlet", "testSessionSwitched"); HttpURLConnection connectionOther = (HttpURLConnection) urlOther.openConnection(); setSessionCookie(connectionOther, originalCookie); connectionOther.connect(); List<String> switchedCookies = connectionOther.getHeaderFields().get("Set-Cookie"); assertThat(connectionOther, matchLines("Previous value of attribute: B", "New value of attribute: S")); assertThat(switchedCookies, not(hasItem(originalCookie))); }
Example #13
Source File: ServerFrontendITest.java From ldp4j with Apache License 2.0 | 6 votes |
@Test @Category({ ExceptionPath.class }) @OperateOnDeployment(DEPLOYMENT) public void testPostPostconditionFailure(@ArquillianResource final URL url) throws Exception { LOGGER.info("Started {}",testName.getMethodName()); HELPER.base(url); HELPER.setLegacy(false); HttpPost post = HELPER.newRequest(TestingApplication.ROOT_BAD_RESOURCE_PATH,HttpPost.class); post.setEntity( new StringEntity( TEST_SUITE_BODY, ContentType.create("text/turtle", "UTF-8")) ); Metadata response=HELPER.httpRequest(post); assertThat(response.status,equalTo(HttpStatus.SC_INTERNAL_SERVER_ERROR)); assertThat(response.body,notNullValue()); assertThat(response.contentType,startsWith("text/plain")); assertThat(response.language,equalTo(Locale.ENGLISH)); }
Example #14
Source File: ServerFrontendITest.java From ldp4j with Apache License 2.0 | 6 votes |
@Test @Category({ LDP.class, HappyPath.class }) @OperateOnDeployment(DEPLOYMENT) public void testGetWithCharset(@ArquillianResource final URL url) throws Exception { LOGGER.info("Started {}",testName.getMethodName()); HELPER.base(url); HELPER.setLegacy(false); HttpGet newRequest = HELPER.newRequest(MyApplication.ROOT_PERSON_RESOURCE_PATH,HttpGet.class); newRequest.setHeader("Accept","text/turtle"); newRequest.setHeader("Accept-Charset",Charsets.ISO_8859_1.displayName()); Metadata response = HELPER.httpRequest(newRequest); assertThat(response.contentType,startsWith("text/turtle")); assertThat(response.contentType,containsString("charset="+Charsets.ISO_8859_1.displayName())); LOGGER.info("Completed {}",testName.getMethodName()); }
Example #15
Source File: Simple2ExampleTest.java From appengine-tck with Apache License 2.0 | 6 votes |
/** * @param url the url of the container. * @throws Exception * @RunAsClient runs the test outside of the container. The common * usage is to hit a test servlet with some requests, store the results in * datastore, then verify the results in a subsequent test case that has access * to the results. @InSequence tells the runner which order to execute the test * cases. */ @Test @RunAsClient @InSequence(1) public void invokeTimestampTest(@ArquillianResource URL url) throws Exception { String clientTimeStamp = "" + System.currentTimeMillis(); URL testUrl = new URL(url, "examplePage.jsp?ts=" + clientTimeStamp); HttpURLConnection connection = (HttpURLConnection) testUrl.openConnection(); connection.setRequestProperty("User-Agent", "TCK Example"); String response = null; try { response = readFullyAndClose(connection.getInputStream()).trim(); } finally { connection.disconnect(); } // Verify result in client. Assert.assertEquals("Timestamp should be echoed back.", clientTimeStamp, response); }
Example #16
Source File: OIDCAdapterClusterTest.java From keycloak with Apache License 2.0 | 6 votes |
@Test public void testSuccessfulLoginAndBackchannelLogout(@ArquillianResource @OperateOnDeployment(value = SessionPortalDistributable.DEPLOYMENT_NAME) URL appUrl) { String proxiedUrl = getProxiedUrl(appUrl); driver.navigate().to(proxiedUrl); assertCurrentUrlStartsWith(loginPage); loginPage.form().login("[email protected]", "password"); assertCurrentUrlEquals(proxiedUrl); assertSessionCounter(NODE_2_NAME, NODE_2_URI, NODE_1_URI, proxiedUrl, 2); assertSessionCounter(NODE_1_NAME, NODE_1_URI, NODE_2_URI, proxiedUrl, 3); assertSessionCounter(NODE_2_NAME, NODE_2_URI, NODE_1_URI, proxiedUrl, 4); String logoutUri = OIDCLoginProtocolService.logoutUrl(authServerPage.createUriBuilder()) .queryParam(OAuth2Constants.REDIRECT_URI, proxiedUrl).build(AuthRealm.DEMO).toString(); driver.navigate().to(logoutUri); Retry.execute(() -> { driver.navigate().to(proxiedUrl); assertCurrentUrlStartsWith(loginPage); }, 10, 300); }
Example #17
Source File: ClientSideWebAppFlowTest.java From appengine-tck with Apache License 2.0 | 6 votes |
@Test @RunAsClient public void testUnauthorizedMultipleScopeDoesNotAuthenticate(@ArquillianResource URL url) throws Exception { assumeEnvironment(Environment.APPSPOT); String accessToken = getGoogleAccessToken(nonAdminTestingAccountEmail, nonAdminTestingAccountPw, oauthClientId, oauthRedirectUri, SCOPE_USER); String multiScope = SCOPE_USER + " " + SCOPE_PROFILE; String response = invokeMethodOnServer(url, "getEmail", accessToken, multiScope); OAuthServletAnswer answer = new OAuthServletAnswer(response); String expectedException = InvalidOAuthParametersException.class.getName(); assertTrue("Multiple scopes should not match, expected " + expectedException + ", but was " + answer.getReturnVal(), answer.getReturnVal().contains(expectedException)); }
Example #18
Source File: BlobstoreTest.java From appengine-tck with Apache License 2.0 | 6 votes |
@Test @RunAsClient public void testOnlyPartOfBlobServedWhenResponseContainsBlobRangeHeader(@ArquillianResource URL url) throws Exception { String CONTENTS = "abcdefghijklmnopqrstuvwxyz"; URL pageUrl = new URL(url, "serveblob?name=testrange.txt&mimeType=text/plain&contents=" + CONTENTS + "&blobRange=bytes=2-5"); HttpURLConnection connection = (HttpURLConnection) pageUrl.openConnection(); try { String response = readFullyAndClose(connection.getInputStream()); int PARTIAL_CONTENT = 206; assertEquals(PARTIAL_CONTENT, connection.getResponseCode()); assertEquals("bytes 2-5/26", connection.getHeaderField("Content-Range")); assertEquals(CONTENTS.substring(2, 5 + 1), response); assertNull("header should have been removed from response", connection.getHeaderField("X-AppEngine-BlobRange")); } finally { connection.disconnect(); } }
Example #19
Source File: StudentResourceIntegrationTest.java From tutorials with MIT License | 5 votes |
@Test @RunAsClient public void when_put__then_return_ok(@ArquillianResource URL url) throws URISyntaxException, JsonProcessingException { Student student = new Student("firstName", "lastName"); student.setId(1L); String studentJson = new ObjectMapper().writeValueAsString(student); WebTarget webTarget = ClientBuilder.newClient().target(url.toURI()); Response response = webTarget .path("/student") .request(MediaType.APPLICATION_JSON) .put(Entity.json(studentJson)); assertEquals(200, response.getStatus()); }
Example #20
Source File: HammockURLProvider.java From hammock with Apache License 2.0 | 5 votes |
@Override public Object lookup(ArquillianResource arquillianResource, Annotation... annotations) { HammockRuntime hammockRuntime = CDI.current().select(HammockRuntime.class).get(); try { return new URL(hammockRuntime.getMachineURL()); } catch (MalformedURLException e) { throw new RuntimeException(e); } }
Example #21
Source File: EndPointsTest.java From appengine-tck with Apache License 2.0 | 5 votes |
@Test @RunAsClient public void testPut(@ArquillianResource URL url) throws Exception { URL endPointUrl = toHttps(new URL(url, createPath("put"))); String response = client.doPut(endPointUrl); assertResponse("method put was invoked", response); }
Example #22
Source File: ClientSideWebAppFlowTest.java From appengine-tck with Apache License 2.0 | 5 votes |
@Test @RunAsClient public void testUnauthenticatedRequest(@ArquillianResource URL url) throws Exception { String response = invokeMethodOnServerUnauthenticated(url, "getEmail"); OAuthServletAnswer answer = new OAuthServletAnswer(response); assertEquals("Should NOT be authenticated: " + answer.getReturnVal(), "user is null", answer.getReturnVal()); }
Example #23
Source File: BlobstoreUploadTestBase.java From appengine-tck with Apache License 2.0 | 5 votes |
@Test @RunAsClient @InSequence(60) public void testMaxPerBlob(@ArquillianResource URL url) throws Exception { FileUploader fileUploader = new FileUploader(); // 5 is smaller then content's length String uploadUrl = fileUploader.getUploadUrl(new URL(url, "getUploadUrl"), Collections.singletonMap("max_per_blob", "5")); fileUploader.uploadFile(uploadUrl, "file", getRandomName(), CONTENT_TYPE, UPLOADED_CONTENT, 413); }
Example #24
Source File: UserServiceTest.java From appengine-tck with Apache License 2.0 | 5 votes |
@Test @RunAsClient public void testGetEmailProd(@ArquillianResource URL url) throws Exception { if (!isServletProd(url)) { return; } initAuthClient(url, userId, pw); ServletAnswer answer = getAuthServletAnswer(authClient, url, "getEmail"); Assert.assertEquals("UserId should be same as authenticated user:" + answer, userId, answer.getReturnVal()); }
Example #25
Source File: SessionEventsTest.java From deltaspike with Apache License 2.0 | 5 votes |
/** * Now send a request which creates a session */ @Test @RunAsClient @InSequence(5) public void sendRequestToDestroySession(@ArquillianResource URL contextPath) throws Exception { String url = new URL(contextPath, "destroy-session").toString(); HttpResponse response = client.execute(new HttpGet(url)); assertEquals(200, response.getStatusLine().getStatusCode()); EntityUtils.consumeQuietly(response.getEntity()); }
Example #26
Source File: BlobstoreUploadTestBase.java From appengine-tck with Apache License 2.0 | 5 votes |
@Test @RunAsClient @InSequence(80) public void testBucketName(@ArquillianResource URL url) throws Exception { FileUploader fileUploader = new FileUploader(); String uploadUrl = fileUploader.getUploadUrl(new URL(url, "getUploadUrl"), Collections.singletonMap("bucket_name", "TheBucket")); String blobKey = fileUploader.uploadFile(uploadUrl, "file", getRandomName(), CONTENT_TYPE, UPLOADED_CONTENT); Assert.assertTrue(String.format("Received blobKey '%s'", blobKey), blobKey.contains("gs")); // TODO -- better way? }
Example #27
Source File: ClientSideWebAppFlowTest.java From appengine-tck with Apache License 2.0 | 5 votes |
@Test @RunAsClient public void testNoScopeThrowsInvalidOAuthTokenException(@ArquillianResource URL url) throws Exception { assumeEnvironment(Environment.APPSPOT); String accessToken = getGoogleAccessToken(nonAdminTestingAccountEmail, nonAdminTestingAccountPw, oauthClientId, oauthRedirectUri, SCOPE_USER); String emptyScope = ""; String response = invokeMethodOnServer(url, "getEmail", accessToken, emptyScope); OAuthServletAnswer answer = new OAuthServletAnswer(response); String expectedException = InvalidOAuthTokenException.class.getName(); assertTrue("Expected: " + expectedException, answer.getReturnVal().startsWith(expectedException)); }
Example #28
Source File: TransformerTest.java From appengine-tck with Apache License 2.0 | 5 votes |
@Test @RunAsClient public void testApiResourceProperty(@ArquillianResource URL url) throws Exception { URL endPointUrl = toHttps(new URL(url, createPath("foo"))); String response = invokeEndpointWithPost(endPointUrl); // x is OK, y is ignored, qwerty is renamed Map<String, String> actual = new HashMap<>(); actual.put("x", "1"); actual.put("qwerty", "3"); assertResponse(actual, response); Set<String> excluded = Collections.singleton("y"); assertExcluded(excluded, response); }
Example #29
Source File: ServerFrontendITest.java From ldp4j with Apache License 2.0 | 5 votes |
@Test @Category({ LDP.class, HappyPath.class }) @OperateOnDeployment(DEPLOYMENT) public void testEnhancedDelete(@ArquillianResource final URL url) throws Exception { LOGGER.info("Started {}",testName.getMethodName()); HELPER.base(url); HELPER.setLegacy(false); HELPER.httpRequest(HELPER.newRequest(MyApplication.ROOT_PERSON_RESOURCE_PATH,HttpDelete.class)); LOGGER.info("Completed {}",testName.getMethodName()); }
Example #30
Source File: UserServiceTest.java From appengine-tck with Apache License 2.0 | 5 votes |
/** * Verify isUserLoggedIn on dev_appserver. */ @Test @RunAsClient public void testIsUserLoggedInDev(@ArquillianResource URL url) throws Exception { if (!isServletDev(url)) { return; } ServletAnswer answer = getUnAuthServletAnswer(url, "isUserLoggedIn"); Assert.assertEquals("false", answer.getReturnVal()); }