Here are the examples of the java api org.springframework.http.HttpMethod.POST taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1307 Examples
19
View Source File : BaseControllerTest.java
License : Apache License 2.0
Project Creator : Zoctan
License : Apache License 2.0
Project Creator : Zoctan
protected Result post(final String targetUrl, final Object args, final String token) throws Exception {
return this.execute(HttpMethod.POST, targetUrl, args, token);
}
19
View Source File : WebSecurityConfig.java
License : Apache License 2.0
Project Creator : Zoctan
License : Apache License 2.0
Project Creator : Zoctan
@Override
protected void configure(final HttpSecurity http) throws Exception {
http.headers().cacheControl().and().and().cors().disable().csrf().disable().sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and().exceptionHandling().authenticationEntryPoint(this.myAuthenticationEntryPoint).and().addFilterBefore(this.authenticationFilter, UsernamePreplacedwordAuthenticationFilter.clreplaced).authorizeRequests().antMatchers("/swagger-ui.html**", "/swagger-resources**", "/webjars/**", "/v2/**").permitAll().antMatchers(HttpMethod.POST, "/account", "/account/token").permitAll().antMatchers(HttpMethod.DELETE, "/upload/image/**", "/upload/video/**").permitAll().antMatchers(HttpMethod.PUT, "/wechat/token").permitAll().anyRequest().authenticated();
}
19
View Source File : WebSecurityConfig.java
License : Apache License 2.0
Project Creator : Zoctan
License : Apache License 2.0
Project Creator : Zoctan
@Override
protected void configure(final HttpSecurity http) throws Exception {
http.headers().cacheControl().and().and().cors().disable().csrf().disable().sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and().exceptionHandling().authenticationEntryPoint(this.myAuthenticationEntryPoint).and().addFilterBefore(this.authenticationFilter, UsernamePreplacedwordAuthenticationFilter.clreplaced).authorizeRequests().antMatchers(ANONYMOUS_LIST).permitAll().antMatchers(HttpMethod.POST, "/account", "/account/token").permitAll().antMatchers(HttpMethod.OPTIONS).permitAll().anyRequest().authenticated();
}
19
View Source File : RestDesformUtil.java
License : Apache License 2.0
Project Creator : zhangdaiscott
License : Apache License 2.0
Project Creator : zhangdaiscott
/**
* 新增数据
*
* @param desformCode
* @param formData
* @param token
* @return
*/
public static Result addOne(String desformCode, JSONObject formData, String token) {
return addOrEditOne(desformCode, formData, token, HttpMethod.POST);
}
19
View Source File : SysUserTest.java
License : Apache License 2.0
Project Creator : zhangdaiscott
License : Apache License 2.0
Project Creator : zhangdaiscott
/**
* 测试用例:新增
*/
@Test
public void testAdd() {
// 用户Token
String token = this.getToken();
// 请求地址
String url = BASE_URL + "add";
// 请求 Header (用于传递Token)
HttpHeaders headers = this.getHeaders(token);
// 请求方式是 POST 代表提交新增数据
HttpMethod method = HttpMethod.POST;
System.out.println("请求地址:" + url);
System.out.println("请求方式:" + method);
System.out.println("请求Token:" + token);
JSONObject params = new JSONObject();
params.put("username", "wangwuTest");
params.put("preplacedword", "123456");
params.put("confirmpreplacedword", "123456");
params.put("realname", "单元测试");
params.put("activitiSync", "1");
params.put("userIdenreplacedy", "1");
params.put("workNo", "0025");
System.out.println("请求参数:" + params.toJSONString());
// 利用 RestUtil 请求该url
ResponseEnreplacedy<JSONObject> result = RestUtil.request(url, method, headers, null, params, JSONObject.clreplaced);
if (result != null && result.getBody() != null) {
System.out.println("返回结果:" + result.getBody().toJSONString());
} else {
System.out.println("查询失败");
}
}
19
View Source File : OnlineApiTest.java
License : Apache License 2.0
Project Creator : zhangdaiscott
License : Apache License 2.0
Project Creator : zhangdaiscott
/**
* 测试用例:新增
*/
@Test
public void testAdd() {
// 用户Token
String token = this.getToken();
// 请求地址
String url = BASE_URL + "form/" + ONLINE_CODE;
// 请求 Header (用于传递Token)
HttpHeaders headers = this.getHeaders(token);
// 请求方式是 POST 代表提交新增数据
HttpMethod method = HttpMethod.POST;
System.out.println("请求地址:" + url);
System.out.println("请求方式:" + method);
System.out.println("请求Token:" + token);
JSONObject params = new JSONObject();
params.put("name", "张三");
params.put("sex", "1");
params.put("age", 15);
params.put("descc", "<p>富文本编辑</p>");
System.out.println("请求参数:" + params.toJSONString());
// 利用 RestUtil 请求该url
ResponseEnreplacedy<JSONObject> result = RestUtil.request(url, method, headers, null, params, JSONObject.clreplaced);
if (result != null && result.getBody() != null) {
System.out.println("返回结果:" + result.getBody().toJSONString());
} else {
System.out.println("查询失败");
}
}
19
View Source File : DesformApiTest.java
License : Apache License 2.0
Project Creator : zhangdaiscott
License : Apache License 2.0
Project Creator : zhangdaiscott
/**
* 测试用例:新增
*/
@Test
public void testAdd() {
// 用户Token
String token = this.getToken();
// 请求地址
String url = BASE_URL + DESFORM_CODE;
// 请求 Header (用于传递Token)
HttpHeaders headers = this.getHeaders(token);
// 请求方式是 POST 代表提交新增数据
HttpMethod method = HttpMethod.POST;
System.out.println("请求地址:" + url);
System.out.println("请求方式:" + method);
System.out.println("请求Token:" + token);
JSONObject params = new JSONObject();
params.put("name", "张三");
params.put("sex", "1");
params.put("begin_time", "2019-12-27");
params.put("remarks", "生病了");
System.out.println("请求参数:" + params.toJSONString());
// 利用 RestUtil 请求该url
ResponseEnreplacedy<JSONObject> result = RestUtil.request(url, method, headers, null, params, JSONObject.clreplaced);
if (result != null && result.getBody() != null) {
System.out.println("返回结果:" + result.getBody().toJSONString());
} else {
System.out.println("查询失败");
}
}
19
View Source File : SpringConfig.java
License : Apache License 2.0
Project Creator : yujunhao8831
License : Apache License 2.0
Project Creator : yujunhao8831
/**
* cors跨域处理
*
* @param registry
*/
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedMethods(HttpMethod.HEAD.name(), HttpMethod.GET.name(), HttpMethod.POST.name(), HttpMethod.PUT.name(), HttpMethod.DELETE.name(), HttpMethod.OPTIONS.name(), HttpMethod.PATCH.name(), HttpMethod.TRACE.name()).allowedOrigins("*");
}
19
View Source File : DashboardRestConsumer.java
License : Apache License 2.0
Project Creator : yugabyte
License : Apache License 2.0
Project Creator : yugabyte
public String getCart() {
String restURL = restUrlBase + "shoppingCart";
ResponseEnreplacedy<String> rateResponse = restTemplate.exchange(restURL, HttpMethod.POST, null, new ParameterizedTypeReference<String>() {
});
String getCartJsonResponse = rateResponse.getBody();
return getCartJsonResponse;
}
19
View Source File : ControllerEndpointHandlerMappingTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
@Test
public void mappingNarrowedToMethod() throws Exception {
ExposableControllerEndpoint first = firstEndpoint();
ControllerEndpointHandlerMapping mapping = createMapping("actuator", first);
replacedertThatExceptionOfType(MethodNotAllowedException.clreplaced).isThrownBy(() -> getHandler(mapping, HttpMethod.POST, "/actuator/first"));
}
19
View Source File : HttpRequestTemplate.java
License : Apache License 2.0
Project Creator : yin5980280
License : Apache License 2.0
Project Creator : yin5980280
public String postXml(String url, Object request) {
String xml;
if (request instanceof String) {
xml = (String) request;
} else {
xml = XmlXStreamUtils.object2Xml(request);
}
HttpHeaders headers = this.getHeaders(MEDIA_TYPE_XML);
HttpEnreplacedy<String> httpEnreplacedy = new HttpEnreplacedy<>(xml, headers);
return this.httpExchange(url, HttpMethod.POST, httpEnreplacedy);
}
19
View Source File : HttpRequestTemplate.java
License : Apache License 2.0
Project Creator : yin5980280
License : Apache License 2.0
Project Creator : yin5980280
public String postJson(String url, String json) throws RestClientException {
return this.exchange(url, HttpMethod.POST, json);
}
19
View Source File : TenantConfigRepositoryUnitTest.java
License : Apache License 2.0
Project Creator : xm-online
License : Apache License 2.0
Project Creator : xm-online
@Test
public void createConfigs() {
List<Configuration> configs = new LinkedList<>();
configs.add(new Configuration("path/to/file1.txt", "content1"));
configs.add(new Configuration("path/to/file2.txt", "content2"));
repository.createConfigs("tenant1", configs);
MultiValueMap<String, Object> expectedMap = new LinkedMultiValueMap<>();
expectedMap.add("files", new NamedByteArrayResource("content1".getBytes(), "/config/tenants/TENANT1/app1/path/to/file1.txt"));
expectedMap.add("files", new NamedByteArrayResource("content2".getBytes(), "/config/tenants/TENANT1/app1/path/to/file2.txt"));
HttpEnreplacedy<MultiValueMap> expected = createHttpEnreplacedy(expectedMap, MediaType.MULTIPART_FORM_DATA);
verify(restTemplate).exchange(eq(CONFIG_URL + "/api/config"), eq(HttpMethod.POST), refEq(expected), eq(Void.clreplaced));
}
19
View Source File : TenantConfigRepositoryUnitTest.java
License : Apache License 2.0
Project Creator : xm-online
License : Apache License 2.0
Project Creator : xm-online
@Test
public void createConfig() {
repository.createConfig("tenant1", "/path/to/file.txt", "content");
verify(restTemplate).exchange(eq(CONFIG_URL + "/api/config/tenants/{tenantName}/app1/path/to/file.txt"), eq(HttpMethod.POST), refEq(createHttpEnreplacedyWithContent()), eq(Void.clreplaced), eq("TENANT1"));
}
19
View Source File : TenantConfigRepositoryUnitTest.java
License : Apache License 2.0
Project Creator : xm-online
License : Apache License 2.0
Project Creator : xm-online
@Test
public void createConfigsFullPath() {
List<Configuration> configs = new LinkedList<>();
configs.add(new Configuration("/config/tenants/{tenantName}/app1/path/to/file1.txt", "content1"));
configs.add(new Configuration("/config/tenants/TENANT2/app1/path/to/file2.txt", "content2"));
repository.createConfigsFullPath("tenant1", configs);
MultiValueMap<String, Object> valueMap = new LinkedMultiValueMap<>();
valueMap.add("files", new NamedByteArrayResource("content1".getBytes(), "/config/tenants/TENANT1/app1/path/to/file1.txt"));
valueMap.add("files", new NamedByteArrayResource("content2".getBytes(), "/config/tenants/TENANT2/app1/path/to/file2.txt"));
HttpEnreplacedy<MultiValueMap> enreplacedy = createHttpEnreplacedy(valueMap, MediaType.MULTIPART_FORM_DATA);
verify(restTemplate).exchange(eq(CONFIG_URL + "/api/config"), eq(HttpMethod.POST), refEq(enreplacedy), eq(Void.clreplaced));
}
19
View Source File : TenantConfigRepositoryUnitTest.java
License : Apache License 2.0
Project Creator : xm-online
License : Apache License 2.0
Project Creator : xm-online
@Test
public void createConfigFullPath() {
repository.createConfigFullPath("tenant1", "/api/config/tenants/{tenantName}/app1/path/to/file.txt", "content");
verify(restTemplate).exchange(eq(CONFIG_URL + "/api/config/tenants/{tenantName}/app1/path/to/file.txt"), eq(HttpMethod.POST), refEq(createHttpEnreplacedyWithContent()), eq(Void.clreplaced), eq("TENANT1"));
}
19
View Source File : TenantConfigRepository.java
License : Apache License 2.0
Project Creator : xm-online
License : Apache License 2.0
Project Creator : xm-online
private void exchangePost(final String tenantName, final String path, final HttpEnreplacedy<?> enreplacedy) {
exchange(path, HttpMethod.POST, enreplacedy, tenantName);
}
19
View Source File : TenantConfigRepository.java
License : Apache License 2.0
Project Creator : xm-online
License : Apache License 2.0
Project Creator : xm-online
private void exchangePostMultipart(final List<NamedByteArrayResource> resources) {
resources.forEach(namedByteArrayResource -> replacedertPathInsideTenant(namedByteArrayResource.getFilename()));
MultiValueMap<String, Object> body = new LinkedMultiValueMap<>();
body.addAll(MULTIPART_FILE_NAME, resources);
HttpEnreplacedy<MultiValueMap<String, Object>> enreplacedy = new HttpEnreplacedy<>(body, createMultipartAuthHeaders());
restTemplate.exchange(xmConfigUrl + PATH_API + PATH_CONFIG, HttpMethod.POST, enreplacedy, Void.clreplaced);
}
19
View Source File : SecurityConfig.java
License : MIT License
Project Creator : xkcoding
License : MIT License
Project Creator : xkcoding
/**
* 放行所有不需要登录就可以访问的请求,参见 AuthController
* 也可以在 {@link #configure(HttpSecurity)} 中配置
* {@code http.authorizeRequests().antMatchers("/api/auth/**").permitAll()}
*/
@Override
public void configure(WebSecurity web) {
WebSecurity and = web.ignoring().and();
// 忽略 GET
customConfig.getIgnores().getGet().forEach(url -> and.ignoring().antMatchers(HttpMethod.GET, url));
// 忽略 POST
customConfig.getIgnores().getPost().forEach(url -> and.ignoring().antMatchers(HttpMethod.POST, url));
// 忽略 DELETE
customConfig.getIgnores().getDelete().forEach(url -> and.ignoring().antMatchers(HttpMethod.DELETE, url));
// 忽略 PUT
customConfig.getIgnores().getPut().forEach(url -> and.ignoring().antMatchers(HttpMethod.PUT, url));
// 忽略 HEAD
customConfig.getIgnores().getHead().forEach(url -> and.ignoring().antMatchers(HttpMethod.HEAD, url));
// 忽略 PATCH
customConfig.getIgnores().getPatch().forEach(url -> and.ignoring().antMatchers(HttpMethod.PATCH, url));
// 忽略 OPTIONS
customConfig.getIgnores().getOptions().forEach(url -> and.ignoring().antMatchers(HttpMethod.OPTIONS, url));
// 忽略 TRACE
customConfig.getIgnores().getTrace().forEach(url -> and.ignoring().antMatchers(HttpMethod.TRACE, url));
// 按照请求格式忽略
customConfig.getIgnores().getPattern().forEach(url -> and.ignoring().antMatchers(url));
}
19
View Source File : WebSecurityConfig.java
License : MIT License
Project Creator : wx-chevalier
License : MIT License
Project Creator : wx-chevalier
@Override
protected void configure(HttpSecurity http) throws Exception {
if (h2ConsoleEnabled)
http.authorizeRequests().antMatchers("/h2-console", "/h2-console/**").permitAll().and().headers().frameOptions().sameOrigin();
http.csrf().disable().cors().and().exceptionHandling().authenticationEntryPoint(new HttpStatusEntryPoint(HttpStatus.UNAUTHORIZED)).and().sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and().authorizeRequests().antMatchers(HttpMethod.OPTIONS).permitAll().antMatchers(HttpMethod.GET, "/articles/feed").authenticated().antMatchers(HttpMethod.POST, "/users", "/users/login").permitAll().antMatchers(HttpMethod.GET, "/articles/**", "/profiles/**", "/tags").permitAll().anyRequest().authenticated();
http.addFilterBefore(jwtTokenFilter(), UsernamePreplacedwordAuthenticationFilter.clreplaced);
}
19
View Source File : WebSecurityConfigurer.java
License : MIT License
Project Creator : wx-chevalier
License : MIT License
Project Creator : wx-chevalier
@Override
public void configure(WebSecurity web) throws Exception {
IgnoredRequestConfigurer ignoring = web.ignoring();
// swagger
ignoring.antMatchers(HttpMethod.GET, "/v2/api-docs", "/swagger-resources/**", "/service-worker.js", "/doc.html", "/swagger-ui.html**", "/webjars/**", "favicon.ico");
ignoring.antMatchers("/actuator/**");
ignoring.antMatchers(HttpMethod.POST, "/callback/**");
}
19
View Source File : RootlessExpressionServiceMocker.java
License : Apache License 2.0
Project Creator : WeBankPartners
License : Apache License 2.0
Project Creator : WeBankPartners
public void mockOneLinkWithOpByOnlyExpressionServer(MockRestServiceServer server) {
// mockOneLinkWithOpByOnlyExpression
server.expect(ExpectedCount.manyTimes(), requestTo(String.format("http://%s/wecmdb/enreplacedies/subsys/query", this.gatewayUrl))).andExpect(method(HttpMethod.POST)).andRespond(withSuccess("{\n" + " \"status\": \"OK\",\n" + " \"message\": \"Success\",\n" + " \"data\": [\n" + " {\n" + " \"biz_key\": null,\n" + " \"subsys_design\": \"0002_0000000010\",\n" + " \"key_name\": \"ECIF-CORE_PRD\",\n" + " \"code\": \"CORE\",\n" + " \"orchestration\": null,\n" + " \"manager\": \"nertonsong\",\n" + " \"r_guid\": \"0007_0000000001\",\n" + " \"description\": \"ECIF-CORE PRD\",\n" + " \"id\": \"0007_0000000001\",\n" + " \"state\": 37,\n" + " \"env\": 111,\n" + " \"fixed_date\": \"2019-07-24 16:30:17\"\n" + " }\n" + " ]\n" + "}", MediaType.APPLICATION_JSON));
server.expect(ExpectedCount.manyTimes(), requestTo(String.format("http://%s/wecmdb/enreplacedies/unit/query", this.gatewayUrl))).andExpect(method(HttpMethod.POST)).andRespond(withSuccess("{\n" + " \"status\": \"OK\",\n" + " \"message\": \"Success\",\n" + " \"data\": [\n" + " {\n" + " \"biz_key\": null,\n" + " \"code\": \"APP\",\n" + " \"orchestration\": null,\n" + " \"package\": \"\",\n" + " \"r_guid\": \"0008_0000000001\",\n" + " \"description\": \"\",\n" + " \"resource_set\": \"0020_0000000001\",\n" + " \"key_name\": \"ECIF-CORE_PRD-APP\",\n" + " \"instance_num\": 1,\n" + " \"subsys\": \"0007_0000000001\",\n" + " \"id\": \"0008_0000000001\",\n" + " \"state\": 37,\n" + " \"fixed_date\": \"2019-07-24 16:30:35\",\n" + " \"unit_design\": \"0003_0000000006\"\n" + " },\n" + " {\n" + " \"biz_key\": \"\",\n" + " \"code\": \"DB\",\n" + " \"orchestration\": 231,\n" + " \"package\": \"0011_0000000010\",\n" + " \"r_guid\": \"0008_0000000007\",\n" + " \"description\": \"aa\",\n" + " \"resource_set\": \"0020_0000000001\",\n" + " \"key_name\": \"ECIF-CORE_PRD-DB\",\n" + " \"instance_num\": 1,\n" + " \"subsys\": \"0007_0000000001\",\n" + " \"id\": \"0008_0000000007\",\n" + " \"state\": 37,\n" + " \"fixed_date\": \"\",\n" + " \"unit_design\": \"0003_0000000007\"\n" + " }\n" + " ]\n" + "}", MediaType.APPLICATION_JSON));
}
19
View Source File : RootlessExpressionServiceMocker.java
License : Apache License 2.0
Project Creator : WeBankPartners
License : Apache License 2.0
Project Creator : WeBankPartners
public void mockOneLinkWithOpToOnlyExpressionServer(MockRestServiceServer server) {
// mockOneLinkWithOpToOnlyExpression
server.expect(ExpectedCount.manyTimes(), requestTo(String.format("http://%s/wecmdb/enreplacedies/subsys_design/query", this.gatewayUrl))).andExpect(method(HttpMethod.POST)).andRespond(withSuccess("{\n" + " \"status\": \"OK\",\n" + " \"message\": \"Success\",\n" + " \"data\": [\n" + " {\n" + " \"biz_key\": null,\n" + " \"business_group\": 105,\n" + " \"code\": \"ADMBATCH\",\n" + " \"orchestration\": null,\n" + " \"r_guid\": \"0002_0000000006\",\n" + " \"description\": \"ADM Batch Subsystem\",\n" + " \"dcn_design_type\": 132,\n" + " \"key_name\": \"EDP-ADMBATCH\",\n" + " \"name\": \"ADM Batch Subsystem\",\n" + " \"id\": \"0002_0000000006\",\n" + " \"state\": 34,\n" + " \"fixed_date\": \"2019-07-24 16:28:25\",\n" + " \"system_design\": \"0001_0000000001\"\n" + " }\n" + " ]\n" + "}", MediaType.APPLICATION_JSON));
server.expect(ExpectedCount.manyTimes(), requestTo(String.format("http://%s/wecmdb/enreplacedies/system_design/query", this.gatewayUrl))).andExpect(method(HttpMethod.POST)).andRespond(withSuccess("{\n" + " \"status\": \"OK\",\n" + " \"message\": \"Success\",\n" + " \"data\": [\n" + " {\n" + " \"biz_key\": null,\n" + " \"key_name\": \"EDP\",\n" + " \"business_group\": 105,\n" + " \"code\": \"EDP\",\n" + " \"orchestration\": null,\n" + " \"r_guid\": \"0001_0000000001\",\n" + " \"name\": \"Deposit Micro Core System\",\n" + " \"description\": \"Deposit Micro Core System\",\n" + " \"id\": \"0001_0000000001\",\n" + " \"state\": 34,\n" + " \"fixed_date\": \"2019-07-24 17:28:15\"\n" + " }\n" + " ]\n" + "}", MediaType.APPLICATION_JSON));
}
19
View Source File : RootlessExpressionServiceMocker.java
License : Apache License 2.0
Project Creator : WeBankPartners
License : Apache License 2.0
Project Creator : WeBankPartners
public void mockMultipleLinksWithOpToOnlyExpressionServer(MockRestServiceServer server) {
// first expression
server.expect(ExpectedCount.manyTimes(), requestTo(String.format("http://%s/wecmdb/enreplacedies/subsys/query", this.gatewayUrl))).andExpect(method(HttpMethod.POST)).andRespond(withSuccess("{\n" + " \"status\": \"OK\",\n" + " \"message\": \"Success\",\n" + " \"data\": [\n" + " {\n" + " \"biz_key\": null,\n" + " \"subsys_design\": \"0002_0000000010\",\n" + " \"key_name\": \"ECIF-CORE_PRD\",\n" + " \"code\": \"CORE\",\n" + " \"orchestration\": null,\n" + " \"manager\": \"nertonsong\",\n" + " \"r_guid\": \"0007_0000000001\",\n" + " \"description\": \"ECIF-CORE PRD\",\n" + " \"id\": \"0007_0000000001\",\n" + " \"state\": 37,\n" + " \"env\": 111,\n" + " \"fixed_date\": \"2019-07-24 16:30:17\"\n" + " }\n" + " ]\n" + "}", MediaType.APPLICATION_JSON));
server.expect(ExpectedCount.manyTimes(), requestTo(String.format("http://%s/wecmdb/enreplacedies/subsys_design/query", this.gatewayUrl))).andExpect(method(HttpMethod.POST)).andRespond(withSuccess("{\n" + " \"status\": \"OK\",\n" + " \"message\": \"Success\",\n" + " \"data\": [\n" + " {\n" + " \"biz_key\": null,\n" + " \"business_group\": 105,\n" + " \"code\": \"CORE\",\n" + " \"orchestration\": null,\n" + " \"r_guid\": \"0002_0000000010\",\n" + " \"description\": \"CRM Core Subsystem\",\n" + " \"dcn_design_type\": 135,\n" + " \"key_name\": \"ECIF-CORE\",\n" + " \"name\": \"CRM Core Subsystem\",\n" + " \"id\": \"0002_0000000010\",\n" + " \"state\": 34,\n" + " \"fixed_date\": \"2019-07-24 16:28:27\",\n" + " \"system_design\": \"0001_0000000003\"\n" + " }\n" + " ]\n" + "}", MediaType.APPLICATION_JSON));
server.expect(ExpectedCount.manyTimes(), requestTo(String.format("http://%s/wecmdb/enreplacedies/system_design/query", this.gatewayUrl))).andExpect(method(HttpMethod.POST)).andRespond(withSuccess("{\n" + " \"status\": \"OK\",\n" + " \"message\": \"Success\",\n" + " \"data\": [\n" + " {\n" + " \"biz_key\": null,\n" + " \"key_name\": \"ECIF\",\n" + " \"business_group\": 105,\n" + " \"code\": \"ECIF\",\n" + " \"orchestration\": null,\n" + " \"r_guid\": \"0001_0000000003\",\n" + " \"name\": \"CRM System\",\n" + " \"description\": \"CRM System\",\n" + " \"id\": \"0001_0000000003\",\n" + " \"state\": 34,\n" + " \"fixed_date\": \"2019-07-24 17:28:17\"\n" + " }\n" + " ]\n" + "}", MediaType.APPLICATION_JSON));
}
19
View Source File : AbstractAuthServerRestClient.java
License : Apache License 2.0
Project Creator : WeBankPartners
License : Apache License 2.0
Project Creator : WeBankPartners
protected <T> T postForObject(RestTemplate restTemplate, String path, Object request, ParameterizedTypeReference<AuthServerRestResponseDto<T>> responseType, Object... uriVariables) throws AuthServerClientException {
String requestUri = buildFullUriString(path, clientProperties.getHttpScheme(), clientProperties.getHost(), clientProperties.getPort());
URI expandedUri = restTemplate.getUriTemplateHandler().expand(requestUri, uriVariables);
ResponseEnreplacedy<AuthServerRestResponseDto<T>> responseEnreplacedy = restTemplate.exchange(expandedUri, HttpMethod.POST, buildRequestEnreplacedy(request), responseType);
AuthServerRestResponseDto<T> responseDto = responseEnreplacedy.getBody();
String status = responseDto.getStatus();
if (!AuthServerRestResponseDto.STATUS_OK.equalsIgnoreCase(status)) {
getLogger().warn("rest service invocation failed,status={},message={}", responseDto.getStatus(), responseDto.getMessage());
throw new AuthServerClientException(responseDto.getStatus(), responseDto.getMessage());
}
return responseDto.getData();
}
19
View Source File : FrontRestTools.java
License : Apache License 2.0
Project Creator : WeBankFinTech
License : Apache License 2.0
Project Creator : WeBankFinTech
/**
* post from front for enreplacedy.
*/
public <T> T postForEnreplacedy(Integer groupId, String uri, Object params, Clreplaced<T> clazz) {
T response = restTemplateExchange(groupId, uri, HttpMethod.POST, params, clazz);
if (response == null) {
log.error("postForEnreplacedy response is null!");
throw new NodeMgrException(ConstantCode.REQUEST_FRONT_FAIL);
}
return response;
}
19
View Source File : FrontInterfaceService.java
License : Apache License 2.0
Project Creator : WeBankFinTech
License : Apache License 2.0
Project Creator : WeBankFinTech
/**
* generate group.
*/
public GroupHandleResult generateGroup(String frontIp, Integer frontPort, GenerateGroupInfo param) {
log.debug("start generateGroup frontIp:{} frontPort:{} param:{}", frontIp, frontPort, JsonTools.toJSONString(param));
Integer groupId = Integer.MAX_VALUE;
GroupHandleResult groupHandleResult = requestSpecificFront(groupId, frontIp, frontPort, HttpMethod.POST, FrontRestTools.URI_GENERATE_GROUP, param, GroupHandleResult.clreplaced);
log.debug("end generateGroup");
return groupHandleResult;
}
19
View Source File : FrontRestTools.java
License : Apache License 2.0
Project Creator : WeBankFinTech
License : Apache License 2.0
Project Creator : WeBankFinTech
/**
* post from front for enreplacedy.
*/
public <T> T postForEnreplacedy(Integer chainId, Integer groupId, String uri, Object params, Clreplaced<T> clazz) {
return restTemplateExchange(chainId, groupId, uri, HttpMethod.POST, params, clazz);
}
19
View Source File : FrontInterfaceService.java
License : Apache License 2.0
Project Creator : WeBankFinTech
License : Apache License 2.0
Project Creator : WeBankFinTech
/**
* post to specific front.
*/
public <T> T postToSpecificFront(Integer groupId, String frontIp, Integer frontPort, String uri, Object param, Clreplaced<T> clazz) {
log.debug("start postToSpecificFront. groupId:{} frontIp:{} frontPort:{} uri:{}", groupId, frontIp, frontPort.toString(), uri);
return requestSpecificFront(groupId, frontIp, frontPort, HttpMethod.POST, uri, param, clazz);
}
19
View Source File : ToStringVisitorTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void predicates() {
testPredicate(methods(HttpMethod.GET), "GET");
testPredicate(methods(HttpMethod.GET, HttpMethod.POST), "[GET, POST]");
testPredicate(path("/foo"), "/foo");
testPredicate(pathExtension("foo"), "*.foo");
testPredicate(contentType(MediaType.APPLICATION_JSON), "Content-Type: application/json");
testPredicate(contentType(MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN), "Content-Type: [application/json, text/plain]");
testPredicate(accept(MediaType.APPLICATION_JSON), "Accept: application/json");
testPredicate(param("foo", "bar"), "?foo == bar");
testPredicate(method(HttpMethod.GET).and(path("/foo")), "(GET && /foo)");
testPredicate(method(HttpMethod.GET).or(path("/foo")), "(GET || /foo)");
testPredicate(method(HttpMethod.GET).negate(), "!(GET)");
testPredicate(GET("/foo").or(contentType(MediaType.TEXT_PLAIN)).and(accept(MediaType.APPLICATION_JSON).negate()), "(((GET && /foo) || Content-Type: text/plain) && !(Accept: application/json))");
}
19
View Source File : RequestPredicates.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
/**
* Return a {@code RequestPredicate} that matches if request's HTTP method is {@code POST}
* and the given {@code pattern} matches against the request path.
* @param pattern the path pattern to match against
* @return a predicate that matches if the request method is POST and if the given pattern
* matches against the request path
*/
public static RequestPredicate POST(String pattern) {
return method(HttpMethod.POST).and(path(pattern));
}
19
View Source File : GlobalCorsConfigIntegrationTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void preFlightRequestWithCorsRestricted() throws Exception {
this.headers.set(HttpHeaders.ORIGIN, "https://foo");
this.headers.add(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET");
ResponseEnreplacedy<String> enreplacedy = performOptions("/cors-restricted", this.headers, String.clreplaced);
replacedertEquals(HttpStatus.OK, enreplacedy.getStatusCode());
replacedertEquals("https://foo", enreplacedy.getHeaders().getAccessControlAllowOrigin());
replacedertThat(enreplacedy.getHeaders().getAccessControlAllowMethods(), contains(HttpMethod.GET, HttpMethod.POST));
}
19
View Source File : GlobalCorsConfigIntegrationTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void preFlightRequestWithCorsEnabled() throws Exception {
this.headers.add(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET");
ResponseEnreplacedy<String> enreplacedy = performOptions("/cors", this.headers, String.clreplaced);
replacedertEquals(HttpStatus.OK, enreplacedy.getStatusCode());
replacedertEquals("*", enreplacedy.getHeaders().getAccessControlAllowOrigin());
replacedertThat(enreplacedy.getHeaders().getAccessControlAllowMethods(), contains(HttpMethod.GET, HttpMethod.HEAD, HttpMethod.POST));
}
19
View Source File : ToStringVisitorTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void predicates() {
testPredicate(methods(HttpMethod.GET), "GET");
testPredicate(methods(HttpMethod.GET, HttpMethod.POST), "[GET, POST]");
testPredicate(path("/foo"), "/foo");
testPredicate(pathExtension("foo"), "*.foo");
testPredicate(contentType(MediaType.APPLICATION_JSON), "Content-Type: application/json");
testPredicate(contentType(MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN), "Content-Type: [application/json, text/plain]");
testPredicate(accept(MediaType.APPLICATION_JSON), "Accept: application/json");
testPredicate(queryParam("foo", "bar"), "?foo == bar");
testPredicate(method(HttpMethod.GET).and(path("/foo")), "(GET && /foo)");
testPredicate(method(HttpMethod.GET).or(path("/foo")), "(GET || /foo)");
testPredicate(method(HttpMethod.GET).negate(), "!(GET)");
testPredicate(GET("/foo").or(contentType(MediaType.TEXT_PLAIN)).and(accept(MediaType.APPLICATION_JSON).negate()), "(((GET && /foo) || Content-Type: text/plain) && !(Accept: application/json))");
}
19
View Source File : RouterFunctionBuilderTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void route() {
RouterFunction<ServerResponse> route = RouterFunctions.route().GET("/foo", request -> ServerResponse.ok().build()).POST("/", RequestPredicates.contentType(MediaType.TEXT_PLAIN), request -> ServerResponse.noContent().build()).route(HEAD("/foo"), request -> ServerResponse.accepted().build()).build();
MockServerRequest getFooRequest = MockServerRequest.builder().method(HttpMethod.GET).uri(URI.create("http://localhost/foo")).build();
Mono<Integer> responseMono = route.route(getFooRequest).flatMap(handlerFunction -> handlerFunction.handle(getFooRequest)).map(ServerResponse::statusCode).map(HttpStatus::value);
StepVerifier.create(responseMono).expectNext(200).verifyComplete();
MockServerRequest headFooRequest = MockServerRequest.builder().method(HttpMethod.HEAD).uri(URI.create("http://localhost/foo")).build();
responseMono = route.route(headFooRequest).flatMap(handlerFunction -> handlerFunction.handle(getFooRequest)).map(ServerResponse::statusCode).map(HttpStatus::value);
StepVerifier.create(responseMono).expectNext(202).verifyComplete();
MockServerRequest barRequest = MockServerRequest.builder().method(HttpMethod.POST).uri(URI.create("http://localhost/")).header("Content-Type", "text/plain").build();
responseMono = route.route(barRequest).flatMap(handlerFunction -> handlerFunction.handle(barRequest)).map(ServerResponse::statusCode).map(HttpStatus::value);
StepVerifier.create(responseMono).expectNext(204).verifyComplete();
MockServerRequest invalidRequest = MockServerRequest.builder().method(HttpMethod.POST).uri(URI.create("http://localhost/")).build();
responseMono = route.route(invalidRequest).flatMap(handlerFunction -> handlerFunction.handle(invalidRequest)).map(ServerResponse::statusCode).map(HttpStatus::value);
StepVerifier.create(responseMono).verifyComplete();
}
19
View Source File : DefaultWebClient.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Override
public RequestBodyUriSpec post() {
return methodInternal(HttpMethod.POST);
}
19
View Source File : RequestPartServletServerHttpRequestTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void getMethod() throws Exception {
this.mockRequest.addFile(new MockMultipartFile("part", "", "", "content".getBytes("UTF-8")));
ServerHttpRequest request = new RequestPartServletServerHttpRequest(this.mockRequest, "part");
this.mockRequest.setMethod("POST");
replacedertEquals(HttpMethod.POST, request.getMethod());
}
19
View Source File : HiddenHttpMethodFilterTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void filterWithNoParameter() {
postForm("").block(Duration.ZERO);
replacedertEquals(HttpMethod.POST, this.filterChain.getHttpMethod());
}
19
View Source File : HiddenHttpMethodFilterTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void filterWithParameterMethodNotAllowed() {
postForm("_method=TRACE").block(Duration.ZERO);
replacedertEquals(HttpMethod.POST, this.filterChain.getHttpMethod());
}
19
View Source File : HiddenHttpMethodFilterTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void filterWithEmptyStringParameter() {
postForm("_method=").block(Duration.ZERO);
replacedertEquals(HttpMethod.POST, this.filterChain.getHttpMethod());
}
19
View Source File : CorsConfigurationTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void checkMethodNotAllowed() {
CorsConfiguration config = new CorsConfiguration();
replacedertNull(config.checkHttpMethod(null));
replacedertNull(config.checkHttpMethod(HttpMethod.DELETE));
config.setAllowedMethods(new ArrayList<>());
replacedertNull(config.checkHttpMethod(HttpMethod.POST));
}
19
View Source File : CorsConfigurationTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void checkMethodAllowed() {
CorsConfiguration config = new CorsConfiguration();
replacedertEquals(Arrays.asList(HttpMethod.GET, HttpMethod.HEAD), config.checkHttpMethod(HttpMethod.GET));
config.addAllowedMethod("GET");
replacedertEquals(Arrays.asList(HttpMethod.GET), config.checkHttpMethod(HttpMethod.GET));
config.addAllowedMethod("POST");
replacedertEquals(Arrays.asList(HttpMethod.GET, HttpMethod.POST), config.checkHttpMethod(HttpMethod.GET));
replacedertEquals(Arrays.asList(HttpMethod.GET, HttpMethod.POST), config.checkHttpMethod(HttpMethod.POST));
}
19
View Source File : MockServerHttpRequest.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
/**
* HTTP POST variant. See {@link #get(String, Object...)} for general info.
* @param urlTemplate a URL template; the resulting URL will be encoded
* @param uriVars zero or more URI variables
* @return the created builder
*/
public static BodyBuilder post(String urlTemplate, Object... uriVars) {
return method(HttpMethod.POST, urlTemplate, uriVars);
}
19
View Source File : InterceptingClientHttpRequestFactoryTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void changeMethod() throws Exception {
final HttpMethod changedMethod = HttpMethod.POST;
ClientHttpRequestInterceptor interceptor = new ClientHttpRequestInterceptor() {
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException {
return execution.execute(new HttpRequestWrapper(request) {
@Override
public HttpMethod getMethod() {
return changedMethod;
}
}, body);
}
};
requestFactoryMock = new RequestFactoryMock() {
@Override
public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IOException {
replacedertEquals(changedMethod, httpMethod);
return super.createRequest(uri, httpMethod);
}
};
requestFactory = new InterceptingClientHttpRequestFactory(requestFactoryMock, Collections.singletonList(interceptor));
ClientHttpRequest request = requestFactory.createRequest(new URI("https://example.com"), HttpMethod.GET);
request.execute();
}
19
View Source File : HttpComponentsClientHttpRequestFactoryTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void createHttpUriRequest() throws Exception {
URI uri = new URI("https://example.com");
testRequestBodyAllowed(uri, HttpMethod.GET, false);
testRequestBodyAllowed(uri, HttpMethod.HEAD, false);
testRequestBodyAllowed(uri, HttpMethod.OPTIONS, false);
testRequestBodyAllowed(uri, HttpMethod.TRACE, false);
testRequestBodyAllowed(uri, HttpMethod.PUT, true);
testRequestBodyAllowed(uri, HttpMethod.POST, true);
testRequestBodyAllowed(uri, HttpMethod.PATCH, true);
testRequestBodyAllowed(uri, HttpMethod.DELETE, true);
}
19
View Source File : AbstractHttpRequestFactoryTestCase.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void httpMethods() throws Exception {
replacedertHttpMethod("get", HttpMethod.GET);
replacedertHttpMethod("head", HttpMethod.HEAD);
replacedertHttpMethod("post", HttpMethod.POST);
replacedertHttpMethod("put", HttpMethod.PUT);
replacedertHttpMethod("options", HttpMethod.OPTIONS);
replacedertHttpMethod("delete", HttpMethod.DELETE);
}
19
View Source File : AbstractHttpRequestFactoryTestCase.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test(expected = IllegalStateException.clreplaced)
public void multipleWrites() throws Exception {
ClientHttpRequest request = factory.createRequest(new URI(baseUrl + "/echo"), HttpMethod.POST);
final byte[] body = "Hello World".getBytes("UTF-8");
if (request instanceof StreamingHttpOutputMessage) {
StreamingHttpOutputMessage streamingRequest = (StreamingHttpOutputMessage) request;
streamingRequest.setBody(outputStream -> {
StreamUtils.copy(body, outputStream);
outputStream.flush();
outputStream.close();
});
} else {
StreamUtils.copy(body, request.getBody());
}
request.execute();
FileCopyUtils.copy(body, request.getBody());
}
19
View Source File : AsyncRestTemplate.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Override
public <T> ListenableFuture<ResponseEnreplacedy<T>> postForEnreplacedy(String url, @Nullable HttpEnreplacedy<?> request, Clreplaced<T> responseType, Map<String, ?> uriVariables) throws RestClientException {
AsyncRequestCallback requestCallback = httpEnreplacedyCallback(request, responseType);
ResponseExtractor<ResponseEnreplacedy<T>> responseExtractor = responseEnreplacedyExtractor(responseType);
return execute(url, HttpMethod.POST, requestCallback, responseExtractor, uriVariables);
}
19
View Source File : AsyncRestTemplate.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Override
public ListenableFuture<URI> postForLocation(URI url, @Nullable HttpEnreplacedy<?> request) throws RestClientException {
AsyncRequestCallback callback = httpEnreplacedyCallback(request);
ResponseExtractor<HttpHeaders> extractor = headersExtractor();
ListenableFuture<HttpHeaders> future = execute(url, HttpMethod.POST, callback, extractor);
return adaptToLocationHeader(future);
}
19
View Source File : AsyncRestTemplate.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Override
public ListenableFuture<URI> postForLocation(String url, @Nullable HttpEnreplacedy<?> request, Map<String, ?> uriVars) throws RestClientException {
AsyncRequestCallback callback = httpEnreplacedyCallback(request);
ResponseExtractor<HttpHeaders> extractor = headersExtractor();
ListenableFuture<HttpHeaders> future = execute(url, HttpMethod.POST, callback, extractor, uriVars);
return adaptToLocationHeader(future);
}
See More Examples