org.springframework.test.web.servlet.result.MockMvcResultHandlers Java Examples

The following examples show how to use org.springframework.test.web.servlet.result.MockMvcResultHandlers. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ContractControllerTest.java    From WeBASE-Node-Manager with Apache License 2.0 6 votes vote down vote up
@Test
public void testFindByPartOfBytecodeBin() throws Exception {
    String bytecodeBin = "6060604052341561000c57fe5b5b6001600060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506402540be4006000600101819055506002600260000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060006002600101819055505b5b610443806100c26000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806366c99139146100465780636d4ce63c14610066575bfe5b341561004e57fe5b610064600480803590602001909190505061008c565b005b341561006e57fe5b610076610264565b6040518082815260200191505060405180910390f35b806000600101540360006001018190555080600260010160008282540192505081905550600480548060010182816100c49190610272565b916000526020600020906004020160005b608060405190810160405280604060405190810160405280600881526020017f32303137303431330000000000000000000000000000000000000000000000008152508152602001600060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001600260000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200185815250909190915060008201518160000190805190602001906101c49291906102a4565b5060208201518160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060408201518160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550606082015181600301555050505b50565b600060026001015490505b90565b81548183558181151161029f5760040281600402836000526020600020918201910161029e9190610324565b5b505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106102e557805160ff1916838001178555610313565b82800160010185558215610313579182015b828111156103125782518255916020019190600101906102f7565b5b50905061032091906103aa565b5090565b6103a791905b808211156103a357600060008201600061034491906103cf565b6001820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556002820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905560038201600090555060040161032a565b5090565b90565b6103cc91905b808211156103c85760008160009055506001016103b0565b5090565b90565b50805460018160011615610100020316600290046000825580601f106103f55750610414565b601f01602090049060005260206000209081019061041391906103aa565b5b505600a165627a7a72305820d453cb481a312519166e409e7248d76d8c2672458c08b9500945a4004a1b69020029";
    String partOfBytecodeBin = "test" + bytecodeBin;
    QueryByBinParam param = new QueryByBinParam();
    param.setGroupId(2);
    param.setPartOfBytecodeBin(partOfBytecodeBin);

    ResultActions resultActions = mockMvc
        .perform(MockMvcRequestBuilders.post("/contract/findByPartOfBytecodeBin").
            content(JsonTools.toJSONString(param)).
            contentType(MediaType.APPLICATION_JSON_UTF8)
        );
    resultActions.
        andExpect(MockMvcResultMatchers.status().isOk()).
        andDo(MockMvcResultHandlers.print());
    System.out
        .println("response:" + resultActions.andReturn().getResponse().getContentAsString());
}
 
Example #2
Source File: ProjectControllerTest.java    From AthenaServing with Apache License 2.0 6 votes vote down vote up
/**
 * 删除项目成员
 *
 * @throws Exception
 */
@Test
public void test_project_7_member_delete() throws Exception {
    DeleteProjectMemberRequestBody body = new DeleteProjectMemberRequestBody();
    body.setId("3714708188751200256");
    body.setUserId("3688919024172793856");
    String result = this.mockMvc.perform(MockMvcRequestBuilders.post("/api/v1/project/member/delete")
            .content(JSON.toJSONString(body))
            .contentType(MediaType.APPLICATION_JSON)
            .session((MockHttpSession) Utils.getLoginSession(this.mockMvc))
            .accept(MediaType.APPLICATION_JSON))
            .andExpect(MockMvcResultMatchers.status().isOk())
            .andDo(MockMvcResultHandlers.print())
            .andReturn().getResponse().getContentAsString();
    Utils.assertResult(result);
}
 
Example #3
Source File: UserControllerTest.java    From AthenaServing with Apache License 2.0 6 votes vote down vote up
/**
 * 新增用户
 *
 * @throws Exception
 */
@Test
public void test_user_3_add() throws Exception {
    AddUserRequestBody body = new AddUserRequestBody();
    body.setAccount("sctang");
    body.setEmail("[email protected]");
    body.setPhone("13739263609");
    body.setUserName("sctang");
    String result = this.mockMvc.perform(MockMvcRequestBuilders.post("/api/v1/user/add")
            .content(JSON.toJSONString(body))
            .contentType(MediaType.APPLICATION_JSON)
            .session((MockHttpSession) Utils.getLoginSession(this.mockMvc))
            .accept(MediaType.APPLICATION_JSON))
            .andExpect(MockMvcResultMatchers.status().isOk())
            .andDo(MockMvcResultHandlers.print())
            .andReturn().getResponse().getContentAsString();
    Utils.assertResult(result);
}
 
Example #4
Source File: ServiceConfigControllerTest.java    From AthenaServing with Apache License 2.0 6 votes vote down vote up
/**
 * 查询配置历史列表
 *
 * @throws Exception
 */
@Test
public void test_service_config_8_historyList() throws Exception {
    String result = this.mockMvc.perform(MockMvcRequestBuilders.get("/api/v1/service/config/historyList")
            .param("project", "GG")
            .param("cluster", "GG")
            .param("service", "GG")
            .param("version", "1.0")
            .param("isPage", "1")
            .contentType(MediaType.APPLICATION_JSON)
            .session((MockHttpSession) Utils.getLoginSession(this.mockMvc))
            .accept(MediaType.APPLICATION_JSON))
            .andExpect(MockMvcResultMatchers.status().isOk())
            .andDo(MockMvcResultHandlers.print())
            .andReturn().getResponse().getContentAsString();
    Utils.assertResult(result);
}
 
Example #5
Source File: UserControllerTest.java    From WeBASE-Node-Manager with Apache License 2.0 6 votes vote down vote up
@Test
public void testUpdateUser() throws Exception {
    UpdateUserInputParam updateUser = new UpdateUserInputParam();
    updateUser.setUserId(700001);
    updateUser.setDescription("testtttttttttttttttttttttttt");

    ResultActions resultActions = mockMvc.perform(MockMvcRequestBuilders.put("/user/userInfo").
        content(JsonTools.toJSONString(updateUser)).
        contentType(MediaType.APPLICATION_JSON_UTF8)
    );
    resultActions.
        andExpect(MockMvcResultMatchers.status().isOk()).
        andDo(MockMvcResultHandlers.print());
    System.out
        .println("response:" + resultActions.andReturn().getResponse().getContentAsString());
}
 
Example #6
Source File: ServiceConfigControllerTest.java    From AthenaServing with Apache License 2.0 6 votes vote down vote up
/**
 * 回滚配置
 *
 * @throws Exception
 */
@Test
public void test_service_config_9_rollback() throws Exception {
    IdsRequestBody body = new IdsRequestBody();
    List<String> ids = new ArrayList<>();
    ids.add("3731673452474531840");
    ids.add("3731673452474531841");
    body.setIds(ids);
    String result = this.mockMvc.perform(MockMvcRequestBuilders.post("/api/v1/service/config/rollback")
            .content(JSON.toJSONString(body))
            .contentType(MediaType.APPLICATION_JSON)
            .session((MockHttpSession) Utils.getLoginSession(this.mockMvc))
            .accept(MediaType.APPLICATION_JSON))
            .andExpect(MockMvcResultMatchers.status().isOk())
            .andDo(MockMvcResultHandlers.print())
            .andReturn().getResponse().getContentAsString();
    Utils.assertResult(result);
}
 
Example #7
Source File: ProjectControllerTest.java    From AthenaServing with Apache License 2.0 6 votes vote down vote up
/**
 * 编辑项目
 *
 * @throws Exception
 */
@Test
public void test_project_2_edit() throws Exception {
    EditProjectRequestBody body = new EditProjectRequestBody();
    body.setId("3714708188751200256");
    body.setDesc("修改项目后的描述");
    String result = this.mockMvc.perform(MockMvcRequestBuilders.post("/api/v1/project/edit")
            .content(JSON.toJSONString(body))
            .contentType(MediaType.APPLICATION_JSON)
            .session((MockHttpSession) Utils.getLoginSession(this.mockMvc))
            .accept(MediaType.APPLICATION_JSON))
            .andExpect(MockMvcResultMatchers.status().isOk())
            .andDo(MockMvcResultHandlers.print())
            .andReturn().getResponse().getContentAsString();
    Utils.assertResult(result);
}
 
Example #8
Source File: ServiceConfigControllerTest.java    From AthenaServing with Apache License 2.0 6 votes vote down vote up
/**
 * 查询最近的配置列表
 *
 * @throws Exception
 */
@Test
public void test_service_config_1_lastestList() throws Exception {
    String result = this.mockMvc.perform(MockMvcRequestBuilders.get("/api/v1/service/config/lastestList")
            .param("project", "project3")
            .param("cluster", "cluster1")
            .param("service", "service1")
            .param("version", "1.0.0.1")
            .contentType(MediaType.APPLICATION_JSON)
            .session((MockHttpSession) Utils.getLoginSession(this.mockMvc))
            .accept(MediaType.APPLICATION_JSON))
            .andExpect(MockMvcResultMatchers.status().isOk())
            .andDo(MockMvcResultHandlers.print())
            .andReturn().getResponse().getContentAsString();
    Utils.assertResult(result);
}
 
Example #9
Source File: UserControllerTest.java    From java-master with Apache License 2.0 6 votes vote down vote up
@Test
@WithMockUser(username = "1050106266",
        password = "123456",
        authorities = "ROLE_ADMIN")
public void testFindUsers() throws Exception {
    FindUsersReqVo reqVo = new FindUsersReqVo();
    SysUser user = new SysUser();
    user.setEnabled(true);
    reqVo.setSysUser(user);
    Page page = new Page();
    page.setPageNum(0);
    page.setPageSize(10);
    reqVo.setPage(page);
    System.out.println(objectMapper.writeValueAsString(reqVo));
    mockMvc.perform(MockMvcRequestBuilders.post("/admin/user/findUsers")
            .contentType(MediaType.APPLICATION_JSON)
            .content(objectMapper.writeValueAsString(reqVo))
            .accept(MediaType.APPLICATION_JSON))
            .andDo(MockMvcResultHandlers.print())
            .andExpect(MockMvcResultMatchers.status().isOk());
}
 
Example #10
Source File: EventControllerTest.java    From WeBASE-Front with Apache License 2.0 6 votes vote down vote up
/**
	 * need to create exchange and queue with routing key in mq
	 * @throws Exception
	 */
	@Test
	public void testRegisterContractEvent() throws Exception {
		ReqContractEventRegister param = new ReqContractEventRegister();
		param.setGroupId(groupId);
		param.setAppId("app1");
		param.setExchangeName("group001");
		param.setQueueName("user1");
		String abiStr = "[{\"constant\":false,\"inputs\":[{\"name\":\"n\",\"type\":\"string\"}],\"name\":\"set\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"get\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"name\",\"type\":\"string\"}],\"name\":\"SetName\",\"type\":\"event\"}]";
		List<Object> abi = JsonUtils.toJavaObjectList(abiStr, Object.class);
		param.setContractAbi(abi);
		param.setFromBlock("latest");
		param.setToBlock("latest");
		param.setContractAddress("0x657201d59ec41d1dc278a67916f751f86ca672f7");
		List<String> topics = new ArrayList<>();
		topics.add("SetName(string)");
		param.setTopicList(topics);
		ResultActions resultActions = mockMvc
				.perform(MockMvcRequestBuilders.post("/event/contractEvent").
						content(JsonUtils.toJSONString(param)).
						contentType(MediaType.APPLICATION_JSON)
				);
		resultActions.
//				andExpect(MockMvcResultMatchers.status().isOk()).
				andDo(MockMvcResultHandlers.print());
	}
 
Example #11
Source File: GrayConfigControllerTest.java    From AthenaServing with Apache License 2.0 6 votes vote down vote up
/**
 * 批量推送配置
 *
 * @throws Exception
 */
@Test
public void test_gray_config_5_batchPush() throws Exception {
    BatchPushServiceConfigRequestBody body = new BatchPushServiceConfigRequestBody();
    List<String> ids = new ArrayList<>();
    ids.add("3780718589976248320");
    ids.add("3780718590009802752");
    ids.add("3780718590009802753");
    body.setIds(ids);
    List<String> regionIds = new ArrayList<>();
    regionIds.add("3777763353183649792");
    body.setRegionIds(regionIds);
    String result = this.mockMvc.perform(MockMvcRequestBuilders.post("/api/v1/grayConfig/batchPush")
            .content(JSON.toJSONString(body))
            .contentType(MediaType.APPLICATION_JSON)
            .session((MockHttpSession) Utils.getLoginSession(this.mockMvc))
            .accept(MediaType.APPLICATION_JSON))
            .andExpect(MockMvcResultMatchers.status().isOk())
            .andDo(MockMvcResultHandlers.print())
            .andReturn().getResponse().getContentAsString();
    Utils.assertResult(result);
}
 
Example #12
Source File: GrayConfigControllerTest.java    From AthenaServing with Apache License 2.0 6 votes vote down vote up
/**
 * 推送配置
 *
 * @throws Exception
 */
@Test
public void test_gray_config_4_push() throws Exception {
    PushServiceConfigRequestBody body = new PushServiceConfigRequestBody();
    body.setId("3780959622257442816");
    List<String> regionIds = new ArrayList<>();
    regionIds.add("3777763353183649792");
    body.setRegionIds(regionIds);
    String result = this.mockMvc.perform(MockMvcRequestBuilders.post("/api/v1/grayConfig/push")
            .content(JSON.toJSONString(body))
            .contentType(MediaType.APPLICATION_JSON)
            .session((MockHttpSession) Utils.getLoginSession(this.mockMvc))
            .accept(MediaType.APPLICATION_JSON))
            .andExpect(MockMvcResultMatchers.status().isOk())
            .andDo(MockMvcResultHandlers.print())
            .andReturn().getResponse().getContentAsString();
    Utils.assertResult(result);
}
 
Example #13
Source File: ExamControllerTest.java    From java-master with Apache License 2.0 6 votes vote down vote up
@Test
@WithMockUser(username = "1050106266",
        password = "123456",
        authorities = "ROLE_ADMIN")
public void testGetExamList() throws Exception {
    Map<String, Object> reqVo = new HashMap<>();
    reqVo.put("examType", 1);
    System.out.println(objectMapper.writeValueAsString(reqVo));
    mockMvc.perform(MockMvcRequestBuilders.post("/json/exam/getExamList")
            .session(session)
            .contentType(MediaType.APPLICATION_JSON)
            .content(objectMapper.writeValueAsString(reqVo))
            .accept(MediaType.APPLICATION_JSON))
            .andDo(MockMvcResultHandlers.print())
            .andExpect(MockMvcResultMatchers.status().isOk());
}
 
Example #14
Source File: ServerControllerTest.java    From das with Apache License 2.0 5 votes vote down vote up
@Test
public void check() throws Exception {
    mockMvc.perform(MockMvcRequestBuilders.post("/server/data")
            .contentType(MediaType.APPLICATION_JSON_UTF8)
            .param("id", "1")
            .accept(MediaType.APPLICATION_JSON_UTF8))
            .andExpect(MockMvcResultMatchers.status().isOk())
            .andDo(MockMvcResultHandlers.print());
}
 
Example #15
Source File: GroupDatabaseControllerTest.java    From das with Apache License 2.0 5 votes vote down vote up
@Test
public void getDBListByGroupId() throws Exception {
    mockMvc.perform(MockMvcRequestBuilders.get("/groupdb/dblist")
            .contentType(MediaType.APPLICATION_JSON_UTF8)
            .accept(MediaType.APPLICATION_JSON_UTF8))
            .andExpect(MockMvcResultMatchers.status().isOk())
            .andDo(MockMvcResultHandlers.print());
}
 
Example #16
Source File: DatabaseSetControllerTest.java    From das with Apache License 2.0 5 votes vote down vote up
@Test
public void check() throws Exception {
    mockMvc.perform(MockMvcRequestBuilders.post("/groupdbset/data")
            .contentType(MediaType.APPLICATION_JSON_UTF8)
            .param("id", "1")
            .accept(MediaType.APPLICATION_JSON_UTF8))
            .andExpect(MockMvcResultMatchers.status().isOk())
            .andDo(MockMvcResultHandlers.print());
}
 
Example #17
Source File: ContractControllerTest.java    From WeBASE-Node-Manager with Apache License 2.0 5 votes vote down vote up
@Test
public void testSaveContract() throws Exception {
    Contract testNew = new Contract();
    testNew.setGroupId(groupId);
    testNew.setContractName("OOk");
    testNew.setContractPath("myPath");
    testNew.setContractSource(
        "cHJhZ21hIHNvbGlkaXR5IF4wLjQuMjsNCmNvbnRyYWN0IE9rew0KICAgIA0KICAgIHN0cnVjdCBBY2NvdW50ew0KICAgICAgICBhZGRyZXNzIGFjY291bnQ7DQogICAgICAgIHVpbnQgYmFsYW5jZTsNCiAgICB9DQogICAgDQogICAgc3RydWN0ICBUcmFuc2xvZyB7DQogICAgICAgIHN0cmluZyB0aW1lOw0KICAgICAgICBhZGRyZXNzIGZyb207DQogICAgICAgIGFkZHJlc3MgdG87DQogICAgICAgIHVpbnQgYW1vdW50Ow0KICAgIH0NCiAgICANCiAgICBBY2NvdW50IGZyb207DQogICAgQWNjb3VudCB0bzsNCiAgICANCiAgICBUcmFuc2xvZ1tdIGxvZzsNCg0KICAgIGZ1bmN0aW9uIE9rKCl7DQogICAgICAgIGZyb20uYWNjb3VudD0weDE7DQogICAgICAgIGZyb20uYmFsYW5jZT0xMDAwMDAwMDAwMDsNCiAgICAgICAgdG8uYWNjb3VudD0weDI7DQogICAgICAgIHRvLmJhbGFuY2U9MDsNCg0KICAgIH0NCiAgICBmdW5jdGlvbiBnZXQoKWNvbnN0YW50IHJldHVybnModWludCl7DQogICAgICAgIHJldHVybiB0by5iYWxhbmNlOw0KICAgIH0NCiAgICBmdW5jdGlvbiB0cmFucyh1aW50IG51bSl7DQogICAgCWZyb20uYmFsYW5jZT1mcm9tLmJhbGFuY2UtbnVtOw0KICAgIAl0by5iYWxhbmNlKz1udW07DQogICAgDQogICAgCWxvZy5wdXNoKFRyYW5zbG9nKCIyMDE3MDQxMyIsZnJvbS5hY2NvdW50LHRvLmFjY291bnQsbnVtKSk7DQogICAgfQ0KDQoNCg0KfQ==");
    testNew.setBytecodeBin(
        "6060604052341561000c57fe5b5b6001600060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506402540be4006000600101819055506002600260000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060006002600101819055505b5b610443806100c26000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806366c99139146100465780636d4ce63c14610066575bfe5b341561004e57fe5b610064600480803590602001909190505061008c565b005b341561006e57fe5b610076610264565b6040518082815260200191505060405180910390f35b806000600101540360006001018190555080600260010160008282540192505081905550600480548060010182816100c49190610272565b916000526020600020906004020160005b608060405190810160405280604060405190810160405280600881526020017f32303137303431330000000000000000000000000000000000000000000000008152508152602001600060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001600260000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200185815250909190915060008201518160000190805190602001906101c49291906102a4565b5060208201518160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060408201518160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550606082015181600301555050505b50565b600060026001015490505b90565b81548183558181151161029f5760040281600402836000526020600020918201910161029e9190610324565b5b505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106102e557805160ff1916838001178555610313565b82800160010185558215610313579182015b828111156103125782518255916020019190600101906102f7565b5b50905061032091906103aa565b5090565b6103a791905b808211156103a357600060008201600061034491906103cf565b6001820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556002820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905560038201600090555060040161032a565b5090565b90565b6103cc91905b808211156103c85760008160009055506001016103b0565b5090565b90565b50805460018160011615610100020316600290046000825580601f106103f55750610414565b601f01602090049060005260206000209081019061041391906103aa565b5b505600a165627a7a72305820d453cb481a312519166e409e7248d76d8c2672458c08b9500945a4004a1b69020029");
    testNew.setContractAbi(
        "[{\"constant\":false,\"inputs\":[{\"name\":\"num\",\"type\":\"uint256\"}],\"name\":\"trans\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"get\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"inputs\":[],\"payable\":false,\"type\":\"constructor\"}]");
    testNew.setContractBin(
        "60606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806366c99139146100465780636d4ce63c14610066575bfe5b341561004e57fe5b610064600480803590602001909190505061008c565b005b341561006e57fe5b610076610264565b6040518082815260200191505060405180910390f35b806000600101540360006001018190555080600260010160008282540192505081905550600480548060010182816100c49190610272565b916000526020600020906004020160005b608060405190810160405280604060405190810160405280600881526020017f32303137303431330000000000000000000000000000000000000000000000008152508152602001600060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001600260000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200185815250909190915060008201518160000190805190602001906101c49291906102a4565b5060208201518160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060408201518160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550606082015181600301555050505b50565b600060026001015490505b90565b81548183558181151161029f5760040281600402836000526020600020918201910161029e9190610324565b5b505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106102e557805160ff1916838001178555610313565b82800160010185558215610313579182015b828111156103125782518255916020019190600101906102f7565b5b50905061032091906103aa565b5090565b6103a791905b808211156103a357600060008201600061034491906103cf565b6001820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556002820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905560038201600090555060040161032a565b5090565b90565b6103cc91905b808211156103c85760008160009055506001016103b0565b5090565b90565b50805460018160011615610100020316600290046000825580601f106103f55750610414565b601f01602090049060005260206000209081019061041391906103aa565b5b505600a165627a7a72305820d453cb481a312519166e409e7248d76d8c2672458c08b9500945a4004a1b69020029");

    Contract testUpdate = new Contract();
    testUpdate.setGroupId(groupId);
    testUpdate.setContractId(200002);
    testUpdate.setContractName("Ooook");
    testUpdate.setContractPath("myPath");
    testUpdate.setContractSource(
        "cHJhZ21hIHNvbGlkaXR5IF4wLjQuMjsNCmNvbnRyYWN0IE9rew0KICAgIA0KICAgIHN0cnVjdCBBY2NvdW50ew0KICAgICAgICBhZGRyZXNzIGFjY291bnQ7DQogICAgICAgIHVpbnQgYmFsYW5jZTsNCiAgICB9DQogICAgDQogICAgc3RydWN0ICBUcmFuc2xvZyB7DQogICAgICAgIHN0cmluZyB0aW1lOw0KICAgICAgICBhZGRyZXNzIGZyb207DQogICAgICAgIGFkZHJlc3MgdG87DQogICAgICAgIHVpbnQgYW1vdW50Ow0KICAgIH0NCiAgICANCiAgICBBY2NvdW50IGZyb207DQogICAgQWNjb3VudCB0bzsNCiAgICANCiAgICBUcmFuc2xvZ1tdIGxvZzsNCg0KICAgIGZ1bmN0aW9uIE9rKCl7DQogICAgICAgIGZyb20uYWNjb3VudD0weDE7DQogICAgICAgIGZyb20uYmFsYW5jZT0xMDAwMDAwMDAwMDsNCiAgICAgICAgdG8uYWNjb3VudD0weDI7DQogICAgICAgIHRvLmJhbGFuY2U9MDsNCg0KICAgIH0NCiAgICBmdW5jdGlvbiBnZXQoKWNvbnN0YW50IHJldHVybnModWludCl7DQogICAgICAgIHJldHVybiB0by5iYWxhbmNlOw0KICAgIH0NCiAgICBmdW5jdGlvbiB0cmFucyh1aW50IG51bSl7DQogICAgCWZyb20uYmFsYW5jZT1mcm9tLmJhbGFuY2UtbnVtOw0KICAgIAl0by5iYWxhbmNlKz1udW07DQogICAgDQogICAgCWxvZy5wdXNoKFRyYW5zbG9nKCIyMDE3MDQxMyIsZnJvbS5hY2NvdW50LHRvLmFjY291bnQsbnVtKSk7DQogICAgfQ0KDQoNCg0KfQ==");
    testUpdate.setBytecodeBin(
        "6060604052341561000c57fe5b5b6001600060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506402540be4006000600101819055506002600260000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060006002600101819055505b5b610443806100c26000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806366c99139146100465780636d4ce63c14610066575bfe5b341561004e57fe5b610064600480803590602001909190505061008c565b005b341561006e57fe5b610076610264565b6040518082815260200191505060405180910390f35b806000600101540360006001018190555080600260010160008282540192505081905550600480548060010182816100c49190610272565b916000526020600020906004020160005b608060405190810160405280604060405190810160405280600881526020017f32303137303431330000000000000000000000000000000000000000000000008152508152602001600060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001600260000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200185815250909190915060008201518160000190805190602001906101c49291906102a4565b5060208201518160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060408201518160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550606082015181600301555050505b50565b600060026001015490505b90565b81548183558181151161029f5760040281600402836000526020600020918201910161029e9190610324565b5b505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106102e557805160ff1916838001178555610313565b82800160010185558215610313579182015b828111156103125782518255916020019190600101906102f7565b5b50905061032091906103aa565b5090565b6103a791905b808211156103a357600060008201600061034491906103cf565b6001820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556002820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905560038201600090555060040161032a565b5090565b90565b6103cc91905b808211156103c85760008160009055506001016103b0565b5090565b90565b50805460018160011615610100020316600290046000825580601f106103f55750610414565b601f01602090049060005260206000209081019061041391906103aa565b5b505600a165627a7a72305820d453cb481a312519166e409e7248d76d8c2672458c08b9500945a4004a1b69020029");
    testUpdate.setContractAbi(
        "[{\"constant\":false,\"inputs\":[{\"name\":\"num\",\"type\":\"uint256\"}],\"name\":\"trans\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"get\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"inputs\":[],\"payable\":false,\"type\":\"constructor\"}]");
    testUpdate.setContractBin(
        "60606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806366c99139146100465780636d4ce63c14610066575bfe5b341561004e57fe5b610064600480803590602001909190505061008c565b005b341561006e57fe5b610076610264565b6040518082815260200191505060405180910390f35b806000600101540360006001018190555080600260010160008282540192505081905550600480548060010182816100c49190610272565b916000526020600020906004020160005b608060405190810160405280604060405190810160405280600881526020017f32303137303431330000000000000000000000000000000000000000000000008152508152602001600060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001600260000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200185815250909190915060008201518160000190805190602001906101c49291906102a4565b5060208201518160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060408201518160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550606082015181600301555050505b50565b600060026001015490505b90565b81548183558181151161029f5760040281600402836000526020600020918201910161029e9190610324565b5b505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106102e557805160ff1916838001178555610313565b82800160010185558215610313579182015b828111156103125782518255916020019190600101906102f7565b5b50905061032091906103aa565b5090565b6103a791905b808211156103a357600060008201600061034491906103cf565b6001820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556002820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905560038201600090555060040161032a565b5090565b90565b6103cc91905b808211156103c85760008160009055506001016103b0565b5090565b90565b50805460018160011615610100020316600290046000825580601f106103f55750610414565b601f01602090049060005260206000209081019061041391906103aa565b5b505600a165627a7a72305820d453cb481a312519166e409e7248d76d8c2672458c08b9500945a4004a1b69020029");

    ResultActions resultActions = mockMvc.perform(MockMvcRequestBuilders.post("/contract/save").
        content(JsonTools.toJSONString(testUpdate)).
        contentType(MediaType.APPLICATION_JSON_UTF8)
    );
    resultActions.
        andExpect(MockMvcResultMatchers.status().isOk()).
        andDo(MockMvcResultHandlers.print());
    System.out
        .println("response:" + resultActions.andReturn().getResponse().getContentAsString());
}
 
Example #18
Source File: ServerGroupControllerTest.java    From das with Apache License 2.0 5 votes vote down vote up
@Test
public void sync() throws Exception {
    mockMvc.perform(MockMvcRequestBuilders.post("/serverGroup/sync")
            .contentType(MediaType.APPLICATION_JSON_UTF8)
            .param("id", "1")
            .accept(MediaType.APPLICATION_JSON_UTF8))
            .andExpect(MockMvcResultMatchers.status().isOk())
            .andDo(MockMvcResultHandlers.print());
}
 
Example #19
Source File: GroupControllerTest.java    From das with Apache License 2.0 5 votes vote down vote up
@Test
public void tree() throws Exception {
    mockMvc.perform(MockMvcRequestBuilders.get("/group/tree")
            .contentType(MediaType.APPLICATION_JSON_UTF8)
            .accept(MediaType.APPLICATION_JSON_UTF8))
            .andExpect(MockMvcResultMatchers.status().isOk())
            .andDo(MockMvcResultHandlers.print());
}
 
Example #20
Source File: UserControllerTests.java    From spring-boot-study with MIT License 5 votes vote down vote up
/**
 * 新增单个用户信息 /users/ POST
 * 注意 addUser 使用了 @RequestBody 方法,对应使用 .contentType(MediaType.APPLICATION_JSON).content(json 字符串)
 * */
@Test
public void addUser() throws  Exception{
    mockMvc.perform(MockMvcRequestBuilders.post("/api/user/users")
            .contentType(MediaType.APPLICATION_JSON).content("{ \"userId\": 3,\"userName\": \"tom\"}"))
            .andExpect(MockMvcResultMatchers.status().isCreated())
            .andDo(MockMvcResultHandlers.print())
            .andReturn();
}
 
Example #21
Source File: ServerConfigControllerTest.java    From das with Apache License 2.0 5 votes vote down vote up
@Test
public void list() throws Exception {
    Paging<ServerConfig> paging = new Paging<>();
    paging.setData(new ServerConfig());
    String requestJson = JSONObject.toJSONString(paging);
    mockMvc.perform(MockMvcRequestBuilders.post("/serverConfig/list")
            .contentType(MediaType.APPLICATION_JSON_UTF8)
            .content(requestJson)
            .accept(MediaType.APPLICATION_JSON_UTF8))
            .andExpect(MockMvcResultMatchers.status().isOk())
            .andDo(MockMvcResultHandlers.print());
}
 
Example #22
Source File: PublicStrategyControllerTest.java    From das with Apache License 2.0 5 votes vote down vote up
@Test
public void delete() throws Exception {
    mockMvc.perform(MockMvcRequestBuilders.delete("/publicStrategy/delete")
            .contentType(MediaType.APPLICATION_JSON_UTF8)
            .content(requestJson)
            .accept(MediaType.APPLICATION_JSON_UTF8))
            .andExpect(MockMvcResultMatchers.status().isOk())
            .andDo(MockMvcResultHandlers.print());
}
 
Example #23
Source File: GrayGroupControllerTest.java    From AthenaServing with Apache License 2.0 5 votes vote down vote up
/**
 * 查询灰度组明细
 *
 * @throws Exception
 */
@Test
public void test_gray_group_3_detail() throws Exception {
    String result = this.mockMvc.perform(MockMvcRequestBuilders.get("/api/v1/gray/detail")
            .param("id", "3781019715757932544")
            .contentType(MediaType.APPLICATION_JSON)
            .session((MockHttpSession) Utils.getLoginSession(this.mockMvc))
            .accept(MediaType.APPLICATION_JSON))
            .andExpect(MockMvcResultMatchers.status().isOk())
            .andDo(MockMvcResultHandlers.print())
            .andReturn().getResponse().getContentAsString();
    Utils.assertResult(result);
}
 
Example #24
Source File: GroupMemberControllerTest.java    From das with Apache License 2.0 5 votes vote down vote up
@Test
public void getGroupUsers() throws Exception {
    Paging<DasGroup> paging = new Paging<>();
    paging.setData(new DasGroup());
    String requestJson = JSONObject.toJSONString(paging);
    mockMvc.perform(MockMvcRequestBuilders.post("/member/list")
            .contentType(MediaType.APPLICATION_JSON_UTF8)
            .content(requestJson)
            .accept(MediaType.APPLICATION_JSON_UTF8))
            .andExpect(MockMvcResultMatchers.status().isOk())
            .andDo(MockMvcResultHandlers.print());
}
 
Example #25
Source File: GroupControllerTest.java    From das with Apache License 2.0 5 votes vote down vote up
@Test
public void getAllGroup() throws Exception {
    Paging<DasGroup> paging = new Paging<>();
    paging.setData(new DasGroup());
    String requestJson = JSONObject.toJSONString(paging);
    mockMvc.perform(MockMvcRequestBuilders.post("/group/list")
            .contentType(MediaType.APPLICATION_JSON_UTF8)
            .content(requestJson)
            .accept(MediaType.APPLICATION_JSON_UTF8))
            .andExpect(MockMvcResultMatchers.status().isOk())
            .andDo(MockMvcResultHandlers.print());
}
 
Example #26
Source File: TableEntityControllerTest.java    From das with Apache License 2.0 5 votes vote down vote up
@Test
public void update() throws Exception {
    mockMvc.perform(MockMvcRequestBuilders.put("/tableEntity/update")
            .contentType(MediaType.APPLICATION_JSON_UTF8)
            .content(requestJson)
            .accept(MediaType.APPLICATION_JSON_UTF8))
            .andExpect(MockMvcResultMatchers.status().isOk())
            .andDo(MockMvcResultHandlers.print());
}
 
Example #27
Source File: CodeControllerTest.java    From das with Apache License 2.0 5 votes vote down vote up
@Test
public void getFileContent() throws Exception {
    mockMvc.perform(MockMvcRequestBuilders.get("/code/content")
            .contentType(MediaType.APPLICATION_JSON_UTF8)
            .param("projectId", "1")
            .param("name", "tom")
            .accept(MediaType.APPLICATION_JSON_UTF8))
            .andExpect(MockMvcResultMatchers.status().isOk())
            .andDo(MockMvcResultHandlers.print());
}
 
Example #28
Source File: LogParseControllerTest.java    From WeBASE-Front with Apache License 2.0 5 votes vote down vote up
@Test
public void testDeleteData() throws Exception {
    
    ResultActions resultActions = mockMvc.perform(MockMvcRequestBuilders
            .delete("/charging/deleteData?type=2&keepEndDate=2020-03-26T22:45:55&groupId="
                    + groupId)
            .contentType(MediaType.APPLICATION_JSON));
    resultActions.andExpect(MockMvcResultMatchers.status().isOk())
    .andDo(MockMvcResultHandlers.print());
}
 
Example #29
Source File: ServerGroupControllerTest.java    From das with Apache License 2.0 5 votes vote down vote up
@Test
public void serversNoGroup() throws Exception {
    mockMvc.perform(MockMvcRequestBuilders.post("/serverGroup/serversNoGroup")
            .contentType(MediaType.APPLICATION_JSON_UTF8)
            .param("appGroupId", "1")
            .accept(MediaType.APPLICATION_JSON_UTF8))
            .andExpect(MockMvcResultMatchers.status().isOk())
            .andDo(MockMvcResultHandlers.print());
}
 
Example #30
Source File: DatabaseSetControllerTest.java    From das with Apache License 2.0 5 votes vote down vote up
@Test
public void config() throws Exception {
    mockMvc.perform(MockMvcRequestBuilders.get("/groupdbset/config")
            .contentType(MediaType.APPLICATION_JSON_UTF8)
            .param("appId", "123456")
            .accept(MediaType.APPLICATION_JSON_UTF8))
            .andExpect(MockMvcResultMatchers.status().isOk())
            .andDo(MockMvcResultHandlers.print());
}