Merge branch '1.2.x'

This commit is contained in:
Phillip Webb
2015-10-07 23:34:08 -07:00
507 changed files with 2659 additions and 2478 deletions

View File

@@ -50,8 +50,8 @@ public class SampleActuatorApplicationTests {
@Test
public void testHome() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + port, Map.class);
ResponseEntity<Map> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + port, Map.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();

View File

@@ -52,8 +52,8 @@ public class SampleActuatorUiApplicationPortTests {
@Test
public void testHome() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port, String.class);
ResponseEntity<String> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port, String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
}

View File

@@ -58,11 +58,11 @@ public class SampleActuatorUiApplicationTests {
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
ResponseEntity<String> entity = new TestRestTemplate().exchange(
"http://localhost:" + this.port, HttpMethod.GET, new HttpEntity<Void>(
headers), String.class);
"http://localhost:" + this.port, HttpMethod.GET,
new HttpEntity<Void>(headers), String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertTrue("Wrong body (title doesn't match):\n" + entity.getBody(), entity
.getBody().contains("<title>Hello"));
assertTrue("Wrong body (title doesn't match):\n" + entity.getBody(),
entity.getBody().contains("<title>Hello"));
}
@Test
@@ -76,8 +76,8 @@ public class SampleActuatorUiApplicationTests {
@Test
public void testMetrics() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port + "/metrics", Map.class);
ResponseEntity<Map> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port + "/metrics", Map.class);
assertEquals(HttpStatus.UNAUTHORIZED, entity.getStatusCode());
}
@@ -89,14 +89,12 @@ public class SampleActuatorUiApplicationTests {
"http://localhost:" + this.port + "/error", HttpMethod.GET,
new HttpEntity<Void>(headers), String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertTrue("Wrong body:\n" + entity.getBody(),
entity.getBody().contains("<html>"));
assertTrue("Wrong body:\n" + entity.getBody(),
entity.getBody().contains("<body>"));
assertTrue("Wrong body:\n" + entity.getBody(), entity.getBody()
.contains("<html>"));
assertTrue("Wrong body:\n" + entity.getBody(), entity.getBody()
.contains("<body>"));
assertTrue(
"Wrong body:\n" + entity.getBody(),
entity.getBody().contains(
"Please contact the operator with the above information"));
.contains("Please contact the operator with the above information"));
}
}

View File

@@ -60,17 +60,16 @@ public class ManagementAddressActuatorApplicationTests {
@Test
public void testHome() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port, Map.class);
ResponseEntity<Map> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port, Map.class);
assertEquals(HttpStatus.UNAUTHORIZED, entity.getStatusCode());
}
@Test
public void testHealth() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate()
.getForEntity(
"http://localhost:" + this.managementPort + "/admin/health",
String.class);
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.managementPort + "/admin/health",
String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertTrue("Wrong body: " + entity.getBody(),
entity.getBody().contains("\"status\":\"UP\""));

View File

@@ -61,14 +61,14 @@ public class ManagementPathSampleActuatorApplicationTests {
@Test
public void testHomeIsSecure() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port, Map.class);
ResponseEntity<Map> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port, Map.class);
assertEquals(HttpStatus.UNAUTHORIZED, entity.getStatusCode());
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();
assertEquals("Wrong body: " + body, "Unauthorized", body.get("error"));
assertFalse("Wrong headers: " + entity.getHeaders(), entity.getHeaders()
.containsKey("Set-Cookie"));
assertFalse("Wrong headers: " + entity.getHeaders(),
entity.getHeaders().containsKey("Set-Cookie"));
}
}

View File

@@ -48,8 +48,8 @@ public class NonSensitiveHealthTests {
@Test
public void testSecureHealth() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port + "/health", String.class);
ResponseEntity<String> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port + "/health", String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertFalse("Wrong body: " + entity.getBody(),
entity.getBody().contains("\"hello\":1"));

View File

@@ -64,30 +64,30 @@ public class SampleActuatorApplicationTests {
@Test
public void testHomeIsSecure() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port, Map.class);
ResponseEntity<Map> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port, Map.class);
assertEquals(HttpStatus.UNAUTHORIZED, entity.getStatusCode());
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();
assertEquals("Wrong body: " + body, "Unauthorized", body.get("error"));
assertFalse("Wrong headers: " + entity.getHeaders(), entity.getHeaders()
.containsKey("Set-Cookie"));
assertFalse("Wrong headers: " + entity.getHeaders(),
entity.getHeaders().containsKey("Set-Cookie"));
}
@Test
public void testMetricsIsSecure() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port + "/metrics", Map.class);
ResponseEntity<Map> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port + "/metrics", Map.class);
assertEquals(HttpStatus.UNAUTHORIZED, entity.getStatusCode());
entity = new TestRestTemplate().getForEntity("http://localhost:" + this.port
+ "/metrics/", Map.class);
entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port + "/metrics/", Map.class);
assertEquals(HttpStatus.UNAUTHORIZED, entity.getStatusCode());
entity = new TestRestTemplate().getForEntity("http://localhost:" + this.port
+ "/metrics/foo", Map.class);
entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port + "/metrics/foo", Map.class);
assertEquals(HttpStatus.UNAUTHORIZED, entity.getStatusCode());
entity = new TestRestTemplate().getForEntity("http://localhost:" + this.port
+ "/metrics.json", Map.class);
entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port + "/metrics.json", Map.class);
assertEquals(HttpStatus.UNAUTHORIZED, entity.getStatusCode());
}
@@ -127,8 +127,8 @@ public class SampleActuatorApplicationTests {
@Test
public void testHealth() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port + "/health", String.class);
ResponseEntity<String> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port + "/health", String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertTrue("Wrong body: " + entity.getBody(),
entity.getBody().contains("\"status\":\"UP\""));
@@ -147,11 +147,11 @@ public class SampleActuatorApplicationTests {
@Test
public void testInfo() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port + "/info", String.class);
ResponseEntity<String> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port + "/info", String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertTrue("Wrong body: " + entity.getBody(),
entity.getBody().contains("\"artifact\":\"spring-boot-sample-actuator\""));
assertTrue("Wrong body: " + entity.getBody(), entity.getBody()
.contains("\"artifact\":\"spring-boot-sample-actuator\""));
}
@Test
@@ -199,8 +199,8 @@ public class SampleActuatorApplicationTests {
@Test
public void testErrorPageDirectAccess() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port + "/error", Map.class);
ResponseEntity<Map> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port + "/error", Map.class);
assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, entity.getStatusCode());
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();
@@ -225,7 +225,8 @@ public class SampleActuatorApplicationTests {
public void testConfigProps() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate("user", getPassword())
.getForEntity("http://localhost:" + this.port + "/configprops", Map.class);
.getForEntity("http://localhost:" + this.port + "/configprops",
Map.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();

View File

@@ -74,14 +74,14 @@ public class ServletPathSampleActuatorApplicationTests {
@Test
public void testHomeIsSecure() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port + "/spring/", Map.class);
ResponseEntity<Map> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port + "/spring/", Map.class);
assertEquals(HttpStatus.UNAUTHORIZED, entity.getStatusCode());
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();
assertEquals("Wrong body: " + body, "Unauthorized", body.get("error"));
assertFalse("Wrong headers: " + entity.getHeaders(), entity.getHeaders()
.containsKey("Set-Cookie"));
assertFalse("Wrong headers: " + entity.getHeaders(),
entity.getHeaders().containsKey("Set-Cookie"));
}
}

View File

@@ -53,14 +53,14 @@ public class ServletPathUnsecureSampleActuatorApplicationTests {
@Test
public void testHome() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port + "/spring/", Map.class);
ResponseEntity<Map> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port + "/spring/", Map.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();
assertEquals("Hello Phil", body.get("message"));
assertFalse("Wrong headers: " + entity.getHeaders(), entity.getHeaders()
.containsKey("Set-Cookie"));
assertFalse("Wrong headers: " + entity.getHeaders(),
entity.getHeaders().containsKey("Set-Cookie"));
}
@Test

View File

@@ -55,14 +55,14 @@ public class UnsecureManagementSampleActuatorApplicationTests {
@Test
public void testHomeIsSecure() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port, Map.class);
ResponseEntity<Map> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port, Map.class);
assertEquals(HttpStatus.UNAUTHORIZED, entity.getStatusCode());
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();
assertEquals("Wrong body: " + body, "Unauthorized", body.get("error"));
assertFalse("Wrong headers: " + entity.getHeaders(), entity.getHeaders()
.containsKey("Set-Cookie"));
assertFalse("Wrong headers: " + entity.getHeaders(),
entity.getHeaders().containsKey("Set-Cookie"));
}
@Test
@@ -74,12 +74,13 @@ public class UnsecureManagementSampleActuatorApplicationTests {
// ignore;
}
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port + "/metrics", Map.class);
ResponseEntity<Map> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port + "/metrics", Map.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();
assertTrue("Wrong body: " + body, body.containsKey("counter.status.401.unmapped"));
assertTrue("Wrong body: " + body,
body.containsKey("counter.status.401.unmapped"));
}
}

View File

@@ -52,14 +52,14 @@ public class UnsecureSampleActuatorApplicationTests {
@Test
public void testHome() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port, Map.class);
ResponseEntity<Map> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port, Map.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();
assertEquals("Hello Phil", body.get("message"));
assertFalse("Wrong headers: " + entity.getHeaders(), entity.getHeaders()
.containsKey("Set-Cookie"));
assertFalse("Wrong headers: " + entity.getHeaders(),
entity.getHeaders().containsKey("Set-Cookie"));
}
}

View File

@@ -53,8 +53,8 @@ public class ChatService {
return message;
}
public static class JacksonEncoderDecoder implements Encoder<Message, String>,
Decoder<String, Message> {
public static class JacksonEncoderDecoder
implements Encoder<Message, String>, Decoder<String, Message> {
private final ObjectMapper mapper = new ObjectMapper();

View File

@@ -60,9 +60,9 @@ public class SampleAtmosphereApplicationTests {
public void chatEndpoint() throws Exception {
ConfigurableApplicationContext context = new SpringApplicationBuilder(
ClientConfiguration.class, PropertyPlaceholderAutoConfiguration.class)
.properties(
"websocket.uri:ws://localhost:" + this.port + "/chat/websocket")
.run("--spring.main.web_environment=false");
.properties("websocket.uri:ws://localhost:" + this.port
+ "/chat/websocket")
.run("--spring.main.web_environment=false");
long count = context.getBean(ClientConfiguration.class).latch.getCount();
AtomicReference<String> messagePayloadReference = context
.getBean(ClientConfiguration.class).messagePayload;

View File

@@ -64,8 +64,8 @@ public class SampleBatchApplication {
public static void main(String[] args) throws Exception {
// System.exit is common for Batch applications since the exit code can be used to
// drive a workflow
System.exit(SpringApplication.exit(SpringApplication.run(
SampleBatchApplication.class, args)));
System.exit(SpringApplication
.exit(SpringApplication.run(SampleBatchApplication.class, args)));
}
}

View File

@@ -31,8 +31,8 @@ public class SampleBatchApplicationTests {
@Test
public void testDefaultSettings() throws Exception {
assertEquals(0, SpringApplication.exit(SpringApplication
.run(SampleBatchApplication.class)));
assertEquals(0, SpringApplication
.exit(SpringApplication.run(SampleBatchApplication.class)));
String output = this.outputCapture.toString();
assertTrue("Wrong output: " + output,
output.contains("completed with the following parameters"));

View File

@@ -88,8 +88,8 @@ public class Gemstone implements Serializable {
@Override
public String toString() {
return String.format("{ @type = %1$s, id = %2$d, name = %3$s }", getClass()
.getName(), getId(), getName());
return String.format("{ @type = %1$s, id = %2$d, name = %3$s }",
getClass().getName(), getId(), getName());
}
}

View File

@@ -40,8 +40,8 @@ import sample.data.gemfire.domain.Gemstone;
public class GemstoneServiceImpl implements GemstoneService {
protected static final List<String> APPROVED_GEMS = new ArrayList<String>(
Arrays.asList("ALEXANDRITE", "AQUAMARINE", "DIAMOND", "OPAL", "PEARL",
"RUBY", "SAPPHIRE", "SPINEL", "TOPAZ"));
Arrays.asList("ALEXANDRITE", "AQUAMARINE", "DIAMOND", "OPAL", "PEARL", "RUBY",
"SAPPHIRE", "SPINEL", "TOPAZ"));
@Autowired
private GemstoneRepository gemstoneRepo;
@@ -127,9 +127,10 @@ public class GemstoneServiceImpl implements GemstoneService {
// to demonstrate transactions in GemFire.
Gemstone savedGemstone = validate(this.gemstoneRepo.save(gemstone));
Assert.state(savedGemstone.equals(get(gemstone.getId())), String.format(
"Failed to find Gemstone (%1$s) in GemFire's Cache Region 'Gemstones'!",
gemstone));
Assert.state(savedGemstone.equals(get(gemstone.getId())),
String.format(
"Failed to find Gemstone (%1$s) in GemFire's Cache Region 'Gemstones'!",
gemstone));
System.out.printf("Saved Gemstone (%1$s)%n", savedGemstone.getName());
@@ -141,8 +142,8 @@ public class GemstoneServiceImpl implements GemstoneService {
// NOTE if the Gemstone is not valid, blow chunks (should cause transaction to
// rollback in GemFire)!
System.err.printf("Illegal Gemstone (%1$s)!%n", gemstone.getName());
throw new IllegalGemstoneException(String.format(
"'%1$s' is not a valid Gemstone!", gemstone.getName()));
throw new IllegalGemstoneException(
String.format("'%1$s' is not a valid Gemstone!", gemstone.getName()));
}
return gemstone;

View File

@@ -95,8 +95,8 @@ public class SampleDataGemFireApplicationTests {
this.gemstoneService.save(createGemstone("Ruby"));
assertEquals(2, this.gemstoneService.count());
assertTrue(asList(this.gemstoneService.list()).containsAll(
getGemstones("Diamond", "Ruby")));
assertTrue(asList(this.gemstoneService.list())
.containsAll(getGemstones("Diamond", "Ruby")));
try {
this.gemstoneService.save(createGemstone("Coal"));
@@ -105,15 +105,15 @@ public class SampleDataGemFireApplicationTests {
}
assertEquals(2, this.gemstoneService.count());
assertTrue(asList(this.gemstoneService.list()).containsAll(
getGemstones("Diamond", "Ruby")));
assertTrue(asList(this.gemstoneService.list())
.containsAll(getGemstones("Diamond", "Ruby")));
this.gemstoneService.save(createGemstone("Pearl"));
this.gemstoneService.save(createGemstone("Sapphire"));
assertEquals(4, this.gemstoneService.count());
assertTrue(asList(this.gemstoneService.list()).containsAll(
getGemstones("Diamond", "Ruby", "Pearl", "Sapphire")));
assertTrue(asList(this.gemstoneService.list())
.containsAll(getGemstones("Diamond", "Ruby", "Pearl", "Sapphire")));
try {
this.gemstoneService.save(createGemstone("Quartz"));
@@ -122,8 +122,8 @@ public class SampleDataGemFireApplicationTests {
}
assertEquals(4, this.gemstoneService.count());
assertTrue(asList(this.gemstoneService.list()).containsAll(
getGemstones("Diamond", "Ruby", "Pearl", "Sapphire")));
assertTrue(asList(this.gemstoneService.list())
.containsAll(getGemstones("Diamond", "Ruby", "Pearl", "Sapphire")));
assertEquals(createGemstone("Diamond"), this.gemstoneService.get("Diamond"));
assertEquals(createGemstone("Pearl"), this.gemstoneService.get("Pearl"));
}

View File

@@ -39,10 +39,10 @@ public class HotelSummary implements Serializable {
public HotelSummary(City city, String name, Double averageRating) {
this.city = city;
this.name = name;
this.averageRating = averageRating == null ? null : new BigDecimal(averageRating,
MATH_CONTEXT).doubleValue();
this.averageRatingRounded = averageRating == null ? null : (int) Math
.round(averageRating);
this.averageRating = averageRating == null ? null
: new BigDecimal(averageRating, MATH_CONTEXT).doubleValue();
this.averageRatingRounded = averageRating == null ? null
: (int) Math.round(averageRating);
}
public City getCity() {

View File

@@ -36,7 +36,8 @@ class CityServiceImpl implements CityService {
private final HotelRepository hotelRepository;
@Autowired
public CityServiceImpl(CityRepository cityRepository, HotelRepository hotelRepository) {
public CityServiceImpl(CityRepository cityRepository,
HotelRepository hotelRepository) {
this.cityRepository = cityRepository;
this.hotelRepository = hotelRepository;
}

View File

@@ -73,12 +73,9 @@ public class SampleDataJpaApplicationTests {
@Test
public void testJmx() throws Exception {
assertEquals(
1,
ManagementFactory
.getPlatformMBeanServer()
.queryMBeans(new ObjectName("jpa.sample:type=ConnectionPool,*"),
null).size());
assertEquals(1, ManagementFactory.getPlatformMBeanServer()
.queryMBeans(new ObjectName("jpa.sample:type=ConnectionPool,*"), null)
.size());
}
}

View File

@@ -59,10 +59,10 @@ public class HotelRepositoryIntegrationTests {
.get(0);
assertThat(city.getName(), is("Atlanta"));
Page<HotelSummary> hotels = this.repository.findByCity(city, new PageRequest(0,
10, Direction.ASC, "name"));
Hotel hotel = this.repository.findByCityAndName(city, hotels.getContent().get(0)
.getName());
Page<HotelSummary> hotels = this.repository.findByCity(city,
new PageRequest(0, 10, Direction.ASC, "name"));
Hotel hotel = this.repository.findByCityAndName(city,
hotels.getContent().get(0).getName());
assertThat(hotel.getName(), is("Doubletree"));
List<RatingCount> counts = this.repository.findRatingCounts(hotel);

View File

@@ -34,8 +34,8 @@ public class SampleFlywayApplicationTests {
@Test
public void testDefaultSettings() throws Exception {
assertEquals(new Integer(1), this.template.queryForObject(
"SELECT COUNT(*) from PERSON", Integer.class));
assertEquals(new Integer(1), this.template
.queryForObject("SELECT COUNT(*) from PERSON", Integer.class));
}
}

View File

@@ -49,7 +49,8 @@ public class CustomerController {
@RequestMapping(method = RequestMethod.GET)
HttpEntity<Resources<Customer>> showCustomers() {
Resources<Customer> resources = new Resources<Customer>(this.repository.findAll());
Resources<Customer> resources = new Resources<Customer>(
this.repository.findAll());
resources.add(this.entityLinks.linkToCollectionResource(Customer.class));
return new ResponseEntity<Resources<Customer>>(resources, HttpStatus.OK);
}

View File

@@ -48,8 +48,8 @@ public class SampleHateoasApplicationTests {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port + "/customers/1", String.class);
assertThat(entity.getStatusCode(), equalTo(HttpStatus.OK));
assertThat(entity.getBody(), startsWith("{\"id\":1,\"firstName\":\"Oliver\""
+ ",\"lastName\":\"Gierke\""));
assertThat(entity.getBody(), startsWith(
"{\"id\":1,\"firstName\":\"Oliver\"" + ",\"lastName\":\"Gierke\""));
assertThat(entity.getBody(), containsString("_links\":{\"self\":{\"href\""));
}

View File

@@ -75,8 +75,8 @@ public class SampleIntegrationApplicationTests {
}
private String getOutput() throws Exception {
Future<String> future = Executors.newSingleThreadExecutor().submit(
new Callable<String>() {
Future<String> future = Executors.newSingleThreadExecutor()
.submit(new Callable<String>() {
@Override
public String call() throws Exception {
Resource[] resources = getResourcesWithContent();
@@ -96,8 +96,9 @@ public class SampleIntegrationApplicationTests {
}
private Resource[] getResourcesWithContent() throws IOException {
Resource[] candidates = ResourcePatternUtils.getResourcePatternResolver(
new DefaultResourceLoader()).getResources("file:target/output/**");
Resource[] candidates = ResourcePatternUtils
.getResourcePatternResolver(new DefaultResourceLoader())
.getResources("file:target/output/**");
for (Resource candidate : candidates) {
if (candidate.contentLength() == 0) {
return new Resource[0];

View File

@@ -30,8 +30,8 @@ public class ProducerApplication implements CommandLineRunner {
public void run(String... args) throws Exception {
new File("target/input").mkdirs();
if (args.length > 0) {
FileOutputStream stream = new FileOutputStream("target/input/data"
+ System.currentTimeMillis() + ".txt");
FileOutputStream stream = new FileOutputStream(
"target/input/data" + System.currentTimeMillis() + ".txt");
for (String arg : args) {
stream.write(arg.getBytes());
}

View File

@@ -29,8 +29,9 @@ public class SampleJerseyApplication extends SpringBootServletInitializer {
}
public static void main(String[] args) {
new SampleJerseyApplication().configure(
new SpringApplicationBuilder(SampleJerseyApplication.class)).run(args);
new SampleJerseyApplication()
.configure(new SpringApplicationBuilder(SampleJerseyApplication.class))
.run(args);
}
}

View File

@@ -43,8 +43,8 @@ public class SampleJerseyApplicationTests {
@Test
public void contextLoads() {
ResponseEntity<String> entity = this.restTemplate.getForEntity(
"http://localhost:" + this.port + "/hello", String.class);
ResponseEntity<String> entity = this.restTemplate
.getForEntity("http://localhost:" + this.port + "/hello", String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
}
@@ -58,8 +58,8 @@ public class SampleJerseyApplicationTests {
@Test
public void validation() {
ResponseEntity<String> entity = this.restTemplate.getForEntity(
"http://localhost:" + this.port + "/reverse", String.class);
ResponseEntity<String> entity = this.restTemplate
.getForEntity("http://localhost:" + this.port + "/reverse", String.class);
assertEquals(HttpStatus.BAD_REQUEST, entity.getStatusCode());
}

View File

@@ -38,8 +38,8 @@ public class SampleJersey1ApplicationTests {
@Test
public void contextLoads() {
assertEquals("Hello World", new TestRestTemplate().getForObject(
"http://localhost:" + this.port + "/", String.class));
assertEquals("Hello World", new TestRestTemplate()
.getForObject("http://localhost:" + this.port + "/", String.class));
}
}

View File

@@ -54,8 +54,8 @@ public class SampleJettySslApplicationTests {
@Test
public void testHome() throws Exception {
SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
new SSLContextBuilder().loadTrustMaterial(null,
new TrustSelfSignedStrategy()).build());
new SSLContextBuilder()
.loadTrustMaterial(null, new TrustSelfSignedStrategy()).build());
HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory)
.build();
@@ -63,8 +63,8 @@ public class SampleJettySslApplicationTests {
TestRestTemplate testRestTemplate = new TestRestTemplate();
((HttpComponentsClientHttpRequestFactory) testRestTemplate.getRequestFactory())
.setHttpClient(httpClient);
ResponseEntity<String> entity = testRestTemplate.getForEntity(
"https://localhost:" + this.port, String.class);
ResponseEntity<String> entity = testRestTemplate
.getForEntity("https://localhost:" + this.port, String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertEquals("Hello World", entity.getBody());
}

View File

@@ -57,8 +57,8 @@ public class SampleJettyApplicationTests {
@Test
public void testHome() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port, String.class);
ResponseEntity<String> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port, String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertEquals("Hello World", entity.getBody());
}

View File

@@ -54,8 +54,8 @@ public class SampleJetty8SslApplicationTests {
@Test
public void testHome() throws Exception {
SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
new SSLContextBuilder().loadTrustMaterial(null,
new TrustSelfSignedStrategy()).build());
new SSLContextBuilder()
.loadTrustMaterial(null, new TrustSelfSignedStrategy()).build());
HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory)
.build();
@@ -63,8 +63,8 @@ public class SampleJetty8SslApplicationTests {
TestRestTemplate testRestTemplate = new TestRestTemplate();
((HttpComponentsClientHttpRequestFactory) testRestTemplate.getRequestFactory())
.setHttpClient(httpClient);
ResponseEntity<String> entity = testRestTemplate.getForEntity(
"https://localhost:" + this.port, String.class);
ResponseEntity<String> entity = testRestTemplate
.getForEntity("https://localhost:" + this.port, String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertEquals("Hello World", entity.getBody());
}

View File

@@ -57,8 +57,8 @@ public class SampleJetty8ApplicationTests {
@Test
public void testHome() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port, String.class);
ResponseEntity<String> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port, String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertEquals("Hello World", entity.getBody());
}

View File

@@ -26,8 +26,8 @@ import org.springframework.context.ApplicationContext;
public class SampleAtomikosApplication {
public static void main(String[] args) throws Exception {
ApplicationContext context = SpringApplication.run(
SampleAtomikosApplication.class, args);
ApplicationContext context = SpringApplication
.run(SampleAtomikosApplication.class, args);
AccountService service = context.getBean(AccountService.class);
AccountRepository repository = context.getBean(AccountRepository.class);
service.createAccountAndNotify("josh");

View File

@@ -26,8 +26,8 @@ import org.springframework.context.ApplicationContext;
public class SampleBitronixApplication {
public static void main(String[] args) throws Exception {
ApplicationContext context = SpringApplication.run(
SampleBitronixApplication.class, args);
ApplicationContext context = SpringApplication
.run(SampleBitronixApplication.class, args);
AccountService service = context.getBean(AccountService.class);
AccountRepository repository = context.getBean(AccountRepository.class);
service.createAccountAndNotify("josh");

View File

@@ -41,20 +41,19 @@ public class SampleLiquibaseApplicationTests {
}
}
String output = this.outputCapture.toString();
assertTrue(
"Wrong output: " + output,
assertTrue("Wrong output: " + output,
output.contains("Successfully acquired change log lock")
&& output.contains("Creating database history "
+ "table with name: PUBLIC.DATABASECHANGELOG")
&& output.contains("Table person created")
&& output.contains("ChangeSet classpath:/db/"
+ "changelog/db.changelog-master.yaml::1::"
+ "marceloverdijk ran successfully")
&& output.contains("New row inserted into person")
&& output.contains("ChangeSet classpath:/db/changelog/"
+ "db.changelog-master.yaml::2::"
+ "marceloverdijk ran successfully")
&& output.contains("Successfully released change log lock"));
&& output.contains("Table person created")
&& output.contains("ChangeSet classpath:/db/"
+ "changelog/db.changelog-master.yaml::1::"
+ "marceloverdijk ran successfully")
&& output.contains("New row inserted into person")
&& output.contains("ChangeSet classpath:/db/changelog/"
+ "db.changelog-master.yaml::2::"
+ "marceloverdijk ran successfully")
&& output.contains("Successfully released change log lock"));
}
private boolean serverNotRunning(IllegalStateException ex) {

View File

@@ -86,15 +86,16 @@ public class SampleIntegrationParentApplicationTests {
}
private Resource[] findResources() throws IOException {
return ResourcePatternUtils.getResourcePatternResolver(
new DefaultResourceLoader()).getResources("file:target/output/**/*.msg");
return ResourcePatternUtils
.getResourcePatternResolver(new DefaultResourceLoader())
.getResources("file:target/output/**/*.msg");
}
private String readResources(Resource[] resources) throws IOException {
StringBuilder builder = new StringBuilder();
for (Resource resource : resources) {
builder.append(new String(StreamUtils.copyToByteArray(resource
.getInputStream())));
builder.append(
new String(StreamUtils.copyToByteArray(resource.getInputStream())));
}
return builder.toString();
}

View File

@@ -30,8 +30,8 @@ public class ProducerApplication implements CommandLineRunner {
public void run(String... args) throws Exception {
new File("target/input").mkdirs();
if (args.length > 0) {
FileOutputStream stream = new FileOutputStream("target/input/data"
+ System.currentTimeMillis() + ".txt");
FileOutputStream stream = new FileOutputStream(
"target/input/data" + System.currentTimeMillis() + ".txt");
for (String arg : args) {
stream.write(arg.getBytes());
}

View File

@@ -36,9 +36,9 @@ public class SampleSecureApplication implements CommandLineRunner {
@Override
public void run(String... args) throws Exception {
SecurityContextHolder.getContext().setAuthentication(
new UsernamePasswordAuthenticationToken("user", "N/A", AuthorityUtils
.commaSeparatedStringToAuthorityList("ROLE_USER")));
SecurityContextHolder.getContext()
.setAuthentication(new UsernamePasswordAuthenticationToken("user", "N/A",
AuthorityUtils.commaSeparatedStringToAuthorityList("ROLE_USER")));
try {
System.out.println(this.service.secure());
}

View File

@@ -58,8 +58,8 @@ public class SampleSecureApplicationTests {
public void init() {
AuthenticationManager authenticationManager = this.context
.getBean(AuthenticationManager.class);
this.authentication = authenticationManager
.authenticate(new UsernamePasswordAuthenticationToken("user", "password"));
this.authentication = authenticationManager.authenticate(
new UsernamePasswordAuthenticationToken("user", "password"));
}
@After

View File

@@ -52,8 +52,8 @@ public class SampleServletApplicationTests {
@Test
public void testHomeIsSecure() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port, String.class);
ResponseEntity<String> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port, String.class);
assertEquals(HttpStatus.UNAUTHORIZED, entity.getStatusCode());
}

View File

@@ -43,8 +43,8 @@ public class SampleTestNGApplicationTests extends AbstractTestNGSpringContextTes
@Test
public void testHome() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port, String.class);
ResponseEntity<String> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port, String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertEquals("Hello World", entity.getBody());
}

View File

@@ -48,8 +48,8 @@ public class SampleWebJspApplicationTests {
@Test
public void testJspWithEl() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port, String.class);
ResponseEntity<String> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port, String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertTrue("Wrong body:\n" + entity.getBody(),
entity.getBody().contains("/resources/text.txt"));

View File

@@ -71,15 +71,13 @@ public class SampleTomcatTwoConnectorsApplicationTests {
X509TrustManager tm = new X509TrustManager() {
@Override
public void checkClientTrusted(
java.security.cert.X509Certificate[] chain, String authType)
throws java.security.cert.CertificateException {
public void checkClientTrusted(java.security.cert.X509Certificate[] chain,
String authType) throws java.security.cert.CertificateException {
}
@Override
public void checkServerTrusted(
java.security.cert.X509Certificate[] chain, String authType)
throws java.security.cert.CertificateException {
public void checkServerTrusted(java.security.cert.X509Certificate[] chain,
String authType) throws java.security.cert.CertificateException {
}
@Override
@@ -103,19 +101,21 @@ public class SampleTomcatTwoConnectorsApplicationTests {
new HostnameVerifier() {
@Override
public boolean verify(final String hostname, final SSLSession session) {
public boolean verify(final String hostname,
final SSLSession session) {
return true; // these guys are alright by me...
}
});
template.setRequestFactory(factory);
ResponseEntity<String> entity = template.getForEntity("http://localhost:"
+ this.port + "/hello", String.class);
ResponseEntity<String> entity = template
.getForEntity("http://localhost:" + this.port + "/hello", String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertEquals("hello", entity.getBody());
ResponseEntity<String> httpsEntity = template.getForEntity("https://localhost:"
+ this.context.getBean("port") + "/hello", String.class);
ResponseEntity<String> httpsEntity = template.getForEntity(
"https://localhost:" + this.context.getBean("port") + "/hello",
String.class);
assertEquals(HttpStatus.OK, httpsEntity.getStatusCode());
assertEquals("hello", httpsEntity.getBody());

View File

@@ -51,8 +51,8 @@ public class SampleTomcatSslApplicationTests {
@Test
public void testHome() throws Exception {
SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
new SSLContextBuilder().loadTrustMaterial(null,
new TrustSelfSignedStrategy()).build());
new SSLContextBuilder()
.loadTrustMaterial(null, new TrustSelfSignedStrategy()).build());
HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory)
.build();
@@ -60,8 +60,8 @@ public class SampleTomcatSslApplicationTests {
TestRestTemplate testRestTemplate = new TestRestTemplate();
((HttpComponentsClientHttpRequestFactory) testRestTemplate.getRequestFactory())
.setHttpClient(httpClient);
ResponseEntity<String> entity = testRestTemplate.getForEntity(
"https://localhost:" + this.port, String.class);
ResponseEntity<String> entity = testRestTemplate
.getForEntity("https://localhost:" + this.port, String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertEquals("Hello, world", entity.getBody());
}

View File

@@ -65,7 +65,8 @@ public class NonAutoConfigurationSampleTomcatApplicationTests {
ServerPropertiesAutoConfiguration.class, WebMvcAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class })
@ComponentScan(basePackageClasses = { SampleController.class, HelloWorldService.class })
@ComponentScan(basePackageClasses = { SampleController.class,
HelloWorldService.class })
public static class NonAutoConfigurationSampleTomcatApplication {
public static void main(String[] args) throws Exception {
@@ -76,8 +77,8 @@ public class NonAutoConfigurationSampleTomcatApplicationTests {
@Test
public void testHome() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port, String.class);
ResponseEntity<String> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port, String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertEquals("Hello World", entity.getBody());
}

View File

@@ -55,8 +55,8 @@ public class SampleTomcatApplicationTests {
@Test
public void testHome() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port, String.class);
ResponseEntity<String> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port, String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertEquals("Hello World", entity.getBody());
}

View File

@@ -48,8 +48,8 @@ public class SampleWebJspApplicationTests {
@Test
public void testJspWithEl() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port, String.class);
ResponseEntity<String> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port, String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertTrue("Wrong body:\n" + entity.getBody(),
entity.getBody().contains("/resources/text.txt"));

View File

@@ -51,7 +51,8 @@ public class WebConfig extends WebMvcConfigurerAdapter {
}
@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
public void configureDefaultServletHandling(
DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
}

View File

@@ -48,8 +48,8 @@ public class SampleTraditionalApplicationTests {
@Test
public void testHomeJsp() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port, String.class);
ResponseEntity<String> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port, String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
String body = entity.getBody();
assertTrue("Wrong body:\n" + body, body.contains("<html>"));

View File

@@ -54,8 +54,8 @@ public class SampleUndertowSslApplicationTests {
@Test
public void testHome() throws Exception {
SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
new SSLContextBuilder().loadTrustMaterial(null,
new TrustSelfSignedStrategy()).build());
new SSLContextBuilder()
.loadTrustMaterial(null, new TrustSelfSignedStrategy()).build());
HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory)
.build();
@@ -63,8 +63,8 @@ public class SampleUndertowSslApplicationTests {
TestRestTemplate testRestTemplate = new TestRestTemplate();
((HttpComponentsClientHttpRequestFactory) testRestTemplate.getRequestFactory())
.setHttpClient(httpClient);
ResponseEntity<String> entity = testRestTemplate.getForEntity(
"https://localhost:" + this.port, String.class);
ResponseEntity<String> entity = testRestTemplate
.getForEntity("https://localhost:" + this.port, String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertEquals("Hello World", entity.getBody());
}

View File

@@ -86,8 +86,8 @@ public class SampleUndertowApplicationTests {
}
private void assertOkResponse(String path, String body) {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port + path, String.class);
ResponseEntity<String> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port + path, String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertEquals(body, entity.getBody());
}

View File

@@ -55,8 +55,8 @@ public class SampleWebFreeMarkerApplicationTests {
@Test
public void testFreeMarkerTemplate() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + port, String.class);
ResponseEntity<String> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + port, String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertTrue("Wrong body:\n" + entity.getBody(),
entity.getBody().contains("Hello, Andy"));
@@ -73,8 +73,8 @@ public class SampleWebFreeMarkerApplicationTests {
requestEntity, String.class);
assertEquals(HttpStatus.NOT_FOUND, responseEntity.getStatusCode());
assertTrue("Wrong body:\n" + responseEntity.getBody(), responseEntity.getBody()
.contains("Something went wrong: 404 Not Found"));
assertTrue("Wrong body:\n" + responseEntity.getBody(),
responseEntity.getBody().contains("Something went wrong: 404 Not Found"));
}
}

View File

@@ -53,13 +53,13 @@ public class SampleGroovyTemplateApplicationTests {
@Test
public void testHome() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port, String.class);
ResponseEntity<String> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port, String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertTrue("Wrong body (title doesn't match):\n" + entity.getBody(), entity
.getBody().contains("<title>Messages"));
assertFalse("Wrong body (found layout:fragment):\n" + entity.getBody(), entity
.getBody().contains("layout:fragment"));
assertTrue("Wrong body (title doesn't match):\n" + entity.getBody(),
entity.getBody().contains("<title>Messages"));
assertFalse("Wrong body (found layout:fragment):\n" + entity.getBody(),
entity.getBody().contains("layout:fragment"));
}
@Test
@@ -67,8 +67,8 @@ public class SampleGroovyTemplateApplicationTests {
MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
map.set("text", "FOO text");
map.set("summary", "FOO");
URI location = new TestRestTemplate().postForLocation("http://localhost:"
+ this.port, map);
URI location = new TestRestTemplate()
.postForLocation("http://localhost:" + this.port, map);
assertTrue("Wrong location:\n" + location,
location.toString().contains("localhost:" + this.port));
}

View File

@@ -48,8 +48,8 @@ public class SampleWebJspApplicationTests {
@Test
public void testJspWithEl() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port, String.class);
ResponseEntity<String> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port, String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertTrue("Wrong body:\n" + entity.getBody(),
entity.getBody().contains("/resources/text.txt"));

View File

@@ -75,8 +75,8 @@ public class SampleMethodSecurityApplication extends WebMvcConfigurerAdapter {
@Order(Ordered.HIGHEST_PRECEDENCE)
@Configuration
protected static class AuthenticationSecurity extends
GlobalAuthenticationConfigurerAdapter {
protected static class AuthenticationSecurity
extends GlobalAuthenticationConfigurerAdapter {
@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {

View File

@@ -61,11 +61,11 @@ public class SampleMethodSecurityApplicationTests {
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
ResponseEntity<String> entity = new TestRestTemplate().exchange(
"http://localhost:" + this.port, HttpMethod.GET, new HttpEntity<Void>(
headers), String.class);
"http://localhost:" + this.port, HttpMethod.GET,
new HttpEntity<Void>(headers), String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertTrue("Wrong body (title doesn't match):\n" + entity.getBody(), entity
.getBody().contains("<title>Login"));
assertTrue("Wrong body (title doesn't match):\n" + entity.getBody(),
entity.getBody().contains("<title>Login"));
}
@Test
@@ -81,8 +81,8 @@ public class SampleMethodSecurityApplicationTests {
new HttpEntity<MultiValueMap<String, String>>(form, headers),
String.class);
assertEquals(HttpStatus.FOUND, entity.getStatusCode());
assertEquals("http://localhost:" + this.port + "/", entity.getHeaders()
.getLocation().toString());
assertEquals("http://localhost:" + this.port + "/",
entity.getHeaders().getLocation().toString());
}
@Test
@@ -100,18 +100,18 @@ public class SampleMethodSecurityApplicationTests {
assertEquals(HttpStatus.FOUND, entity.getStatusCode());
String cookie = entity.getHeaders().getFirst("Set-Cookie");
headers.set("Cookie", cookie);
ResponseEntity<String> page = new TestRestTemplate().exchange(entity.getHeaders()
.getLocation(), HttpMethod.GET, new HttpEntity<Void>(headers),
String.class);
ResponseEntity<String> page = new TestRestTemplate().exchange(
entity.getHeaders().getLocation(), HttpMethod.GET,
new HttpEntity<Void>(headers), String.class);
assertEquals(HttpStatus.FORBIDDEN, page.getStatusCode());
assertTrue("Wrong body (message doesn't match):\n" + entity.getBody(), page
.getBody().contains("Access denied"));
assertTrue("Wrong body (message doesn't match):\n" + entity.getBody(),
page.getBody().contains("Access denied"));
}
@Test
public void testManagementProtected() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port + "/beans", String.class);
ResponseEntity<String> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port + "/beans", String.class);
assertEquals(HttpStatus.UNAUTHORIZED, entity.getStatusCode());
}
@@ -130,8 +130,8 @@ public class SampleMethodSecurityApplicationTests {
}
private void getCsrf(MultiValueMap<String, String> form, HttpHeaders headers) {
ResponseEntity<String> page = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port + "/login", String.class);
ResponseEntity<String> page = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port + "/login", String.class);
String cookie = page.getHeaders().getFirst("Set-Cookie");
headers.set("Cookie", cookie);
String body = page.getBody();

View File

@@ -55,8 +55,8 @@ public class SampleWebMustacheApplicationTests {
@Test
public void testMustacheTemplate() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port, String.class);
ResponseEntity<String> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port, String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertTrue("Wrong body:\n" + entity.getBody(),
entity.getBody().contains("Hello, Andy"));
@@ -73,8 +73,8 @@ public class SampleWebMustacheApplicationTests {
requestEntity, String.class);
assertEquals(HttpStatus.NOT_FOUND, responseEntity.getStatusCode());
assertTrue("Wrong body:\n" + responseEntity.getBody(), responseEntity.getBody()
.contains("Something went wrong: 404 Not Found"));
assertTrue("Wrong body:\n" + responseEntity.getBody(),
responseEntity.getBody().contains("Something went wrong: 404 Not Found"));
}
}

View File

@@ -64,11 +64,11 @@ public class SampleWebSecureCustomApplicationTests {
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
ResponseEntity<String> entity = new TestRestTemplate().exchange(
"http://localhost:" + this.port, HttpMethod.GET, new HttpEntity<Void>(
headers), String.class);
"http://localhost:" + this.port, HttpMethod.GET,
new HttpEntity<Void>(headers), String.class);
assertEquals(HttpStatus.FOUND, entity.getStatusCode());
assertTrue("Wrong location:\n" + entity.getHeaders(), entity.getHeaders()
.getLocation().toString().endsWith(port + "/login"));
assertTrue("Wrong location:\n" + entity.getHeaders(),
entity.getHeaders().getLocation().toString().endsWith(port + "/login"));
}
@Test
@@ -96,16 +96,16 @@ public class SampleWebSecureCustomApplicationTests {
new HttpEntity<MultiValueMap<String, String>>(form, headers),
String.class);
assertEquals(HttpStatus.FOUND, entity.getStatusCode());
assertTrue("Wrong location:\n" + entity.getHeaders(), entity.getHeaders()
.getLocation().toString().endsWith(port + "/"));
assertTrue("Wrong location:\n" + entity.getHeaders(),
entity.getHeaders().getLocation().toString().endsWith(port + "/"));
assertNotNull("Missing cookie:\n" + entity.getHeaders(),
entity.getHeaders().get("Set-Cookie"));
}
private HttpHeaders getHeaders() {
HttpHeaders headers = new HttpHeaders();
ResponseEntity<String> page = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port + "/login", String.class);
ResponseEntity<String> page = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port + "/login", String.class);
assertEquals(HttpStatus.OK, page.getStatusCode());
String cookie = page.getHeaders().getFirst("Set-Cookie");
headers.set("Cookie", cookie);

View File

@@ -62,11 +62,11 @@ public class SampleWebSecureCustomApplicationTests {
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
ResponseEntity<String> entity = new TestRestTemplate().exchange(
"http://localhost:" + this.port, HttpMethod.GET, new HttpEntity<Void>(
headers), String.class);
"http://localhost:" + this.port, HttpMethod.GET,
new HttpEntity<Void>(headers), String.class);
assertEquals(HttpStatus.FOUND, entity.getStatusCode());
assertTrue("Wrong location:\n" + entity.getHeaders(), entity.getHeaders()
.getLocation().toString().endsWith(port + "/login"));
assertTrue("Wrong location:\n" + entity.getHeaders(),
entity.getHeaders().getLocation().toString().endsWith(port + "/login"));
}
@Test
@@ -94,16 +94,16 @@ public class SampleWebSecureCustomApplicationTests {
new HttpEntity<MultiValueMap<String, String>>(form, headers),
String.class);
assertEquals(HttpStatus.FOUND, entity.getStatusCode());
assertTrue("Wrong location:\n" + entity.getHeaders(), entity.getHeaders()
.getLocation().toString().endsWith(port + "/"));
assertTrue("Wrong location:\n" + entity.getHeaders(),
entity.getHeaders().getLocation().toString().endsWith(port + "/"));
assertNotNull("Missing cookie:\n" + entity.getHeaders(),
entity.getHeaders().get("Set-Cookie"));
}
private HttpHeaders getHeaders() {
HttpHeaders headers = new HttpHeaders();
ResponseEntity<String> page = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port + "/login", String.class);
ResponseEntity<String> page = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port + "/login", String.class);
assertEquals(HttpStatus.OK, page.getStatusCode());
String cookie = page.getHeaders().getFirst("Set-Cookie");
headers.set("Cookie", cookie);

View File

@@ -62,11 +62,11 @@ public class SampleSecureApplicationTests {
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
ResponseEntity<String> entity = new TestRestTemplate().exchange(
"http://localhost:" + this.port, HttpMethod.GET, new HttpEntity<Void>(
headers), String.class);
"http://localhost:" + this.port, HttpMethod.GET,
new HttpEntity<Void>(headers), String.class);
assertEquals(HttpStatus.FOUND, entity.getStatusCode());
assertTrue("Wrong location:\n" + entity.getHeaders(), entity.getHeaders()
.getLocation().toString().endsWith(port + "/login"));
assertTrue("Wrong location:\n" + entity.getHeaders(),
entity.getHeaders().getLocation().toString().endsWith(port + "/login"));
}
@Test
@@ -94,16 +94,16 @@ public class SampleSecureApplicationTests {
new HttpEntity<MultiValueMap<String, String>>(form, headers),
String.class);
assertEquals(HttpStatus.FOUND, entity.getStatusCode());
assertTrue("Wrong location:\n" + entity.getHeaders(), entity.getHeaders()
.getLocation().toString().endsWith(port + "/"));
assertTrue("Wrong location:\n" + entity.getHeaders(),
entity.getHeaders().getLocation().toString().endsWith(port + "/"));
assertNotNull("Missing cookie:\n" + entity.getHeaders(),
entity.getHeaders().get("Set-Cookie"));
}
private HttpHeaders getHeaders() {
HttpHeaders headers = new HttpHeaders();
ResponseEntity<String> page = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port + "/login", String.class);
ResponseEntity<String> page = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port + "/login", String.class);
assertEquals(HttpStatus.OK, page.getStatusCode());
String cookie = page.getHeaders().getFirst("Set-Cookie");
headers.set("Cookie", cookie);

View File

@@ -51,23 +51,25 @@ public class SampleWebStaticApplicationTests {
@Test
public void testHome() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port, String.class);
ResponseEntity<String> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port, String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertTrue("Wrong body (title doesn't match):\n" + entity.getBody(), entity
.getBody().contains("<title>Static"));
assertTrue("Wrong body (title doesn't match):\n" + entity.getBody(),
entity.getBody().contains("<title>Static"));
}
@Test
public void testCss() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port
+ "/webjars/bootstrap/3.0.3/css/bootstrap.min.css", String.class);
ResponseEntity<String> entity = new TestRestTemplate()
.getForEntity(
"http://localhost:" + this.port
+ "/webjars/bootstrap/3.0.3/css/bootstrap.min.css",
String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertTrue("Wrong body:\n" + entity.getBody(), entity.getBody().contains("body"));
assertEquals("Wrong content type:\n" + entity.getHeaders().getContentType(),
MediaType.valueOf("text/css;charset=UTF-8"), entity.getHeaders()
.getContentType());
MediaType.valueOf("text/css;charset=UTF-8"),
entity.getHeaders().getContentType());
}
}

View File

@@ -55,13 +55,13 @@ public class SampleWebUiApplicationTests {
@Test
public void testHome() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port, String.class);
ResponseEntity<String> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port, String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertTrue("Wrong body (title doesn't match):\n" + entity.getBody(), entity
.getBody().contains("<title>Messages"));
assertFalse("Wrong body (found layout:fragment):\n" + entity.getBody(), entity
.getBody().contains("layout:fragment"));
assertTrue("Wrong body (title doesn't match):\n" + entity.getBody(),
entity.getBody().contains("<title>Messages"));
assertFalse("Wrong body (found layout:fragment):\n" + entity.getBody(),
entity.getBody().contains("layout:fragment"));
}
@Test
@@ -69,8 +69,8 @@ public class SampleWebUiApplicationTests {
MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
map.set("text", "FOO text");
map.set("summary", "FOO");
URI location = new TestRestTemplate().postForLocation("http://localhost:"
+ this.port, map);
URI location = new TestRestTemplate()
.postForLocation("http://localhost:" + this.port, map);
assertTrue("Wrong location:\n" + location,
location.toString().contains("localhost:" + this.port));
}

View File

@@ -55,8 +55,8 @@ public class SampleWebVelocityApplicationTests {
@Test
public void testVelocityTemplate() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port, String.class);
ResponseEntity<String> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port, String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertTrue("Wrong body:\n" + entity.getBody(),
entity.getBody().contains("Hello, Andy"));
@@ -73,8 +73,8 @@ public class SampleWebVelocityApplicationTests {
requestEntity, String.class);
assertEquals(HttpStatus.NOT_FOUND, responseEntity.getStatusCode());
assertTrue("Wrong body:\n" + responseEntity.getBody(), responseEntity.getBody()
.contains("Something went wrong: 404 Not Found"));
assertTrue("Wrong body:\n" + responseEntity.getBody(),
responseEntity.getBody().contains("Something went wrong: 404 Not Found"));
}
}

View File

@@ -27,7 +27,7 @@ public class ReverseWebSocketEndpoint {
@OnMessage
public void handleMessage(Session session, String message) throws IOException {
session.getBasicRemote().sendText(
"Reversed: " + new StringBuilder(message).reverse());
session.getBasicRemote()
.sendText("Reversed: " + new StringBuilder(message).reverse());
}
}

View File

@@ -106,7 +106,7 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler {
public void afterConnectionClosed(WebSocketSession session, CloseStatus status)
throws Exception {
SnakeTimer.removeSnake(this.snake);
SnakeTimer.broadcast(String.format("{'type': 'leave', 'id': %d}",
Integer.valueOf(this.id)));
SnakeTimer.broadcast(
String.format("{'type': 'leave', 'id': %d}", Integer.valueOf(this.id)));
}
}

View File

@@ -61,9 +61,9 @@ public class SampleWebSocketsApplicationTests {
public void echoEndpoint() throws Exception {
ConfigurableApplicationContext context = new SpringApplicationBuilder(
ClientConfiguration.class, PropertyPlaceholderAutoConfiguration.class)
.properties(
"websocket.uri:ws://localhost:" + this.port + "/echo/websocket")
.run("--spring.main.web_environment=false");
.properties("websocket.uri:ws://localhost:" + this.port
+ "/echo/websocket")
.run("--spring.main.web_environment=false");
long count = context.getBean(ClientConfiguration.class).latch.getCount();
AtomicReference<String> messagePayloadReference = context
.getBean(ClientConfiguration.class).messagePayload;
@@ -76,8 +76,9 @@ public class SampleWebSocketsApplicationTests {
public void reverseEndpoint() throws Exception {
ConfigurableApplicationContext context = new SpringApplicationBuilder(
ClientConfiguration.class, PropertyPlaceholderAutoConfiguration.class)
.properties("websocket.uri:ws://localhost:" + this.port + "/reverse")
.run("--spring.main.web_environment=false");
.properties(
"websocket.uri:ws://localhost:" + this.port + "/reverse")
.run("--spring.main.web_environment=false");
long count = context.getBean(ClientConfiguration.class).latch.getCount();
AtomicReference<String> messagePayloadReference = context
.getBean(ClientConfiguration.class).messagePayload;

View File

@@ -67,8 +67,9 @@ public class CustomContainerWebSocketsApplicationTests {
public void echoEndpoint() throws Exception {
ConfigurableApplicationContext context = new SpringApplicationBuilder(
ClientConfiguration.class, PropertyPlaceholderAutoConfiguration.class)
.properties("websocket.uri:ws://localhost:" + PORT + "/ws/echo/websocket")
.run("--spring.main.web_environment=false");
.properties("websocket.uri:ws://localhost:" + PORT
+ "/ws/echo/websocket")
.run("--spring.main.web_environment=false");
long count = context.getBean(ClientConfiguration.class).latch.getCount();
AtomicReference<String> messagePayloadReference = context
.getBean(ClientConfiguration.class).messagePayload;
@@ -81,8 +82,9 @@ public class CustomContainerWebSocketsApplicationTests {
public void reverseEndpoint() throws Exception {
ConfigurableApplicationContext context = new SpringApplicationBuilder(
ClientConfiguration.class, PropertyPlaceholderAutoConfiguration.class)
.properties("websocket.uri:ws://localhost:" + PORT + "/ws/reverse").run(
"--spring.main.web_environment=false");
.properties(
"websocket.uri:ws://localhost:" + PORT + "/ws/reverse")
.run("--spring.main.web_environment=false");
long count = context.getBean(ClientConfiguration.class).latch.getCount();
AtomicReference<String> messagePayloadReference = context
.getBean(ClientConfiguration.class).messagePayload;

View File

@@ -27,7 +27,7 @@ public class ReverseWebSocketEndpoint {
@OnMessage
public void handleMessage(Session session, String message) throws IOException {
session.getBasicRemote().sendText(
"Reversed: " + new StringBuilder(message).reverse());
session.getBasicRemote()
.sendText("Reversed: " + new StringBuilder(message).reverse());
}
}

View File

@@ -106,7 +106,7 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler {
public void afterConnectionClosed(WebSocketSession session, CloseStatus status)
throws Exception {
SnakeTimer.removeSnake(this.snake);
SnakeTimer.broadcast(String.format("{'type': 'leave', 'id': %d}",
Integer.valueOf(this.id)));
SnakeTimer.broadcast(
String.format("{'type': 'leave', 'id': %d}", Integer.valueOf(this.id)));
}
}

View File

@@ -61,9 +61,9 @@ public class SampleWebSocketsApplicationTests {
public void echoEndpoint() throws Exception {
ConfigurableApplicationContext context = new SpringApplicationBuilder(
ClientConfiguration.class, PropertyPlaceholderAutoConfiguration.class)
.properties(
"websocket.uri:ws://localhost:" + this.port + "/echo/websocket")
.run("--spring.main.web_environment=false");
.properties("websocket.uri:ws://localhost:" + this.port
+ "/echo/websocket")
.run("--spring.main.web_environment=false");
long count = context.getBean(ClientConfiguration.class).latch.getCount();
AtomicReference<String> messagePayloadReference = context
.getBean(ClientConfiguration.class).messagePayload;
@@ -76,8 +76,9 @@ public class SampleWebSocketsApplicationTests {
public void reverseEndpoint() throws Exception {
ConfigurableApplicationContext context = new SpringApplicationBuilder(
ClientConfiguration.class, PropertyPlaceholderAutoConfiguration.class)
.properties("websocket.uri:ws://localhost:" + this.port + "/reverse")
.run("--spring.main.web_environment=false");
.properties(
"websocket.uri:ws://localhost:" + this.port + "/reverse")
.run("--spring.main.web_environment=false");
long count = context.getBean(ClientConfiguration.class).latch.getCount();
AtomicReference<String> messagePayloadReference = context
.getBean(ClientConfiguration.class).messagePayload;

View File

@@ -67,8 +67,9 @@ public class CustomContainerWebSocketsApplicationTests {
public void echoEndpoint() throws Exception {
ConfigurableApplicationContext context = new SpringApplicationBuilder(
ClientConfiguration.class, PropertyPlaceholderAutoConfiguration.class)
.properties("websocket.uri:ws://localhost:" + PORT + "/ws/echo/websocket")
.run("--spring.main.web_environment=false");
.properties("websocket.uri:ws://localhost:" + PORT
+ "/ws/echo/websocket")
.run("--spring.main.web_environment=false");
long count = context.getBean(ClientConfiguration.class).latch.getCount();
AtomicReference<String> messagePayloadReference = context
.getBean(ClientConfiguration.class).messagePayload;
@@ -81,8 +82,9 @@ public class CustomContainerWebSocketsApplicationTests {
public void reverseEndpoint() throws Exception {
ConfigurableApplicationContext context = new SpringApplicationBuilder(
ClientConfiguration.class, PropertyPlaceholderAutoConfiguration.class)
.properties("websocket.uri:ws://localhost:" + PORT + "/ws/reverse").run(
"--spring.main.web_environment=false");
.properties(
"websocket.uri:ws://localhost:" + PORT + "/ws/reverse")
.run("--spring.main.web_environment=false");
long count = context.getBean(ClientConfiguration.class).latch.getCount();
AtomicReference<String> messagePayloadReference = context
.getBean(ClientConfiguration.class).messagePayload;

View File

@@ -27,7 +27,7 @@ public class ReverseWebSocketEndpoint {
@OnMessage
public void handleMessage(Session session, String message) throws IOException {
session.getBasicRemote().sendText(
"Reversed: " + new StringBuilder(message).reverse());
session.getBasicRemote()
.sendText("Reversed: " + new StringBuilder(message).reverse());
}
}

View File

@@ -106,7 +106,7 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler {
public void afterConnectionClosed(WebSocketSession session, CloseStatus status)
throws Exception {
SnakeTimer.removeSnake(this.snake);
SnakeTimer.broadcast(String.format("{'type': 'leave', 'id': %d}",
Integer.valueOf(this.id)));
SnakeTimer.broadcast(
String.format("{'type': 'leave', 'id': %d}", Integer.valueOf(this.id)));
}
}

View File

@@ -61,9 +61,9 @@ public class SampleWebSocketsApplicationTests {
public void echoEndpoint() throws Exception {
ConfigurableApplicationContext context = new SpringApplicationBuilder(
ClientConfiguration.class, PropertyPlaceholderAutoConfiguration.class)
.properties(
"websocket.uri:ws://localhost:" + this.port + "/echo/websocket")
.run("--spring.main.web_environment=false");
.properties("websocket.uri:ws://localhost:" + this.port
+ "/echo/websocket")
.run("--spring.main.web_environment=false");
long count = context.getBean(ClientConfiguration.class).latch.getCount();
AtomicReference<String> messagePayloadReference = context
.getBean(ClientConfiguration.class).messagePayload;
@@ -76,8 +76,9 @@ public class SampleWebSocketsApplicationTests {
public void reverseEndpoint() throws Exception {
ConfigurableApplicationContext context = new SpringApplicationBuilder(
ClientConfiguration.class, PropertyPlaceholderAutoConfiguration.class)
.properties("websocket.uri:ws://localhost:" + this.port + "/reverse")
.run("--spring.main.web_environment=false");
.properties(
"websocket.uri:ws://localhost:" + this.port + "/reverse")
.run("--spring.main.web_environment=false");
long count = context.getBean(ClientConfiguration.class).latch.getCount();
AtomicReference<String> messagePayloadReference = context
.getBean(ClientConfiguration.class).messagePayload;

View File

@@ -67,8 +67,9 @@ public class CustomContainerWebSocketsApplicationTests {
public void echoEndpoint() throws Exception {
ConfigurableApplicationContext context = new SpringApplicationBuilder(
ClientConfiguration.class, PropertyPlaceholderAutoConfiguration.class)
.properties("websocket.uri:ws://localhost:" + PORT + "/ws/echo/websocket")
.run("--spring.main.web_environment=false");
.properties("websocket.uri:ws://localhost:" + PORT
+ "/ws/echo/websocket")
.run("--spring.main.web_environment=false");
long count = context.getBean(ClientConfiguration.class).latch.getCount();
AtomicReference<String> messagePayloadReference = context
.getBean(ClientConfiguration.class).messagePayload;
@@ -81,8 +82,9 @@ public class CustomContainerWebSocketsApplicationTests {
public void reverseEndpoint() throws Exception {
ConfigurableApplicationContext context = new SpringApplicationBuilder(
ClientConfiguration.class, PropertyPlaceholderAutoConfiguration.class)
.properties("websocket.uri:ws://localhost:" + PORT + "/ws/reverse").run(
"--spring.main.web_environment=false");
.properties(
"websocket.uri:ws://localhost:" + PORT + "/ws/reverse")
.run("--spring.main.web_environment=false");
long count = context.getBean(ClientConfiguration.class).latch.getCount();
AtomicReference<String> messagePayloadReference = context
.getBean(ClientConfiguration.class).messagePayload;

View File

@@ -33,7 +33,8 @@ import org.springframework.xml.xsd.XsdSchema;
public class WebServiceConfig extends WsConfigurerAdapter {
@Bean
public ServletRegistrationBean dispatcherServlet(ApplicationContext applicationContext) {
public ServletRegistrationBean dispatcherServlet(
ApplicationContext applicationContext) {
MessageDispatcherServlet servlet = new MessageDispatcherServlet();
servlet.setApplicationContext(applicationContext);
return new ServletRegistrationBean(servlet, "/services/*");

View File

@@ -69,10 +69,10 @@ public class HolidayEndpoint {
public void handleHolidayRequest(@RequestPayload Element holidayRequest)
throws Exception {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date startDate = dateFormat.parse(this.startDateExpression.evaluateFirst(
holidayRequest).getText());
Date endDate = dateFormat.parse(this.endDateExpression.evaluateFirst(
holidayRequest).getText());
Date startDate = dateFormat
.parse(this.startDateExpression.evaluateFirst(holidayRequest).getText());
Date endDate = dateFormat
.parse(this.endDateExpression.evaluateFirst(holidayRequest).getText());
String name = this.nameExpression.evaluateFirst(holidayRequest);
this.humanResourceService.bookHoliday(startDate, endDate, name);

View File

@@ -51,22 +51,18 @@ public class SampleWsApplicationTests {
@Before
public void setUp() {
this.webServiceTemplate.setDefaultUri("http://localhost:" + this.serverPort
+ "/services/");
this.webServiceTemplate
.setDefaultUri("http://localhost:" + this.serverPort + "/services/");
}
@Test
public void testSendingHolidayRequest() {
final String request = "<hr:HolidayRequest xmlns:hr=\"http://mycompany.com/hr/schemas\">"
+ " <hr:Holiday>"
+ " <hr:StartDate>2013-10-20</hr:StartDate>"
+ " <hr:EndDate>2013-11-22</hr:EndDate>"
+ " </hr:Holiday>"
+ " <hr:Employee>"
+ " <hr:Number>1</hr:Number>"
+ " <hr:Holiday>" + " <hr:StartDate>2013-10-20</hr:StartDate>"
+ " <hr:EndDate>2013-11-22</hr:EndDate>" + " </hr:Holiday>"
+ " <hr:Employee>" + " <hr:Number>1</hr:Number>"
+ " <hr:FirstName>John</hr:FirstName>"
+ " <hr:LastName>Doe</hr:LastName>"
+ " </hr:Employee>"
+ " <hr:LastName>Doe</hr:LastName>" + " </hr:Employee>"
+ "</hr:HolidayRequest>";
StreamSource source = new StreamSource(new StringReader(request));