本文整理汇总了Java中org.springframework.test.web.servlet.ResultActions.andReturn方法的典型用法代码示例。如果您正苦于以下问题:Java ResultActions.andReturn方法的具体用法?Java ResultActions.andReturn怎么用?Java ResultActions.andReturn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.test.web.servlet.ResultActions
的用法示例。
在下文中一共展示了ResultActions.andReturn方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: uploadTest
import org.springframework.test.web.servlet.ResultActions; //导入方法依赖的package包/类
@Test
public void uploadTest() throws Exception {
byte[] data = generateRandomByteArray(rnd, 10 * 1024);
byte[] hash = getSHA256Hash(data);
String path = CSAR_BASE_URL + "rnd";
MockMultipartHttpServletRequestBuilder builder = buildMockedMultipartUploadRequest(data, path);
ResultActions resultActions = mvc.perform(
builder
).andDo(print()).andExpect(status().is2xxSuccessful());
resultActions.andReturn();
assertNotNull(dataRead);
assertEquals(data.length, dataRead.length);
byte[] hashUpload = getSHA256Hash(this.dataRead);
assertHashesEqual(hash, hashUpload);
}
示例2: csarDetails
import org.springframework.test.web.servlet.ResultActions; //导入方法依赖的package包/类
@Test
public void csarDetails() throws Exception {
for (String name : MOCK_CSAR_NAMES) {
ResultActions resultActions = mvc.perform(
get(CSAR_BASE_URL + name).accept(ACCEPTED_MIME_TYPE)
).andDo(print()).andExpect(status().is2xxSuccessful());
resultActions.andExpect(jsonPath("$.name").value(name));
resultActions.andExpect(jsonPath("$.links").isArray());
resultActions.andExpect(jsonPath("$.links[" + relations.size() + "]").doesNotExist());
//Validate String result
MvcResult result = resultActions.andReturn();
JSONObject object = new JSONObject(result.getResponse().getContentAsString());
HALRelationUtils.validateRelations(object.getJSONArray("links"), relations, name);
}
}
示例3: listPlatforms
import org.springframework.test.web.servlet.ResultActions; //导入方法依赖的package包/类
@Test
public void listPlatforms() throws Exception {
ResultActions resultActions = mvc.perform(
get("/api/platforms")
).andDo(print()).andExpect(status().is2xxSuccessful())
.andExpect(content().contentType("application/hal+json;charset=UTF-8"));
resultActions.andExpect(jsonPath("$._embedded.platform").isArray());
resultActions.andExpect(jsonPath("$._embedded.platform[" + PLATFORMS.size() + "]").doesNotExist());
for (int i = 0; i < PLATFORMS.size(); i++) {
resultActions.andExpect(jsonPath("$._embedded.platform[" + i + "].id").isString());
resultActions.andExpect(jsonPath("$._embedded.platform[" + i + "].name").isString());
}
resultActions.andReturn();
}
示例4: platformDetails
import org.springframework.test.web.servlet.ResultActions; //导入方法依赖的package包/类
@Test
public void platformDetails() throws Exception {
for (Platform platform : prov.getSupportedPlatforms()) {
ResultActions resultActions = mvc.perform(
get("/api/platforms/" + platform.id)
).andDo(print());
resultActions.andExpect(jsonPath("$.id").value(platform.id));
resultActions.andExpect(jsonPath("$.name").value(platform.name));
resultActions.andExpect(jsonPath("$._links.self.href").isString());
resultActions.andReturn();
}
}
示例5: platformDetails404
import org.springframework.test.web.servlet.ResultActions; //导入方法依赖的package包/类
@Test
public void platformDetails404() throws Exception {
ResultActions resultActions = mvc.perform(
get("/api/platforms/not-a-platform")
).andDo(print());
resultActions.andExpect(status().isNotFound());
resultActions.andReturn();
}
示例6: listCsars
import org.springframework.test.web.servlet.ResultActions; //导入方法依赖的package包/类
@Test
public void listCsars() throws Exception {
ResultActions resultActions = mvc.perform(
get(LIST_CSARS_URL).accept(ACCEPTED_MIME_TYPE)
).andDo(print()).andExpect(status().is2xxSuccessful());
resultActions.andExpect(jsonPath("$.links[0].rel").value("self"));
resultActions.andExpect(jsonPath("$.links[0].href").value(LIST_CSARS_SELF_URL));
resultActions.andExpect(jsonPath("$.content").exists());
resultActions.andExpect(jsonPath("$.content").isArray());
resultActions.andExpect(jsonPath("$.content[2]").doesNotExist());
resultActions.andReturn();
}
示例7: uploadTestArchiveAlreadyExists
import org.springframework.test.web.servlet.ResultActions; //导入方法依赖的package包/类
@Test
public void uploadTestArchiveAlreadyExists() throws Exception {
//Generate 10 KiB of random data
byte[] data = generateRandomByteArray(rnd, 10);
String path = CSAR_BASE_URL + "apache";
MockMultipartHttpServletRequestBuilder builder = buildMockedMultipartUploadRequest(data, path);
ResultActions resultActions = mvc.perform(
builder
).andDo(print()).andExpect(status().is(201));
resultActions.andReturn();
}