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


Java ResultActions.andReturn方法代碼示例

本文整理匯總了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);
}
 
開發者ID:StuPro-TOSCAna,項目名稱:TOSCAna,代碼行數:21,代碼來源:CsarControllerTest.java

示例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);
    }
}
 
開發者ID:StuPro-TOSCAna,項目名稱:TOSCAna,代碼行數:17,代碼來源:CsarControllerTest.java

示例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();
}
 
開發者ID:StuPro-TOSCAna,項目名稱:TOSCAna,代碼行數:15,代碼來源:PlatformControllerTest.java

示例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();
    }
}
 
開發者ID:StuPro-TOSCAna,項目名稱:TOSCAna,代碼行數:13,代碼來源:PlatformControllerTest.java

示例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();
}
 
開發者ID:StuPro-TOSCAna,項目名稱:TOSCAna,代碼行數:9,代碼來源:PlatformControllerTest.java

示例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();
}
 
開發者ID:StuPro-TOSCAna,項目名稱:TOSCAna,代碼行數:13,代碼來源:CsarControllerTest.java

示例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();
}
 
開發者ID:StuPro-TOSCAna,項目名稱:TOSCAna,代碼行數:15,代碼來源:CsarControllerTest.java


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