当前位置: 首页>>代码示例>>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;未经允许,请勿转载。