本文整理匯總了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();
}