Java Code Examples for org.springframework.web.client.HttpClientErrorException#BadRequest

The following examples show how to use org.springframework.web.client.HttpClientErrorException#BadRequest . 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: JobConfigurationRestControllerIT.java    From spring-batch-lightmin with Apache License 2.0 6 votes vote down vote up
@Test(expected = HttpClientErrorException.BadRequest.class)
public void testCreationOfFalsyConfigOnAddJobConfiguration() {
    final String uri = LOCALHOST + ":" + this.getServerPort() + AbstractRestController
            .JobConfigurationRestControllerAPI.JOB_CONFIGURATIONS;

    final JobConfiguration jobConfiguration = DomainToResourceMapper.map(this.createJobConfigurationWithFalsyConfig());
    final ResponseEntity<Void> responseEntity = this.restTemplate.postForEntity(uri, jobConfiguration, Void.class);
    assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CREATED);
    final String uriGet = LOCALHOST + ":" + this.getServerPort() + AbstractRestController
            .JobConfigurationRestControllerAPI.JOB_CONFIGURATIONS_JOB_NAME;
    final ResponseEntity<JobConfigurations> result = this.restTemplate.getForEntity(uriGet, JobConfigurations.class,
            "simpleJob");
    assertThat(result).isNotNull();
    final JobConfigurations jobConfigurations = result.getBody();
    final Collection<JobConfiguration> jobConfigurationsCollection = jobConfigurations.getJobConfigurations();
    assertThat(jobConfigurationsCollection).hasSize(2);
}
 
Example 2
Source File: OAuth2ConfigResourceClientTokenForwardingTest.java    From spring-cloud-services-connector with Apache License 2.0 5 votes vote down vote up
@Ignore("config-server has a bug when handling requests that are missing the vault token: https://github.com/spring-cloud/spring-cloud-config/issues/1512")
@Test(expected = HttpClientErrorException.BadRequest.class)
public void badRequestWhenConfigServerTokenNotSet() {
	configClientProperties.setToken(null);
	ConfigResourceClient configClient = new ConfigResourceClientAutoConfiguration()
			.configResourceClient(resource, configClientProperties);
	configClient.getPlainTextResource(null, null, "nginx.conf");
}