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