當前位置: 首頁>>代碼示例>>Java>>正文


Java RestAssured.get方法代碼示例

本文整理匯總了Java中io.restassured.RestAssured.get方法的典型用法代碼示例。如果您正苦於以下問題:Java RestAssured.get方法的具體用法?Java RestAssured.get怎麽用?Java RestAssured.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.restassured.RestAssured的用法示例。


在下文中一共展示了RestAssured.get方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: test

import io.restassured.RestAssured; //導入方法依賴的package包/類
@Test
public void test() throws InstantiationException, IllegalAccessException {
	String url = getBaseUri() + "country/ch";
	io.restassured.response.Response getResponse = RestAssured.get(url);
	Assert.assertEquals(200, getResponse.getStatusCode());

	getResponse.then().assertThat().body("data.attributes.deText", Matchers.equalTo("Schweiz"));
	getResponse.then().assertThat().body("data.attributes.enText", Matchers.equalTo("Switzerland"));

	String patchData = "{'data':{'id':'ch','type':'country','attributes':{'deText':'Test','enText':'Switzerland','ctlActCd':true}}}".replaceAll("'", "\"");

	Response patchResponse = RestAssured.given().body(patchData.getBytes()).header("content-type", JsonApiMediaType.APPLICATION_JSON_API).when().patch(url);
	patchResponse.then().statusCode(HttpStatus.SC_OK);

	getResponse = RestAssured.get(url);
	Assert.assertEquals(200, getResponse.getStatusCode());
	getResponse.then().assertThat().body("data.attributes.deText", Matchers.equalTo("Test"));
	getResponse.then().assertThat().body("data.attributes.enText", Matchers.equalTo("Switzerland"));
}
 
開發者ID:crnk-project,項目名稱:crnk-framework,代碼行數:20,代碼來源:CustomResourceFieldTest.java

示例2: testInvokeRepositoryActionWithException

import io.restassured.RestAssured; //導入方法依賴的package包/類
@Test
public void testInvokeRepositoryActionWithException() {
	// resources should be received in json api format
	String url = getBaseUri() + "schedules/repositoryActionWithException?msg=hello";
	io.restassured.response.Response res = RestAssured.get(url);
	Assert.assertEquals(403, res.getStatusCode());

	res.then().assertThat().body("errors[0].status", Matchers.equalTo("403"));

	// check filters
	ArgumentCaptor<DocumentFilterContext> contexts = ArgumentCaptor.forClass(DocumentFilterContext.class);
	Mockito.verify(filter, Mockito.times(1)).filter(contexts.capture(), Mockito.any(DocumentFilterChain.class));
	DocumentFilterContext actionContext = contexts.getAllValues().get(0);
	Assert.assertEquals("GET", actionContext.getMethod());
	Assert.assertTrue(actionContext.getJsonPath() instanceof ActionPath);
}
 
開發者ID:crnk-project,項目名稱:crnk-framework,代碼行數:17,代碼來源:InteroperabilityTest.java

示例3: testInvokeRepositoryActionWithException

import io.restassured.RestAssured; //導入方法依賴的package包/類
@Test
public void testInvokeRepositoryActionWithException() {
	// resources should be received in json api format
	String url = getBaseUri() + "schedules/repositoryActionWithException?msg=hello";
	io.restassured.response.Response response = RestAssured.get(url);
	Assert.assertEquals(403, response.getStatusCode());

	response.then().assertThat().body("errors[0].status", Matchers.equalTo("403"));

	// check filters
	ArgumentCaptor<DocumentFilterContext> contexts = ArgumentCaptor.forClass(DocumentFilterContext.class);
	Mockito.verify(filter, Mockito.times(1)).filter(contexts.capture(), Mockito.any(DocumentFilterChain.class));
	DocumentFilterContext actionContext = contexts.getAllValues().get(0);
	Assert.assertEquals("GET", actionContext.getMethod());
	Assert.assertTrue(actionContext.getJsonPath() instanceof ActionPath);
}
 
開發者ID:crnk-project,項目名稱:crnk-framework,代碼行數:17,代碼來源:JsonApiActionResponseTest.java

示例4: testInvokeRepositoryActionWithException

import io.restassured.RestAssured; //導入方法依賴的package包/類
@Test
public void testInvokeRepositoryActionWithException() {
	// resources should be received in json api format
	String url = getBaseUri() + "schedules/repositoryActionWithException?msg=hello";
	io.restassured.response.Response response = RestAssured.get(url);
	Assert.assertEquals(403, response.getStatusCode());
	System.out.println("body: " + response.body().asString());

	response.then().assertThat().body("errors[0].status", Matchers.equalTo("403"));

	// check filters
	ArgumentCaptor<DocumentFilterContext> contexts = ArgumentCaptor.forClass(DocumentFilterContext.class);
	Mockito.verify(filter, Mockito.times(1)).filter(contexts.capture(), Mockito.any(DocumentFilterChain.class));
	DocumentFilterContext actionContext = contexts.getAllValues().get(0);
	Assert.assertEquals("GET", actionContext.getMethod());
	Assert.assertTrue(actionContext.getJsonPath() instanceof ActionPath);
}
 
開發者ID:katharsis-project,項目名稱:katharsis-framework,代碼行數:18,代碼來源:JsonApiActionResponseTest.java

示例5: the

import io.restassured.RestAssured; //導入方法依賴的package包/類
@When("^I want to get information on the (.+) project$")
public void usersGetInformationOnAProject(String projectName) throws IOException {
    wireMockServer.start();

    configureFor("localhost", 8080);

    stubFor(get(urlEqualTo(GET_JSON_PATH+projectName))
            .willReturn(aResponse().withBody(jsonString).withHeader("content-type", JSON_CONTENT_TYPE).withStatus(200)));

    Response res = RestAssured.get(GET_JSON_PATH+projectName);

    assertEquals(200, res.getStatusCode());
    String json = res.body().asString();
    JsonPath jp = new JsonPath(json);
    assertNotNull(jp);
    assertEquals("cucumber", jp.getString("testing-framework"));
    assertEquals("cucumber.io", jp.getString("website"));
    assertTrue(jp.getString("supported-language").contains("Java"));
    assertTrue(jp.getString("supported-language").contains("C++"));

    /* ANOTHER WAY TO DO THE SAME */
   /* given().contentType(JSON_CONTENT_TYPE).expect()
            .statusCode(200)
            .body(
                    "testing-framework", Matchers.equalTo("cucumber"),
                    "website", Matchers.equalTo("cucumber.io"),
                    "supported-language", Matchers.contains(
                        "Ruby",
                        "Java",
                        "Javascript",
                        "PHP",
                        "Python",
                        "C++"))
            .when()
            .get(GET_JSON_PATH+projectName); */

    wireMockServer.stop();
}
 
開發者ID:mariaklimenko,項目名稱:jeta,代碼行數:39,代碼來源:RestAssuredSteps.java

示例6: testInvokeRepositoryActionWithResourceResult

import io.restassured.RestAssured; //導入方法依賴的package包/類
@Test
public void testInvokeRepositoryActionWithResourceResult() {
	// resources should be received in json api format
	String url = getBaseUri() + "schedules/repositoryActionWithResourceResult?msg=hello";
	io.restassured.response.Response res = RestAssured.get(url);
	Assert.assertEquals(200, res.getStatusCode());
	res.then().assertThat().body("data.attributes.name", Matchers.equalTo("hello"));

	// check filters
	ArgumentCaptor<DocumentFilterContext> contexts = ArgumentCaptor.forClass(DocumentFilterContext.class);
	Mockito.verify(filter, Mockito.times(1)).filter(contexts.capture(), Mockito.any(DocumentFilterChain.class));
	DocumentFilterContext actionContext = contexts.getAllValues().get(0);
	Assert.assertEquals("GET", actionContext.getMethod());
	Assert.assertTrue(actionContext.getJsonPath() instanceof ActionPath);
}
 
開發者ID:crnk-project,項目名稱:crnk-framework,代碼行數:16,代碼來源:InteroperabilityTest.java

示例7: testInvokeRepositoryActionWithResourceResult

import io.restassured.RestAssured; //導入方法依賴的package包/類
@Test
public void testInvokeRepositoryActionWithResourceResult() {
	// resources should be received in json api format
	String url = getBaseUri() + "schedules/repositoryActionWithResourceResult?msg=hello";
	io.restassured.response.Response response = RestAssured.get(url);
	Assert.assertEquals(200, response.getStatusCode());
	response.then().assertThat().body("data.attributes.name", Matchers.equalTo("hello"));

	// check filters
	ArgumentCaptor<DocumentFilterContext> contexts = ArgumentCaptor.forClass(DocumentFilterContext.class);
	Mockito.verify(filter, Mockito.times(1)).filter(contexts.capture(), Mockito.any(DocumentFilterChain.class));
	DocumentFilterContext actionContext = contexts.getAllValues().get(0);
	Assert.assertEquals("GET", actionContext.getMethod());
	Assert.assertTrue(actionContext.getJsonPath() instanceof ActionPath);
}
 
開發者ID:crnk-project,項目名稱:crnk-framework,代碼行數:16,代碼來源:JsonApiActionResponseTest.java

示例8: getVideo

import io.restassured.RestAssured; //導入方法依賴的package包/類
@Attachment(value = "Video on Failure", type = "video/mp4")
private static byte[] getVideo(URL videoCaptureURL)
        throws TimeoutException, InterruptedException, ConnectException {
    int i = 0;
    while (i++ < 4) {
        logger.debug("Download URL for Video Capture: " + videoCaptureURL);
        Response response = RestAssured.get(videoCaptureURL);
        if (response.getStatusCode() == HttpStatus.SC_OK) {
            return response.asByteArray();
        }
        TimeUnit.SECONDS.sleep(2);
    }
    throw new TimeoutException();
}
 
開發者ID:Frameworkium,項目名稱:frameworkium-core,代碼行數:15,代碼來源:VideoCapture.java

示例9: testSongRest

import io.restassured.RestAssured; //導入方法依賴的package包/類
@Test
public void testSongRest() {
    Response response = RestAssured.get("http://localhost:8080/api/songs/");
    assertEquals(200, response.getStatusCode());
}
 
開發者ID:muatik,項目名稱:spring-playground,代碼行數:6,代碼來源:SongsTest.java


注:本文中的io.restassured.RestAssured.get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。