Upgrade to spring-javaformat 0.0.11

This commit is contained in:
Andy Wilkinson
2019-06-07 09:44:58 +01:00
parent d548c5ed31
commit 8f1be4cded
1940 changed files with 16814 additions and 28498 deletions

View File

@@ -19,7 +19,7 @@
<properties>
<main.basedir>${basedir}/..</main.basedir>
<java.version>1.8</java.version>
<spring-javaformat.version>0.0.9</spring-javaformat.version>
<spring-javaformat.version>0.0.11</spring-javaformat.version>
<nohttp-checkstyle.version>0.0.1.RELEASE</nohttp-checkstyle.version>
<disable.checks>false</disable.checks>
</properties>

View File

@@ -46,8 +46,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@AutoConfigureMockMvc
public class SampleActuatorLog4J2ApplicationTests {
private static final Logger logger = LogManager
.getLogger(SampleActuatorLog4J2ApplicationTests.class);
private static final Logger logger = LogManager.getLogger(SampleActuatorLog4J2ApplicationTests.class);
@Rule
public OutputCapture output = new OutputCapture();
@@ -63,10 +62,9 @@ public class SampleActuatorLog4J2ApplicationTests {
@Test
public void validateLoggersEndpoint() throws Exception {
this.mvc.perform(get("/loggers/org.apache.coyote.http11.Http11NioProtocol"))
.andExpect(status().isOk())
.andExpect(content().string(equalTo("{\"configuredLevel\":\"WARN\","
+ "\"effectiveLevel\":\"WARN\"}")));
this.mvc.perform(get("/loggers/org.apache.coyote.http11.Http11NioProtocol")).andExpect(status().isOk())
.andExpect(
content().string(equalTo("{\"configuredLevel\":\"WARN\"," + "\"effectiveLevel\":\"WARN\"}")));
}
}

View File

@@ -39,8 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Dave Syer
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
properties = { "management.port:0" })
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { "management.port:0" })
@DirtiesContext
public class SampleActuatorUiApplicationPortTests {
@@ -52,23 +51,23 @@ 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);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
}
@Test
public void testMetrics() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.managementPort + "/metrics", Map.class);
ResponseEntity<Map> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.managementPort + "/metrics", Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
}
@Test
public void testHealth() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.managementPort + "/health", String.class);
ResponseEntity<String> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.managementPort + "/health", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).isEqualTo("{\"status\":\"UP\"}");
}

View File

@@ -54,16 +54,15 @@ public class SampleActuatorUiApplicationTests {
public void testHome() throws Exception {
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
ResponseEntity<String> entity = this.restTemplate.exchange("/", HttpMethod.GET,
new HttpEntity<Void>(headers), String.class);
ResponseEntity<String> entity = this.restTemplate.exchange("/", HttpMethod.GET, new HttpEntity<Void>(headers),
String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).contains("<title>Hello");
}
@Test
public void testCss() throws Exception {
ResponseEntity<String> entity = this.restTemplate
.getForEntity("/css/bootstrap.min.css", String.class);
ResponseEntity<String> entity = this.restTemplate.getForEntity("/css/bootstrap.min.css", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).contains("body");
}
@@ -71,8 +70,7 @@ public class SampleActuatorUiApplicationTests {
@Test
public void testMetrics() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/metrics",
Map.class);
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/metrics", Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
}
@@ -80,8 +78,8 @@ public class SampleActuatorUiApplicationTests {
public void testError() throws Exception {
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
ResponseEntity<String> entity = this.restTemplate.exchange("/error",
HttpMethod.GET, new HttpEntity<Void>(headers), String.class);
ResponseEntity<String> entity = this.restTemplate.exchange("/error", HttpMethod.GET,
new HttpEntity<Void>(headers), String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
assertThat(entity.getBody()).contains("<html>").contains("<body>")
.contains("Please contact the operator with the above information");

View File

@@ -44,8 +44,7 @@ public class SampleController {
@GetMapping("/")
@ResponseBody
public Map<String, String> hello() {
return Collections.singletonMap("message",
this.helloWorldService.getHelloMessage());
return Collections.singletonMap("message", this.helloWorldService.getHelloMessage());
}
@PostMapping("/")

View File

@@ -58,8 +58,8 @@ public class CorsSampleActuatorApplicationTests {
@Before
public void setUp() throws Exception {
RestTemplate restTemplate = new RestTemplate();
LocalHostUriTemplateHandler handler = new LocalHostUriTemplateHandler(
this.applicationContext.getEnvironment(), "http");
LocalHostUriTemplateHandler handler = new LocalHostUriTemplateHandler(this.applicationContext.getEnvironment(),
"http");
restTemplate.setUriTemplateHandler(handler);
restTemplate.setRequestFactory(new HttpComponentsClientHttpRequestFactory());
this.testRestTemplate = new TestRestTemplate(restTemplate);
@@ -74,30 +74,24 @@ public class CorsSampleActuatorApplicationTests {
@Test
public void preflightRequestForInsensitiveShouldReturnOk() throws Exception {
RequestEntity<?> healthRequest = RequestEntity.options(new URI("/health"))
.header("Origin", "http://localhost:8080")
.header("Access-Control-Request-Method", "GET").build();
ResponseEntity<?> exchange = this.testRestTemplate.exchange(healthRequest,
Map.class);
.header("Origin", "http://localhost:8080").header("Access-Control-Request-Method", "GET").build();
ResponseEntity<?> exchange = this.testRestTemplate.exchange(healthRequest, Map.class);
assertThat(exchange.getStatusCode()).isEqualTo(HttpStatus.OK);
}
@Test
public void preflightRequestForSensitiveEndpointShouldReturnOk() throws Exception {
RequestEntity<?> entity = RequestEntity.options(new URI("/env"))
.header("Origin", "http://localhost:8080")
RequestEntity<?> entity = RequestEntity.options(new URI("/env")).header("Origin", "http://localhost:8080")
.header("Access-Control-Request-Method", "GET").build();
ResponseEntity<?> env = this.testRestTemplate.exchange(entity, Map.class);
assertThat(env.getStatusCode()).isEqualTo(HttpStatus.OK);
}
@Test
public void preflightRequestWhenCorsConfigInvalidShouldReturnForbidden()
throws Exception {
RequestEntity<?> entity = RequestEntity.options(new URI("/health"))
.header("Origin", "http://localhost:9095")
public void preflightRequestWhenCorsConfigInvalidShouldReturnForbidden() throws Exception {
RequestEntity<?> entity = RequestEntity.options(new URI("/health")).header("Origin", "http://localhost:9095")
.header("Access-Control-Request-Method", "GET").build();
ResponseEntity<byte[]> exchange = this.testRestTemplate.exchange(entity,
byte[].class);
ResponseEntity<byte[]> exchange = this.testRestTemplate.exchange(entity, byte[].class);
assertThat(exchange.getStatusCode()).isEqualTo(HttpStatus.FORBIDDEN);
}

View File

@@ -54,8 +54,8 @@ public class EndpointsPropertiesSampleActuatorApplicationTests {
@Test
public void testCustomErrorPath() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = this.restTemplate
.withBasicAuth("user", getPassword()).getForEntity("/oops", Map.class);
ResponseEntity<Map> entity = this.restTemplate.withBasicAuth("user", getPassword()).getForEntity("/oops",
Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();
@@ -65,8 +65,7 @@ public class EndpointsPropertiesSampleActuatorApplicationTests {
@Test
public void testCustomContextPath() throws Exception {
ResponseEntity<String> entity = this.restTemplate
.withBasicAuth("user", getPassword())
ResponseEntity<String> entity = this.restTemplate.withBasicAuth("user", getPassword())
.getForEntity("/admin/health", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).contains("\"status\":\"UP\"");

View File

@@ -42,8 +42,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
properties = { "management.port=0", "management.context-path=/admin",
"management.security.enabled=false" })
properties = { "management.port=0", "management.context-path=/admin", "management.security.enabled=false" })
@DirtiesContext
public class InsecureManagementPortAndPathSampleActuatorApplicationTests {
@@ -71,25 +70,23 @@ public class InsecureManagementPortAndPathSampleActuatorApplicationTests {
public void testMetrics() throws Exception {
testHome(); // makes sure some requests have been made
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.managementPort + "/admin/metrics", Map.class);
ResponseEntity<Map> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.managementPort + "/admin/metrics", Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
}
@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);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
}
@Test
public void testMissing() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.managementPort + "/admin/missing",
String.class);
ResponseEntity<String> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.managementPort + "/admin/missing", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
assertThat(entity.getBody()).contains("\"status\":404");
}

View File

@@ -40,8 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Dave Syer
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
properties = { "management.security.enabled:false" })
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { "management.security.enabled:false" })
@DirtiesContext
@ActiveProfiles("unsecure-management")
public class InsecureManagementSampleActuatorApplicationTests {
@@ -69,8 +68,7 @@ public class InsecureManagementSampleActuatorApplicationTests {
// ignore;
}
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/metrics",
Map.class);
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/metrics", Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();

View File

@@ -39,8 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Dave Syer
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
properties = { "security.basic.enabled:false" })
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { "security.basic.enabled:false" })
@DirtiesContext
public class InsecureSampleActuatorApplicationTests {

View File

@@ -40,8 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
properties = { "management.port=0", "management.address=127.0.0.1",
"management.context-path:/admin" })
properties = { "management.port=0", "management.address=127.0.0.1", "management.context-path:/admin" })
@DirtiesContext
public class ManagementAddressActuatorApplicationTests {
@@ -54,16 +53,14 @@ 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);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
}
@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);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
}

View File

@@ -38,8 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Dave Syer
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
properties = { "management.context_path=/admin" })
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { "management.context_path=/admin" })
@DirtiesContext
public class ManagementPathSampleActuatorApplicationTests {
@@ -48,8 +47,7 @@ public class ManagementPathSampleActuatorApplicationTests {
@Test
public void testHealth() throws Exception {
ResponseEntity<String> entity = this.restTemplate.getForEntity("/admin/health",
String.class);
ResponseEntity<String> entity = this.restTemplate.getForEntity("/admin/health", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
}

View File

@@ -70,16 +70,15 @@ public class ManagementPortAndPathSampleActuatorApplicationTests {
public void testMetrics() throws Exception {
testHome(); // makes sure some requests have been made
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.managementPort + "/admin/metrics", Map.class);
ResponseEntity<Map> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.managementPort + "/admin/metrics", Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
}
@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);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
}
@@ -87,9 +86,7 @@ public class ManagementPortAndPathSampleActuatorApplicationTests {
@Test
public void testMissing() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate("user", getPassword())
.getForEntity(
"http://localhost:" + this.managementPort + "/admin/missing",
String.class);
.getForEntity("http://localhost:" + this.managementPort + "/admin/missing", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
assertThat(entity.getBody()).contains("\"status\":404");
}
@@ -97,8 +94,8 @@ public class ManagementPortAndPathSampleActuatorApplicationTests {
@Test
public void testErrorPage() 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);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();
@@ -108,8 +105,8 @@ public class ManagementPortAndPathSampleActuatorApplicationTests {
@Test
public void testManagementErrorPage() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.managementPort + "/error", Map.class);
ResponseEntity<Map> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.managementPort + "/error", Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();

View File

@@ -41,8 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Dave Syer
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
properties = { "management.port=0" })
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { "management.port=0" })
@DirtiesContext
public class ManagementPortSampleActuatorApplicationTests {
@@ -70,15 +69,15 @@ public class ManagementPortSampleActuatorApplicationTests {
public void testMetrics() throws Exception {
testHome(); // makes sure some requests have been made
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.managementPort + "/metrics", Map.class);
ResponseEntity<Map> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.managementPort + "/metrics", Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
}
@Test
public void testHealth() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.managementPort + "/health", String.class);
ResponseEntity<String> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.managementPort + "/health", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
}
@@ -86,8 +85,8 @@ public class ManagementPortSampleActuatorApplicationTests {
@Test
public void testErrorPage() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.managementPort + "/error", Map.class);
ResponseEntity<Map> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.managementPort + "/error", Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();

View File

@@ -39,8 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Dave Syer
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
properties = { "management.port=-1" })
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { "management.port=-1" })
@DirtiesContext
public class NoManagementSampleActuatorApplicationTests {
@@ -53,8 +52,8 @@ public class NoManagementSampleActuatorApplicationTests {
@Test
public void testHome() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = this.restTemplate
.withBasicAuth("user", getPassword()).getForEntity("/", Map.class);
ResponseEntity<Map> entity = this.restTemplate.withBasicAuth("user", getPassword()).getForEntity("/",
Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();
@@ -65,8 +64,8 @@ public class NoManagementSampleActuatorApplicationTests {
public void testMetricsNotAvailable() throws Exception {
testHome(); // makes sure some requests have been made
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = this.restTemplate
.withBasicAuth("user", getPassword()).getForEntity("/metrics", Map.class);
ResponseEntity<Map> entity = this.restTemplate.withBasicAuth("user", getPassword()).getForEntity("/metrics",
Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
}

View File

@@ -36,8 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Phillip Webb
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
properties = { "endpoints.health.sensitive=false" })
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { "endpoints.health.sensitive=false" })
@DirtiesContext
public class NonSensitiveHealthTests {
@@ -46,8 +45,7 @@ public class NonSensitiveHealthTests {
@Test
public void testSecureHealth() throws Exception {
ResponseEntity<String> entity = this.restTemplate.getForEntity("/health",
String.class);
ResponseEntity<String> entity = this.restTemplate.getForEntity("/health", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).doesNotContain("\"hello\":1");
}

View File

@@ -71,8 +71,7 @@ public class SampleActuatorApplicationTests {
@Test
public void testMetricsIsSecure() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/metrics",
Map.class);
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/metrics", Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
entity = this.restTemplate.getForEntity("/metrics/", Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
@@ -85,8 +84,8 @@ public class SampleActuatorApplicationTests {
@Test
public void testHome() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = this.restTemplate
.withBasicAuth("user", getPassword()).getForEntity("/", Map.class);
ResponseEntity<Map> entity = this.restTemplate.withBasicAuth("user", getPassword()).getForEntity("/",
Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();
@@ -97,8 +96,8 @@ public class SampleActuatorApplicationTests {
public void testMetrics() throws Exception {
testHome(); // makes sure some requests have been made
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = this.restTemplate
.withBasicAuth("user", getPassword()).getForEntity("/metrics", Map.class);
ResponseEntity<Map> entity = this.restTemplate.withBasicAuth("user", getPassword()).getForEntity("/metrics",
Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();
@@ -108,8 +107,8 @@ public class SampleActuatorApplicationTests {
@Test
public void testEnv() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = this.restTemplate
.withBasicAuth("user", getPassword()).getForEntity("/env", Map.class);
ResponseEntity<Map> entity = this.restTemplate.withBasicAuth("user", getPassword()).getForEntity("/env",
Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();
@@ -118,8 +117,7 @@ public class SampleActuatorApplicationTests {
@Test
public void testHealth() throws Exception {
ResponseEntity<String> entity = this.restTemplate.getForEntity("/health",
String.class);
ResponseEntity<String> entity = this.restTemplate.getForEntity("/health", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
assertThat(entity.getBody()).doesNotContain("\"hello\":\"1\"");
@@ -127,31 +125,26 @@ public class SampleActuatorApplicationTests {
@Test
public void testSecureHealth() throws Exception {
ResponseEntity<String> entity = this.restTemplate
.withBasicAuth("user", getPassword())
.getForEntity("/health", String.class);
ResponseEntity<String> entity = this.restTemplate.withBasicAuth("user", getPassword()).getForEntity("/health",
String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).contains("\"hello\":1");
}
@Test
public void testInfo() throws Exception {
ResponseEntity<String> entity = this.restTemplate.getForEntity("/info",
String.class);
ResponseEntity<String> entity = this.restTemplate.getForEntity("/info", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody())
.contains("\"artifact\":\"spring-boot-sample-actuator\"");
assertThat(entity.getBody()).contains("\"artifact\":\"spring-boot-sample-actuator\"");
assertThat(entity.getBody()).contains("\"someKey\":\"someValue\"");
assertThat(entity.getBody()).contains("\"java\":{", "\"source\":\"1.8\"",
"\"target\":\"1.8\"");
assertThat(entity.getBody()).contains("\"encoding\":{", "\"source\":\"UTF-8\"",
"\"reporting\":\"UTF-8\"");
assertThat(entity.getBody()).contains("\"java\":{", "\"source\":\"1.8\"", "\"target\":\"1.8\"");
assertThat(entity.getBody()).contains("\"encoding\":{", "\"source\":\"UTF-8\"", "\"reporting\":\"UTF-8\"");
}
@Test
public void testErrorPage() throws Exception {
ResponseEntity<String> entity = this.restTemplate
.withBasicAuth("user", getPassword()).getForEntity("/foo", String.class);
ResponseEntity<String> entity = this.restTemplate.withBasicAuth("user", getPassword()).getForEntity("/foo",
String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
String body = entity.getBody();
assertThat(body).contains("\"error\":");
@@ -162,9 +155,8 @@ public class SampleActuatorApplicationTests {
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
HttpEntity<?> request = new HttpEntity<Void>(headers);
ResponseEntity<String> entity = this.restTemplate
.withBasicAuth("user", getPassword())
.exchange("/foo", HttpMethod.GET, request, String.class);
ResponseEntity<String> entity = this.restTemplate.withBasicAuth("user", getPassword()).exchange("/foo",
HttpMethod.GET, request, String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
String body = entity.getBody();
assertThat(body).as("Body was null").isNotNull();
@@ -175,15 +167,15 @@ public class SampleActuatorApplicationTests {
public void testTrace() throws Exception {
this.restTemplate.getForEntity("/health", String.class);
@SuppressWarnings("rawtypes")
ResponseEntity<List> entity = this.restTemplate
.withBasicAuth("user", getPassword()).getForEntity("/trace", List.class);
ResponseEntity<List> entity = this.restTemplate.withBasicAuth("user", getPassword()).getForEntity("/trace",
List.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
@SuppressWarnings("unchecked")
List<Map<String, Object>> list = entity.getBody();
Map<String, Object> trace = list.get(list.size() - 1);
@SuppressWarnings("unchecked")
Map<String, Object> map = (Map<String, Object>) ((Map<String, Object>) ((Map<String, Object>) trace
.get("info")).get("headers")).get("response");
Map<String, Object> map = (Map<String, Object>) ((Map<String, Object>) ((Map<String, Object>) trace.get("info"))
.get("headers")).get("response");
assertThat(map.get("status")).isEqualTo("200");
}
@@ -191,15 +183,14 @@ public class SampleActuatorApplicationTests {
public void traceWithParameterMap() throws Exception {
this.restTemplate.getForEntity("/health?param1=value1", String.class);
@SuppressWarnings("rawtypes")
ResponseEntity<List> entity = this.restTemplate
.withBasicAuth("user", getPassword()).getForEntity("/trace", List.class);
ResponseEntity<List> entity = this.restTemplate.withBasicAuth("user", getPassword()).getForEntity("/trace",
List.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
@SuppressWarnings("unchecked")
List<Map<String, Object>> list = entity.getBody();
Map<String, Object> trace = list.get(0);
@SuppressWarnings("unchecked")
Map<String, Object> map = (Map<String, Object>) ((Map<String, Object>) trace
.get("info")).get("parameters");
Map<String, Object> map = (Map<String, Object>) ((Map<String, Object>) trace.get("info")).get("parameters");
assertThat(map.get("param1")).isNotNull();
}
@@ -218,8 +209,8 @@ public class SampleActuatorApplicationTests {
@SuppressWarnings("unchecked")
public void testBeans() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<List> entity = this.restTemplate
.withBasicAuth("user", getPassword()).getForEntity("/beans", List.class);
ResponseEntity<List> entity = this.restTemplate.withBasicAuth("user", getPassword()).getForEntity("/beans",
List.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).hasSize(1);
Map<String, Object> body = (Map<String, Object>) entity.getBody().get(0);
@@ -229,14 +220,12 @@ public class SampleActuatorApplicationTests {
@Test
public void testConfigProps() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = this.restTemplate
.withBasicAuth("user", getPassword())
.getForEntity("/configprops", Map.class);
ResponseEntity<Map> entity = this.restTemplate.withBasicAuth("user", getPassword()).getForEntity("/configprops",
Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();
assertThat(body)
.containsKey("spring.datasource-" + DataSourceProperties.class.getName());
assertThat(body).containsKey("spring.datasource-" + DataSourceProperties.class.getName());
}
private String getPassword() {

View File

@@ -50,8 +50,7 @@ public class ServletPathInsecureSampleActuatorApplicationTests {
@Test
public void testHome() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/spring/",
Map.class);
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/spring/", Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();
@@ -62,8 +61,7 @@ public class ServletPathInsecureSampleActuatorApplicationTests {
@Test
public void testMetricsIsSecure() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/spring/metrics",
Map.class);
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/spring/metrics", Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
}

View File

@@ -38,8 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Dave Syer
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
properties = { "server.servletPath=/spring" })
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { "server.servletPath=/spring" })
@DirtiesContext
public class ServletPathSampleActuatorApplicationTests {
@@ -49,8 +48,7 @@ public class ServletPathSampleActuatorApplicationTests {
@Test
public void testErrorPath() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/spring/error",
Map.class);
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/spring/error", Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();
@@ -60,8 +58,7 @@ public class ServletPathSampleActuatorApplicationTests {
@Test
public void testHealth() throws Exception {
ResponseEntity<String> entity = this.restTemplate.getForEntity("/spring/health",
String.class);
ResponseEntity<String> entity = this.restTemplate.getForEntity("/spring/health", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
}
@@ -69,8 +66,7 @@ public class ServletPathSampleActuatorApplicationTests {
@Test
public void testHomeIsSecure() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/spring/",
Map.class);
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/spring/", Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();

View File

@@ -52,8 +52,8 @@ public class ShutdownSampleActuatorApplicationTests {
@Test
public void testHome() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = this.restTemplate
.withBasicAuth("user", getPassword()).getForEntity("/", Map.class);
ResponseEntity<Map> entity = this.restTemplate.withBasicAuth("user", getPassword()).getForEntity("/",
Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();
@@ -63,9 +63,8 @@ public class ShutdownSampleActuatorApplicationTests {
@Test
public void testShutdown() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = this.restTemplate
.withBasicAuth("user", getPassword())
.postForEntity("/shutdown", null, Map.class);
ResponseEntity<Map> entity = this.restTemplate.withBasicAuth("user", getPassword()).postForEntity("/shutdown",
null, Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();

View File

@@ -48,12 +48,10 @@ public class SampleAntApplicationIT {
});
assertThat(jarFiles).hasSize(1);
Process process = new JavaExecutable()
.processBuilder("-jar", jarFiles[0].getName()).directory(target).start();
Process process = new JavaExecutable().processBuilder("-jar", jarFiles[0].getName()).directory(target).start();
process.waitFor(5, TimeUnit.MINUTES);
assertThat(process.exitValue()).isEqualTo(0);
String output = FileCopyUtils
.copyToString(new InputStreamReader(process.getInputStream()));
String output = FileCopyUtils.copyToString(new InputStreamReader(process.getInputStream()));
assertThat(output).contains("Spring Boot Ant Example");
}

View File

@@ -48,13 +48,11 @@ public class ChatService {
@org.atmosphere.config.service.Message(encoders = JacksonEncoderDecoder.class,
decoders = JacksonEncoderDecoder.class)
public Message onMessage(Message message) throws IOException {
this.logger.info("Author {} sent message {}", message.getAuthor(),
message.getMessage());
this.logger.info("Author {} sent message {}", message.getAuthor(), message.getMessage());
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

@@ -48,11 +48,10 @@ public class SampleAtmosphereApplication {
public ServletRegistrationBean atmosphereServlet() {
// Dispatcher servlet is mapped to '/home' to allow the AtmosphereServlet
// to be mapped to '/chat'
ServletRegistrationBean registration = new ServletRegistrationBean(
new AtmosphereServlet(), "/chat/*");
ServletRegistrationBean registration = new ServletRegistrationBean(new AtmosphereServlet(), "/chat/*");
registration.addInitParameter("org.atmosphere.cpr.packages", "sample");
registration.addInitParameter("org.atmosphere.interceptor.HeartbeatInterceptor"
+ ".clientHeartbeatFrequencyInSeconds", "10");
registration.addInitParameter(
"org.atmosphere.interceptor.HeartbeatInterceptor" + ".clientHeartbeatFrequencyInSeconds", "10");
registration.setLoadOnStartup(0);
// Need to occur before the EmbeddedAtmosphereInitializer
registration.setOrder(Ordered.HIGHEST_PRECEDENCE);

View File

@@ -46,8 +46,7 @@ import org.springframework.web.socket.handler.TextWebSocketHandler;
import static org.assertj.core.api.Assertions.assertThat;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SampleAtmosphereApplication.class,
webEnvironment = WebEnvironment.RANDOM_PORT)
@SpringBootTest(classes = SampleAtmosphereApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT)
@DirtiesContext
public class SampleAtmosphereApplicationTests {
@@ -58,18 +57,15 @@ public class SampleAtmosphereApplicationTests {
@Test
public void chatEndpoint() throws Exception {
ConfigurableApplicationContext context = new SpringApplicationBuilder(
ClientConfiguration.class, PropertyPlaceholderAutoConfiguration.class)
.properties("websocket.uri:ws://localhost:" + this.port
+ "/chat/websocket")
ConfigurableApplicationContext context = new SpringApplicationBuilder(ClientConfiguration.class,
PropertyPlaceholderAutoConfiguration.class)
.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;
AtomicReference<String> messagePayloadReference = context.getBean(ClientConfiguration.class).messagePayload;
context.close();
assertThat(count).isEqualTo(0L);
assertThat(messagePayloadReference.get())
.contains("{\"message\":\"test\",\"author\":\"test\",\"time\":");
assertThat(messagePayloadReference.get()).contains("{\"message\":\"test\",\"author\":\"test\",\"time\":");
}
@Configuration
@@ -95,8 +91,7 @@ public class SampleAtmosphereApplicationTests {
@Bean
public WebSocketConnectionManager wsConnectionManager() {
WebSocketConnectionManager manager = new WebSocketConnectionManager(client(),
handler(), this.webSocketUri);
WebSocketConnectionManager manager = new WebSocketConnectionManager(client(), handler(), this.webSocketUri);
manager.setAutoStartup(true);
return manager;
}
@@ -111,17 +106,13 @@ public class SampleAtmosphereApplicationTests {
return new TextWebSocketHandler() {
@Override
public void afterConnectionEstablished(WebSocketSession session)
throws Exception {
session.sendMessage(new TextMessage(
"{\"author\":\"test\",\"message\":\"test\"}"));
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
session.sendMessage(new TextMessage("{\"author\":\"test\",\"message\":\"test\"}"));
}
@Override
protected void handleTextMessage(WebSocketSession session,
TextMessage message) throws Exception {
logger.info("Received: " + message + " ("
+ ClientConfiguration.this.latch.getCount() + ")");
protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
logger.info("Received: " + message + " (" + ClientConfiguration.this.latch.getCount() + ")");
session.close();
ClientConfiguration.this.messagePayload.set(message.getPayload());
ClientConfiguration.this.latch.countDown();

View File

@@ -45,8 +45,7 @@ public class SampleBatchApplication {
return new Tasklet() {
@Override
public RepeatStatus execute(StepContribution contribution,
ChunkContext context) {
public RepeatStatus execute(StepContribution contribution, ChunkContext context) {
return RepeatStatus.FINISHED;
}
};
@@ -66,8 +65,7 @@ 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,7 @@ public class SampleBatchApplicationTests {
@Test
public void testDefaultSettings() throws Exception {
assertThat(SpringApplication
.exit(SpringApplication.run(SampleBatchApplication.class))).isEqualTo(0);
assertThat(SpringApplication.exit(SpringApplication.run(SampleBatchApplication.class))).isEqualTo(0);
String output = this.outputCapture.toString();
assertThat(output).contains("completed with the following parameters");
}

View File

@@ -36,8 +36,8 @@ public class CacheManagerCheck implements CommandLineRunner {
@Override
public void run(String... strings) throws Exception {
logger.info("\n\n" + "=========================================================\n"
+ "Using cache manager: " + this.cacheManager.getClass().getName() + "\n"
logger.info("\n\n" + "=========================================================\n" + "Using cache manager: "
+ this.cacheManager.getClass().getName() + "\n"
+ "=========================================================\n\n");
}

View File

@@ -27,8 +27,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
public class SampleCacheApplication {
public static void main(String[] args) {
new SpringApplicationBuilder().sources(SampleCacheApplication.class)
.profiles("app").run(args);
new SpringApplicationBuilder().sources(SampleCacheApplication.class).profiles("app").run(args);
}
}

View File

@@ -28,26 +28,21 @@ import org.springframework.stereotype.Component;
@Profile("app")
class SampleClient {
private static final List<String> SAMPLE_COUNTRY_CODES = Arrays.asList("AF", "AX",
"AL", "DZ", "AS", "AD", "AO", "AI", "AQ", "AG", "AR", "AM", "AW", "AU", "AT",
"AZ", "BS", "BH", "BD", "BB", "BY", "BE", "BZ", "BJ", "BM", "BT", "BO", "BQ",
"BA", "BW", "BV", "BR", "IO", "BN", "BG", "BF", "BI", "KH", "CM", "CA", "CV",
"KY", "CF", "TD", "CL", "CN", "CX", "CC", "CO", "KM", "CG", "CD", "CK", "CR",
"CI", "HR", "CU", "CW", "CY", "CZ", "DK", "DJ", "DM", "DO", "EC", "EG", "SV",
"GQ", "ER", "EE", "ET", "FK", "FO", "FJ", "FI", "FR", "GF", "PF", "TF", "GA",
"GM", "GE", "DE", "GH", "GI", "GR", "GL", "GD", "GP", "GU", "GT", "GG", "GN",
"GW", "GY", "HT", "HM", "VA", "HN", "HK", "HU", "IS", "IN", "ID", "IR", "IQ",
"IE", "IM", "IL", "IT", "JM", "JP", "JE", "JO", "KZ", "KE", "KI", "KP", "KR",
"KW", "KG", "LA", "LV", "LB", "LS", "LR", "LY", "LI", "LT", "LU", "MO", "MK",
"MG", "MW", "MY", "MV", "ML", "MT", "MH", "MQ", "MR", "MU", "YT", "MX", "FM",
"MD", "MC", "MN", "ME", "MS", "MA", "MZ", "MM", "NA", "NR", "NP", "NL", "NC",
"NZ", "NI", "NE", "NG", "NU", "NF", "MP", "NO", "OM", "PK", "PW", "PS", "PA",
"PG", "PY", "PE", "PH", "PN", "PL", "PT", "PR", "QA", "RE", "RO", "RU", "RW",
"BL", "SH", "KN", "LC", "MF", "PM", "VC", "WS", "SM", "ST", "SA", "SN", "RS",
"SC", "SL", "SG", "SX", "SK", "SI", "SB", "SO", "ZA", "GS", "SS", "ES", "LK",
"SD", "SR", "SJ", "SZ", "SE", "CH", "SY", "TW", "TJ", "TZ", "TH", "TL", "TG",
"TK", "TO", "TT", "TN", "TR", "TM", "TC", "TV", "UG", "UA", "AE", "GB", "US",
"UM", "UY", "UZ", "VU", "VE", "VN", "VG", "VI", "WF", "EH", "YE", "ZM", "ZW");
private static final List<String> SAMPLE_COUNTRY_CODES = Arrays.asList("AF", "AX", "AL", "DZ", "AS", "AD", "AO",
"AI", "AQ", "AG", "AR", "AM", "AW", "AU", "AT", "AZ", "BS", "BH", "BD", "BB", "BY", "BE", "BZ", "BJ", "BM",
"BT", "BO", "BQ", "BA", "BW", "BV", "BR", "IO", "BN", "BG", "BF", "BI", "KH", "CM", "CA", "CV", "KY", "CF",
"TD", "CL", "CN", "CX", "CC", "CO", "KM", "CG", "CD", "CK", "CR", "CI", "HR", "CU", "CW", "CY", "CZ", "DK",
"DJ", "DM", "DO", "EC", "EG", "SV", "GQ", "ER", "EE", "ET", "FK", "FO", "FJ", "FI", "FR", "GF", "PF", "TF",
"GA", "GM", "GE", "DE", "GH", "GI", "GR", "GL", "GD", "GP", "GU", "GT", "GG", "GN", "GW", "GY", "HT", "HM",
"VA", "HN", "HK", "HU", "IS", "IN", "ID", "IR", "IQ", "IE", "IM", "IL", "IT", "JM", "JP", "JE", "JO", "KZ",
"KE", "KI", "KP", "KR", "KW", "KG", "LA", "LV", "LB", "LS", "LR", "LY", "LI", "LT", "LU", "MO", "MK", "MG",
"MW", "MY", "MV", "ML", "MT", "MH", "MQ", "MR", "MU", "YT", "MX", "FM", "MD", "MC", "MN", "ME", "MS", "MA",
"MZ", "MM", "NA", "NR", "NP", "NL", "NC", "NZ", "NI", "NE", "NG", "NU", "NF", "MP", "NO", "OM", "PK", "PW",
"PS", "PA", "PG", "PY", "PE", "PH", "PN", "PL", "PT", "PR", "QA", "RE", "RO", "RU", "RW", "BL", "SH", "KN",
"LC", "MF", "PM", "VC", "WS", "SM", "ST", "SA", "SN", "RS", "SC", "SL", "SG", "SX", "SK", "SI", "SB", "SO",
"ZA", "GS", "SS", "ES", "LK", "SD", "SR", "SJ", "SZ", "SE", "CH", "SY", "TW", "TJ", "TZ", "TH", "TL", "TG",
"TK", "TO", "TT", "TN", "TR", "TM", "TC", "TV", "UG", "UA", "AE", "GB", "US", "UM", "UY", "UZ", "VU", "VE",
"VN", "VG", "VI", "WF", "EH", "YE", "ZM", "ZW");
private final CountryRepository countryService;
@@ -60,8 +55,7 @@ class SampleClient {
@Scheduled(fixedDelay = 500)
public void retrieveCountry() {
String randomCode = SAMPLE_COUNTRY_CODES
.get(this.random.nextInt(SAMPLE_COUNTRY_CODES.size()));
String randomCode = SAMPLE_COUNTRY_CODES.get(this.random.nextInt(SAMPLE_COUNTRY_CODES.size()));
System.out.println("Looking for country with code '" + randomCode + "'");
this.countryService.findByCode(randomCode);
}

View File

@@ -45,33 +45,25 @@ public class GradleIT {
private void test(String name, String expected) throws Exception {
File projectDirectory = new File("target/gradleit/" + name);
File javaDirectory = new File(
"target/gradleit/" + name + "/src/main/java/org/test/");
File javaDirectory = new File("target/gradleit/" + name + "/src/main/java/org/test/");
projectDirectory.mkdirs();
javaDirectory.mkdirs();
File script = new File(projectDirectory, "build.gradle");
FileCopyUtils.copy(new File("src/it/" + name + "/build.gradle"), script);
FileCopyUtils.copy(
new File("src/it/" + name
+ "/src/main/java/org/test/SampleApplication.java"),
FileCopyUtils.copy(new File("src/it/" + name + "/src/main/java/org/test/SampleApplication.java"),
new File(javaDirectory, "SampleApplication.java"));
GradleConnector gradleConnector = GradleConnector.newConnector();
gradleConnector.useGradleVersion("2.9");
((DefaultGradleConnector) gradleConnector).embedded(true);
ProjectConnection project = gradleConnector.forProjectDirectory(projectDirectory)
.connect();
project.newBuild().forTasks("clean", "build").setStandardOutput(System.out)
.setStandardError(System.err)
ProjectConnection project = gradleConnector.forProjectDirectory(projectDirectory).connect();
project.newBuild().forTasks("clean", "build").setStandardOutput(System.out).setStandardError(System.err)
.withArguments("-PbootVersion=" + getBootVersion()).run();
Verify.verify(
new File("target/gradleit/" + name + "/build/libs/" + name + ".jar"),
expected);
Verify.verify(new File("target/gradleit/" + name + "/build/libs/" + name + ".jar"), expected);
}
public static String getBootVersion() {
return evaluateExpression(
"/*[local-name()='project']/*[local-name()='parent']/*[local-name()='version']"
+ "/text()");
"/*[local-name()='project']/*[local-name()='parent']/*[local-name()='version']" + "/text()");
}
private static String evaluateExpression(String expression) {

View File

@@ -42,8 +42,7 @@ public class Customer {
@Override
public String toString() {
return String.format("Customer[id=%s, firstName='%s', lastName='%s']", this.id,
this.firstName, this.lastName);
return String.format("Customer[id=%s, firstName='%s', lastName='%s']", this.id, this.firstName, this.lastName);
}
}

View File

@@ -22,11 +22,9 @@ import org.slf4j.LoggerFactory;
import org.springframework.core.Ordered;
public class OrderedCassandraTestExecutionListener
extends CassandraUnitDependencyInjectionTestExecutionListener {
public class OrderedCassandraTestExecutionListener extends CassandraUnitDependencyInjectionTestExecutionListener {
private static final Logger logger = LoggerFactory
.getLogger(OrderedCassandraTestExecutionListener.class);
private static final Logger logger = LoggerFactory.getLogger(OrderedCassandraTestExecutionListener.class);
@Override
public int getOrder() {

View File

@@ -59,8 +59,8 @@ public class User {
@Override
public String toString() {
return "User{" + "id='" + this.id + '\'' + ", firstName='" + this.firstName + '\''
+ ", lastName='" + this.lastName + '\'' + '}';
return "User{" + "id='" + this.id + '\'' + ", firstName='" + this.firstName + '\'' + ", lastName='"
+ this.lastName + '\'' + '}';
}
}

View File

@@ -34,8 +34,7 @@ public class SampleCouchbaseApplicationTests {
@Test
public void testDefaultSettings() throws Exception {
try {
new SpringApplicationBuilder(SampleCouchbaseApplication.class)
.run("--server.port=0");
new SpringApplicationBuilder(SampleCouchbaseApplication.class).run("--server.port=0");
}
catch (RuntimeException ex) {
if (serverNotRunning(ex)) {

View File

@@ -19,8 +19,7 @@ package sample.data.elasticsearch;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
@Document(indexName = "customer", type = "customer", shards = 1, replicas = 0,
refreshInterval = "-1")
@Document(indexName = "customer", type = "customer", shards = 1, replicas = 0, refreshInterval = "-1")
public class Customer {
@Id
@@ -64,8 +63,7 @@ public class Customer {
@Override
public String toString() {
return String.format("Customer[id=%s, firstName='%s', lastName='%s']", this.id,
this.firstName, this.lastName);
return String.format("Customer[id=%s, firstName='%s', lastName='%s']", this.id, this.firstName, this.lastName);
}
}

View File

@@ -49,8 +49,7 @@ public class SampleDataGemFireApplication {
private final SampleDataGemFireProperties properties;
public SampleDataGemFireApplication(
SampleDataGemFireProperties applicationProperties) {
public SampleDataGemFireApplication(SampleDataGemFireProperties applicationProperties) {
this.properties = applicationProperties;
}
@@ -64,8 +63,7 @@ public class SampleDataGemFireApplication {
private Properties getCacheProperties() {
Properties properties = new Properties();
properties.setProperty("name",
SampleDataGemFireApplication.class.getSimpleName());
properties.setProperty("name", SampleDataGemFireApplication.class.getSimpleName());
properties.setProperty("mcast-port", "0");
properties.setProperty("locators", "");
properties.setProperty("log-level", this.properties.getLogLevel());

View File

@@ -42,9 +42,8 @@ public class GemstoneServiceImpl implements GemstoneService {
protected static final List<String> APPROVED_GEMS;
static {
APPROVED_GEMS = Collections.unmodifiableList(
Arrays.asList(("ALEXANDRITE,AQUAMARINE,DIAMOND,OPAL,PEARL,"
+ "RUBY,SAPPHIRE,SPINEL,TOPAZ").split(",")));
APPROVED_GEMS = Collections.unmodifiableList(Arrays
.asList(("ALEXANDRITE,AQUAMARINE,DIAMOND,OPAL,PEARL," + "RUBY,SAPPHIRE,SPINEL,TOPAZ").split(",")));
}
private final GemstoneRepository repository;
@@ -120,8 +119,7 @@ public class GemstoneServiceImpl implements GemstoneService {
// in GemFire rather than before to demonstrate transactions in GemFire.
Gemstone savedGemstone = validate(this.repository.save(gemstone));
Assert.state(savedGemstone.equals(get(gemstone.getId())),
String.format("Failed to find Gemstone (%1$s) in "
+ "GemFire's Cache Region 'Gemstones'!", gemstone));
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());
return gemstone;
}
@@ -131,8 +129,7 @@ public class GemstoneServiceImpl implements GemstoneService {
// NOTE if the Gemstone is not valid, throw error...
// 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

@@ -63,8 +63,7 @@ public class SampleDataGemFireApplicationTests {
this.service.save(createGemstone("Pearl"));
this.service.save(createGemstone("Sapphire"));
assertThat(this.service.count()).isEqualTo(4);
assertThat(this.service.list())
.contains(getGemstones("Diamond", "Ruby", "Pearl", "Sapphire"));
assertThat(this.service.list()).contains(getGemstones("Diamond", "Ruby", "Pearl", "Sapphire"));
try {
this.service.save(createGemstone("Quartz"));
}
@@ -72,8 +71,7 @@ public class SampleDataGemFireApplicationTests {
// expected
}
assertThat(this.service.count()).isEqualTo(4);
assertThat(this.service.list())
.contains(getGemstones("Diamond", "Ruby", "Pearl", "Sapphire"));
assertThat(this.service.list()).contains(getGemstones("Diamond", "Ruby", "Pearl", "Sapphire"));
assertThat(this.service.get("Diamond")).isEqualTo(createGemstone("Diamond"));
assertThat(this.service.get("Pearl")).isEqualTo(createGemstone("Pearl"));
}

View File

@@ -26,8 +26,7 @@ interface CityRepository extends Repository<City, Long> {
Page<City> findAll(Pageable pageable);
Page<City> findByNameContainingAndCountryContainingAllIgnoringCase(String name,
String country, Pageable pageable);
Page<City> findByNameContainingAndCountryContainingAllIgnoringCase(String name, String country, Pageable pageable);
City findByNameAndCountryAllIgnoringCase(String name, String country);

View File

@@ -57,9 +57,8 @@ class CityServiceImpl implements CityService {
name = name.substring(0, splitPos);
}
return this.cityRepository
.findByNameContainingAndCountryContainingAllIgnoringCase(name.trim(),
country.trim(), pageable);
return this.cityRepository.findByNameContainingAndCountryContainingAllIgnoringCase(name.trim(), country.trim(),
pageable);
}
@Override

View File

@@ -47,8 +47,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@RunWith(SpringRunner.class)
@SpringBootTest
// Enable JMX so we can test the MBeans (you can't do this in a properties file)
@TestPropertySource(
properties = { "spring.jmx.enabled:true", "spring.datasource.jmx-enabled:true" })
@TestPropertySource(properties = { "spring.jmx.enabled:true", "spring.datasource.jmx-enabled:true" })
@ActiveProfiles("scratch")
// Separate profile for web tests to avoid clashing databases
public class SampleDataJpaApplicationTests {
@@ -66,15 +65,13 @@ public class SampleDataJpaApplicationTests {
@Test
public void testHome() throws Exception {
this.mvc.perform(get("/")).andExpect(status().isOk())
.andExpect(content().string("Bath"));
this.mvc.perform(get("/")).andExpect(status().isOk()).andExpect(content().string("Bath"));
}
@Test
public void testJmx() throws Exception {
assertThat(ManagementFactory.getPlatformMBeanServer()
.queryMBeans(new ObjectName("jpa.sample:type=ConnectionPool,*"), null))
.hasSize(1);
.queryMBeans(new ObjectName("jpa.sample:type=ConnectionPool,*"), null)).hasSize(1);
}
}

View File

@@ -51,15 +51,11 @@ public class HotelRepositoryIntegrationTests {
@Test
public void executesQueryMethodsCorrectly() {
City city = this.cityRepository
.findAll(new PageRequest(0, 1, Direction.ASC, "name")).getContent()
.get(0);
City city = this.cityRepository.findAll(new PageRequest(0, 1, Direction.ASC, "name")).getContent().get(0);
assertThat(city.getName()).isEqualTo("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()).isEqualTo("Doubletree");
List<RatingCount> counts = this.repository.findRatingCounts(hotel);

View File

@@ -37,8 +37,7 @@ public class Customer {
@Override
public String toString() {
return String.format("Customer[id=%s, firstName='%s', lastName='%s']", this.id,
this.firstName, this.lastName);
return String.format("Customer[id=%s, firstName='%s', lastName='%s']", this.id, this.firstName, this.lastName);
}
}

View File

@@ -39,8 +39,7 @@ public class Customer {
@Override
public String toString() {
return String.format("Customer[id=%s, firstName='%s', lastName='%s']", this.id,
this.firstName, this.lastName);
return String.format("Customer[id=%s, firstName='%s', lastName='%s']", this.id, this.firstName, this.lastName);
}
}

View File

@@ -27,11 +27,9 @@ import org.springframework.data.rest.core.annotation.RepositoryRestResource;
@RepositoryRestResource(collectionResourceRel = "cities", path = "cities")
interface CityRepository extends PagingAndSortingRepository<City, Long> {
Page<City> findByNameContainingAndCountryContainingAllIgnoringCase(
@Param("name") String name, @Param("country") String country,
Pageable pageable);
Page<City> findByNameContainingAndCountryContainingAllIgnoringCase(@Param("name") String name,
@Param("country") String country, Pageable pageable);
City findByNameAndCountryAllIgnoringCase(@Param("name") String name,
@Param("country") String country);
City findByNameAndCountryAllIgnoringCase(@Param("name") String name, @Param("country") String country);
}

View File

@@ -61,27 +61,23 @@ public class SampleDataRestApplicationTests {
@Test
public void testHome() throws Exception {
this.mvc.perform(get("/api")).andExpect(status().isOk())
.andExpect(content().string(containsString("hotels")));
this.mvc.perform(get("/api")).andExpect(status().isOk()).andExpect(content().string(containsString("hotels")));
}
@Test
public void findByNameAndCountry() throws Exception {
this.mvc.perform(get(
"/api/cities/search/findByNameAndCountryAllIgnoringCase?name=Melbourne&country=Australia"))
.andExpect(status().isOk())
.andExpect(jsonPath("state", equalTo("Victoria")))
this.mvc.perform(get("/api/cities/search/findByNameAndCountryAllIgnoringCase?name=Melbourne&country=Australia"))
.andExpect(status().isOk()).andExpect(jsonPath("state", equalTo("Victoria")))
.andExpect(jsonPath("name", equalTo("Melbourne")));
}
@Test
public void findByContaining() throws Exception {
this.mvc.perform(get(
"/api/cities/search/findByNameContainingAndCountryContainingAllIgnoringCase?name=&country=UK"))
.andExpect(status().isOk())
.andExpect(jsonPath("_embedded.cities", hasSize(3)));
this.mvc.perform(
get("/api/cities/search/findByNameContainingAndCountryContainingAllIgnoringCase?name=&country=UK"))
.andExpect(status().isOk()).andExpect(jsonPath("_embedded.cities", hasSize(3)));
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2018 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,17 +50,15 @@ public class CityRepositoryIntegrationTests {
@Test
public void findByNameAndCountry() {
City city = this.repository.findByNameAndCountryAllIgnoringCase("Melbourne",
"Australia");
City city = this.repository.findByNameAndCountryAllIgnoringCase("Melbourne", "Australia");
assertThat(city).isNotNull();
assertThat(city.getName()).isEqualTo("Melbourne");
}
@Test
public void findContaining() {
Page<City> cities = this.repository
.findByNameContainingAndCountryContainingAllIgnoringCase("", "UK",
new PageRequest(0, 10));
Page<City> cities = this.repository.findByNameContainingAndCountryContainingAllIgnoringCase("", "UK",
new PageRequest(0, 10));
assertThat(cities.getTotalElements()).isEqualTo(3L);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -94,8 +94,8 @@ public class Product {
@Override
public String toString() {
return "Product [id=" + this.id + ", name=" + this.name + ", price=" + this.price
+ ", category=" + this.category + ", location=" + this.location + "]";
return "Product [id=" + this.id + ", name=" + this.name + ", price=" + this.price + ", category="
+ this.category + ", location=" + this.location + "]";
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,8 +41,7 @@ public class MyController {
sessionVar = new Date();
session.setAttribute("var", sessionVar);
}
ModelMap model = new ModelMap("message", Message.MESSAGE)
.addAttribute("sessionVar", sessionVar);
ModelMap model = new ModelMap("message", Message.MESSAGE).addAttribute("sessionVar", sessionVar);
return new ModelAndView("hello", model);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -46,24 +46,21 @@ public class SampleDevToolsApplicationIntegrationTests {
@Test
public void testStaticResource() throws Exception {
ResponseEntity<String> entity = this.restTemplate
.getForEntity("/css/application.css", String.class);
ResponseEntity<String> entity = this.restTemplate.getForEntity("/css/application.css", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).contains("color: green;");
}
@Test
public void testPublicResource() throws Exception {
ResponseEntity<String> entity = this.restTemplate.getForEntity("/public.txt",
String.class);
ResponseEntity<String> entity = this.restTemplate.getForEntity("/public.txt", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).contains("public file");
}
@Test
public void testClassResource() throws Exception {
ResponseEntity<String> entity = this.restTemplate
.getForEntity("/application.properties", String.class);
ResponseEntity<String> entity = this.restTemplate.getForEntity("/application.properties", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2018 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -49,8 +49,7 @@ public class Person {
@Override
public String toString() {
return "Person [firstName=" + this.firstName + ", lastName=" + this.lastName
+ "]";
return "Person [firstName=" + this.firstName + ", lastName=" + this.lastName + "]";
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,8 +35,7 @@ public class SampleFlywayApplicationTests {
@Test
public void testDefaultSettings() throws Exception {
assertThat(this.template.queryForObject("SELECT COUNT(*) from PERSON",
Integer.class)).isEqualTo(1);
assertThat(this.template.queryForObject("SELECT COUNT(*) from PERSON", Integer.class)).isEqualTo(1);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -48,8 +48,7 @@ public class CustomerController {
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
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

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,11 +42,9 @@ public class SampleHateoasApplicationTests {
@Test
public void hasHalLinks() throws Exception {
ResponseEntity<String> entity = this.restTemplate.getForEntity("/customers/1",
String.class);
ResponseEntity<String> entity = this.restTemplate.getForEntity("/customers/1", String.class);
assertThat(entity.getStatusCode()).isEqualTo(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()).contains("_links\":{\"self\":{\"href\"");
}
@@ -55,8 +53,8 @@ public class SampleHateoasApplicationTests {
HttpHeaders headers = new HttpHeaders();
headers.set(HttpHeaders.ACCEPT, "application/xml;q=0.9,application/json;q=0.8");
HttpEntity<?> request = new HttpEntity<>(headers);
ResponseEntity<String> response = this.restTemplate.exchange("/customers/1",
HttpMethod.GET, request, String.class);
ResponseEntity<String> response = this.restTemplate.exchange("/customers/1", HttpMethod.GET, request,
String.class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(response.getHeaders().getContentType())
.isEqualTo(MediaType.parseMediaType("application/json;charset=UTF-8"));

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,8 +26,7 @@ interface CityRepository extends Repository<City, Long> {
Page<City> findAll(Pageable pageable);
Page<City> findByNameContainingAndCountryContainingAllIgnoringCase(String name,
String country, Pageable pageable);
Page<City> findByNameContainingAndCountryContainingAllIgnoringCase(String name, String country, Pageable pageable);
City findByNameAndCountryAllIgnoringCase(String name, String country);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2018 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -57,9 +57,8 @@ class CityServiceImpl implements CityService {
name = name.substring(0, splitPos);
}
return this.cityRepository
.findByNameContainingAndCountryContainingAllIgnoringCase(name.trim(),
country.trim(), pageable);
return this.cityRepository.findByNameContainingAndCountryContainingAllIgnoringCase(name.trim(), country.trim(),
pageable);
}
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,8 +47,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@RunWith(SpringRunner.class)
@SpringBootTest
// Enable JMX so we can test the MBeans (you can't do this in a properties file)
@TestPropertySource(
properties = { "spring.jmx.enabled:true", "spring.datasource.jmx-enabled:true" })
@TestPropertySource(properties = { "spring.jmx.enabled:true", "spring.datasource.jmx-enabled:true" })
@ActiveProfiles("scratch")
// Separate profile for web tests to avoid clashing databases
public class SampleHibernate4ApplicationTests {
@@ -66,15 +65,13 @@ public class SampleHibernate4ApplicationTests {
@Test
public void testHome() throws Exception {
this.mvc.perform(get("/")).andExpect(status().isOk())
.andExpect(content().string("Bath"));
this.mvc.perform(get("/")).andExpect(status().isOk()).andExpect(content().string("Bath"));
}
@Test
public void testJmx() throws Exception {
assertThat(ManagementFactory.getPlatformMBeanServer()
.queryMBeans(new ObjectName("jpa.sample:type=ConnectionPool,*"), null))
.hasSize(1);
.queryMBeans(new ObjectName("jpa.sample:type=ConnectionPool,*"), null)).hasSize(1);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2018 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -51,15 +51,11 @@ public class HotelRepositoryIntegrationTests {
@Test
public void executesQueryMethodsCorrectly() {
City city = this.cityRepository
.findAll(new PageRequest(0, 1, Direction.ASC, "name")).getContent()
.get(0);
City city = this.cityRepository.findAll(new PageRequest(0, 1, Direction.ASC, "name")).getContent().get(0);
assertThat(city.getName()).isEqualTo("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()).isEqualTo("Doubletree");
List<RatingCount> counts = this.repository.findRatingCounts(hotel);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,8 +26,7 @@ interface CityRepository extends Repository<City, Long> {
Page<City> findAll(Pageable pageable);
Page<City> findByNameContainingAndCountryContainingAllIgnoringCase(String name,
String country, Pageable pageable);
Page<City> findByNameContainingAndCountryContainingAllIgnoringCase(String name, String country, Pageable pageable);
City findByNameAndCountryAllIgnoringCase(String name, String country);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2018 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -57,9 +57,8 @@ class CityServiceImpl implements CityService {
name = name.substring(0, splitPos);
}
return this.cityRepository
.findByNameContainingAndCountryContainingAllIgnoringCase(name.trim(),
country.trim(), pageable);
return this.cityRepository.findByNameContainingAndCountryContainingAllIgnoringCase(name.trim(), country.trim(),
pageable);
}
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,8 +47,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@RunWith(SpringRunner.class)
@SpringBootTest
// Enable JMX so we can test the MBeans (you can't do this in a properties file)
@TestPropertySource(
properties = { "spring.jmx.enabled:true", "spring.datasource.jmx-enabled:true" })
@TestPropertySource(properties = { "spring.jmx.enabled:true", "spring.datasource.jmx-enabled:true" })
@ActiveProfiles("scratch")
// Separate profile for web tests to avoid clashing databases
public class SampleHibernate52ApplicationTests {
@@ -66,15 +65,13 @@ public class SampleHibernate52ApplicationTests {
@Test
public void testHome() throws Exception {
this.mvc.perform(get("/")).andExpect(status().isOk())
.andExpect(content().string("Bath"));
this.mvc.perform(get("/")).andExpect(status().isOk()).andExpect(content().string("Bath"));
}
@Test
public void testJmx() throws Exception {
assertThat(ManagementFactory.getPlatformMBeanServer()
.queryMBeans(new ObjectName("jpa.sample:type=ConnectionPool,*"), null))
.hasSize(1);
.queryMBeans(new ObjectName("jpa.sample:type=ConnectionPool,*"), null)).hasSize(1);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2018 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -51,15 +51,11 @@ public class HotelRepositoryIntegrationTests {
@Test
public void executesQueryMethodsCorrectly() {
City city = this.cityRepository
.findAll(new PageRequest(0, 1, Direction.ASC, "name")).getContent()
.get(0);
City city = this.cityRepository.findAll(new PageRequest(0, 1, Direction.ASC, "name")).getContent().get(0);
assertThat(city.getName()).isEqualTo("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()).isEqualTo("Doubletree");
List<RatingCount> counts = this.repository.findRatingCounts(hotel);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,23 +50,20 @@ public class SampleHypermediaGsonApplicationTests {
@Test
public void health() throws Exception {
this.mockMvc.perform(get("/health").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
this.mockMvc.perform(get("/health").accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk())
.andExpect(jsonPath("$.links[0].href").value("http://localhost/health"))
.andExpect(jsonPath("$.content.status").exists());
}
@Test
public void trace() throws Exception {
this.mockMvc.perform(get("/trace").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk()).andExpect(jsonPath("$.links").doesNotExist())
.andExpect(jsonPath("$").isArray());
this.mockMvc.perform(get("/trace").accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk())
.andExpect(jsonPath("$.links").doesNotExist()).andExpect(jsonPath("$").isArray());
}
@Test
public void envValue() throws Exception {
this.mockMvc.perform(get("/env/user.home").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
this.mockMvc.perform(get("/env/user.home").accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk())
.andExpect(jsonPath("$._links").doesNotExist());
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,35 +42,33 @@ public class SampleHypermediaJpaApplicationIntegrationTests {
@Test
public void links() throws Exception {
this.mockMvc.perform(get("/").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk()).andExpect(jsonPath("$._links").exists());
this.mockMvc.perform(get("/").accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk())
.andExpect(jsonPath("$._links").exists());
}
@Test
public void health() throws Exception {
this.mockMvc.perform(get("/admin/health").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
this.mockMvc.perform(get("/admin/health").accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk())
.andExpect(jsonPath("$._links").doesNotExist());
}
@Test
public void adminLinks() throws Exception {
this.mockMvc.perform(get("/admin").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk()).andExpect(jsonPath("$._links").exists());
this.mockMvc.perform(get("/admin").accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk())
.andExpect(jsonPath("$._links").exists());
}
@Test
public void docs() throws Exception {
MvcResult response = this.mockMvc
.perform(get("/admin/docs/").accept(MediaType.TEXT_HTML))
MvcResult response = this.mockMvc.perform(get("/admin/docs/").accept(MediaType.TEXT_HTML))
.andExpect(status().isOk()).andReturn();
System.err.println(response.getResponse().getContentAsString());
}
@Test
public void browser() throws Exception {
MvcResult response = this.mockMvc.perform(get("/").accept(MediaType.TEXT_HTML))
.andExpect(status().isFound()).andReturn();
MvcResult response = this.mockMvc.perform(get("/").accept(MediaType.TEXT_HTML)).andExpect(status().isFound())
.andReturn();
assertThat(response.getResponse().getHeaders("location").get(0))
.isEqualTo("http://localhost/browser/index.html#/");
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,19 +44,16 @@ public class SampleHypermediaUiSecureApplicationTests {
@Test
public void testInsecureNestedPath() throws Exception {
ResponseEntity<String> entity = this.restTemplate.getForEntity("/env",
String.class);
ResponseEntity<String> entity = this.restTemplate.getForEntity("/env", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
ResponseEntity<String> user = this.restTemplate.getForEntity("/env/foo",
String.class);
ResponseEntity<String> user = this.restTemplate.getForEntity("/env/foo", String.class);
assertThat(user.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(user.getBody()).contains("{\"foo\":");
}
@Test
public void testSecurePath() throws Exception {
ResponseEntity<String> entity = this.restTemplate.getForEntity("/metrics",
String.class);
ResponseEntity<String> entity = this.restTemplate.getForEntity("/metrics", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,8 +44,7 @@ public class SampleHypermediaUiSecureApplicationWithContextPathTests {
@Test
public void testSecurePath() throws Exception {
ResponseEntity<String> entity = this.restTemplate.getForEntity("/admin/metrics",
String.class);
ResponseEntity<String> entity = this.restTemplate.getForEntity("/admin/metrics", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,8 +35,7 @@ import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
properties = { "management.context-path=" })
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { "management.context-path=" })
public class SampleHypermediaUiApplicationTests {
@Autowired
@@ -58,8 +57,8 @@ public class SampleHypermediaUiApplicationTests {
public void linksWithJson() throws Exception {
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
ResponseEntity<String> response = this.restTemplate.exchange("/actuator",
HttpMethod.GET, new HttpEntity<Void>(headers), String.class);
ResponseEntity<String> response = this.restTemplate.exchange("/actuator", HttpMethod.GET,
new HttpEntity<Void>(headers), String.class);
assertThat(response.getBody()).contains("\"_links\":");
}
@@ -67,8 +66,8 @@ public class SampleHypermediaUiApplicationTests {
public void homeWithHtml() throws Exception {
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
ResponseEntity<String> response = this.restTemplate.exchange("/", HttpMethod.GET,
new HttpEntity<Void>(headers), String.class);
ResponseEntity<String> response = this.restTemplate.exchange("/", HttpMethod.GET, new HttpEntity<Void>(headers),
String.class);
assertThat(response.getBody()).contains("Hello World");
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -51,8 +51,8 @@ public class SampleHypermediaApplicationHomePageTests {
public void linksWithJson() throws Exception {
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
ResponseEntity<String> response = this.restTemplate.exchange("/actuator",
HttpMethod.GET, new HttpEntity<Void>(headers), String.class);
ResponseEntity<String> response = this.restTemplate.exchange("/actuator", HttpMethod.GET,
new HttpEntity<Void>(headers), String.class);
assertThat(response.getBody()).contains("\"_links\":");
}
@@ -60,8 +60,8 @@ public class SampleHypermediaApplicationHomePageTests {
public void halWithHtml() throws Exception {
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
ResponseEntity<String> response = this.restTemplate.exchange("/actuator/",
HttpMethod.GET, new HttpEntity<Void>(headers), String.class);
ResponseEntity<String> response = this.restTemplate.exchange("/actuator/", HttpMethod.GET,
new HttpEntity<Void>(headers), String.class);
assertThat(response.getBody()).contains("HAL Browser");
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -54,25 +54,22 @@ public class SampleIntegrationApplication {
@Bean
public FileWritingMessageHandler fileWriter() {
FileWritingMessageHandler writer = new FileWritingMessageHandler(
new File("target/output"));
FileWritingMessageHandler writer = new FileWritingMessageHandler(new File("target/output"));
writer.setExpectReply(false);
return writer;
}
@Bean
public IntegrationFlow integrationFlow(SampleEndpoint endpoint) {
return IntegrationFlows.from(fileReader(), new FixedRatePoller())
.channel(inputChannel()).handle(endpoint).channel(outputChannel())
.handle(fileWriter()).get();
return IntegrationFlows.from(fileReader(), new FixedRatePoller()).channel(inputChannel()).handle(endpoint)
.channel(outputChannel()).handle(fileWriter()).get();
}
public static void main(String[] args) throws Exception {
SpringApplication.run(SampleIntegrationApplication.class, args);
}
private static class FixedRatePoller
implements Consumer<SourcePollingChannelAdapterSpec> {
private static class FixedRatePoller implements Consumer<SourcePollingChannelAdapterSpec> {
@Override
public void accept(SourcePollingChannelAdapterSpec spec) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2018 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -79,42 +79,38 @@ public class SampleIntegrationApplicationTests {
@Test
public void testMessageGateway() throws Exception {
this.context = SpringApplication.run(SampleIntegrationApplication.class,
"testviamg");
this.context = SpringApplication.run(SampleIntegrationApplication.class, "testviamg");
String output = getOutput();
assertThat(output).contains("testviamg");
}
private String getOutput() throws Exception {
Future<String> future = Executors.newSingleThreadExecutor()
.submit(new Callable<String>() {
@Override
public String call() throws Exception {
Resource[] resources = getResourcesWithContent();
while (resources.length == 0) {
Thread.sleep(200);
resources = getResourcesWithContent();
}
StringBuilder builder = new StringBuilder();
for (Resource resource : resources) {
InputStream inputStream = resource.getInputStream();
try {
builder.append(new String(
StreamUtils.copyToByteArray(inputStream)));
}
finally {
inputStream.close();
}
}
return builder.toString();
Future<String> future = Executors.newSingleThreadExecutor().submit(new Callable<String>() {
@Override
public String call() throws Exception {
Resource[] resources = getResourcesWithContent();
while (resources.length == 0) {
Thread.sleep(200);
resources = getResourcesWithContent();
}
StringBuilder builder = new StringBuilder();
for (Resource resource : resources) {
InputStream inputStream = resource.getInputStream();
try {
builder.append(new String(StreamUtils.copyToByteArray(inputStream)));
}
});
finally {
inputStream.close();
}
}
return builder.toString();
}
});
return future.get(30, TimeUnit.SECONDS);
}
private Resource[] getResourcesWithContent() throws IOException {
Resource[] candidates = ResourcePatternUtils
.getResourcePatternResolver(new DefaultResourceLoader())
Resource[] candidates = ResourcePatternUtils.getResourcePatternResolver(new DefaultResourceLoader())
.getResources("file:target/output/**");
for (Resource candidate : candidates) {
if (candidate.contentLength() == 0) {

View File

@@ -30,8 +30,7 @@ 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

@@ -24,9 +24,7 @@ import org.springframework.boot.web.support.SpringBootServletInitializer;
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

@@ -38,23 +38,20 @@ public class SampleJerseyApplicationTests {
@Test
public void contextLoads() {
ResponseEntity<String> entity = this.restTemplate.getForEntity("/hello",
String.class);
ResponseEntity<String> entity = this.restTemplate.getForEntity("/hello", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
}
@Test
public void reverse() {
ResponseEntity<String> entity = this.restTemplate
.getForEntity("/reverse?input=olleh", String.class);
ResponseEntity<String> entity = this.restTemplate.getForEntity("/reverse?input=olleh", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).isEqualTo("hello");
}
@Test
public void validation() {
ResponseEntity<String> entity = this.restTemplate.getForEntity("/reverse",
String.class);
ResponseEntity<String> entity = this.restTemplate.getForEntity("/reverse", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST);
}

View File

@@ -48,8 +48,7 @@ public class SampleJersey1Application {
public FilterRegistrationBean jersey() {
FilterRegistrationBean bean = new FilterRegistrationBean();
bean.setFilter(new ServletContainer());
bean.addInitParameter("com.sun.jersey.config.property.packages",
"com.sun.jersey;sample.jersey1");
bean.addInitParameter("com.sun.jersey.config.property.packages", "com.sun.jersey;sample.jersey1");
return bean;
}

View File

@@ -36,8 +36,7 @@ public class SampleJersey1ApplicationTests {
@Test
public void rootReturnsHelloWorld() {
assertThat(this.restTemplate.getForObject("/", String.class))
.isEqualTo("Hello World");
assertThat(this.restTemplate.getForObject("/", String.class)).isEqualTo("Hello World");
}
}

View File

@@ -47,8 +47,7 @@ public class SampleJettySslApplicationTests {
@Test
public void testHome() throws Exception {
TestRestTemplate testRestTemplate = new TestRestTemplate(HttpClientOption.SSL);
ResponseEntity<String> entity = testRestTemplate
.getForEntity("https://localhost:" + this.port, String.class);
ResponseEntity<String> entity = testRestTemplate.getForEntity("https://localhost:" + this.port, String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).isEqualTo("Hello World");
}

View File

@@ -65,16 +65,13 @@ public class SampleJettyApplicationTests {
requestHeaders.set("Accept-Encoding", "gzip");
HttpEntity<?> requestEntity = new HttpEntity<Object>(requestHeaders);
ResponseEntity<byte[]> entity = this.restTemplate.exchange("/", HttpMethod.GET,
requestEntity, byte[].class);
ResponseEntity<byte[]> entity = this.restTemplate.exchange("/", HttpMethod.GET, requestEntity, byte[].class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
GZIPInputStream inflater = new GZIPInputStream(
new ByteArrayInputStream(entity.getBody()));
GZIPInputStream inflater = new GZIPInputStream(new ByteArrayInputStream(entity.getBody()));
try {
assertThat(StreamUtils.copyToString(inflater, Charset.forName("UTF-8")))
.isEqualTo("Hello World");
assertThat(StreamUtils.copyToString(inflater, Charset.forName("UTF-8"))).isEqualTo("Hello World");
}
finally {
inflater.close();

View File

@@ -64,14 +64,11 @@ public class SampleJetty8ApplicationTests {
HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.set("Accept-Encoding", "gzip");
HttpEntity<?> requestEntity = new HttpEntity<Object>(requestHeaders);
ResponseEntity<byte[]> entity = this.restTemplate.exchange("/", HttpMethod.GET,
requestEntity, byte[].class);
ResponseEntity<byte[]> entity = this.restTemplate.exchange("/", HttpMethod.GET, requestEntity, byte[].class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
GZIPInputStream inflater = new GZIPInputStream(
new ByteArrayInputStream(entity.getBody()));
GZIPInputStream inflater = new GZIPInputStream(new ByteArrayInputStream(entity.getBody()));
try {
assertThat(StreamUtils.copyToString(inflater, Charset.forName("UTF-8")))
.isEqualTo("Hello World");
assertThat(StreamUtils.copyToString(inflater, Charset.forName("UTF-8"))).isEqualTo("Hello World");
}
finally {
inflater.close();

View File

@@ -64,14 +64,11 @@ public class SampleJetty92ApplicationTests {
HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.set("Accept-Encoding", "gzip");
HttpEntity<?> requestEntity = new HttpEntity<Object>(requestHeaders);
ResponseEntity<byte[]> entity = this.restTemplate.exchange("/", HttpMethod.GET,
requestEntity, byte[].class);
ResponseEntity<byte[]> entity = this.restTemplate.exchange("/", HttpMethod.GET, requestEntity, byte[].class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
GZIPInputStream inflater = new GZIPInputStream(
new ByteArrayInputStream(entity.getBody()));
GZIPInputStream inflater = new GZIPInputStream(new ByteArrayInputStream(entity.getBody()));
try {
assertThat(StreamUtils.copyToString(inflater, Charset.forName("UTF-8")))
.isEqualTo("Hello World");
assertThat(StreamUtils.copyToString(inflater, Charset.forName("UTF-8"))).isEqualTo("Hello World");
}
finally {
inflater.close();

View File

@@ -65,16 +65,13 @@ public class SampleJettyApplicationTests {
requestHeaders.set("Accept-Encoding", "gzip");
HttpEntity<?> requestEntity = new HttpEntity<Object>(requestHeaders);
ResponseEntity<byte[]> entity = this.restTemplate.exchange("/", HttpMethod.GET,
requestEntity, byte[].class);
ResponseEntity<byte[]> entity = this.restTemplate.exchange("/", HttpMethod.GET, requestEntity, byte[].class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
GZIPInputStream inflater = new GZIPInputStream(
new ByteArrayInputStream(entity.getBody()));
GZIPInputStream inflater = new GZIPInputStream(new ByteArrayInputStream(entity.getBody()));
try {
assertThat(StreamUtils.copyToString(inflater, Charset.forName("UTF-8")))
.isEqualTo("Hello World");
assertThat(StreamUtils.copyToString(inflater, Charset.forName("UTF-8"))).isEqualTo("Hello World");
}
finally {
inflater.close();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2018 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -62,18 +62,15 @@ public class JooqExamples implements CommandLineRunner {
}
private void jooqSql() {
Query query = this.dsl.select(BOOK.TITLE, AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME)
.from(BOOK).join(AUTHOR).on(BOOK.AUTHOR_ID.equal(AUTHOR.ID))
.where(BOOK.PUBLISHED_IN.equal(2015));
Query query = this.dsl.select(BOOK.TITLE, AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME).from(BOOK).join(AUTHOR)
.on(BOOK.AUTHOR_ID.equal(AUTHOR.ID)).where(BOOK.PUBLISHED_IN.equal(2015));
Object[] bind = query.getBindValues().toArray(new Object[] {});
List<String> list = this.jdbc.query(query.getSQL(), bind,
new RowMapper<String>() {
@Override
public String mapRow(ResultSet rs, int rowNum) throws SQLException {
return rs.getString(1) + " : " + rs.getString(2) + " "
+ rs.getString(3);
}
});
List<String> list = this.jdbc.query(query.getSQL(), bind, new RowMapper<String>() {
@Override
public String mapRow(ResultSet rs, int rowNum) throws SQLException {
return rs.getString(1) + " : " + rs.getString(2) + " " + rs.getString(3);
}
});
System.out.println("jOOQ SQL " + list);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,9 +38,8 @@ public class SampleJooqApplicationTests {
SampleJooqApplication.main(NO_ARGS);
assertThat(this.out.toString()).contains("jOOQ Fetch 1 Greg Turnquest");
assertThat(this.out.toString()).contains("jOOQ Fetch 2 Craig Walls");
assertThat(this.out.toString())
.contains("jOOQ SQL " + "[Learning Spring Boot : Greg Turnquest, "
+ "Spring Boot in Action : Craig Walls]");
assertThat(this.out.toString()).contains(
"jOOQ SQL " + "[Learning Spring Boot : Greg Turnquest, " + "Spring Boot in Action : Craig Walls]");
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,8 +33,7 @@ class JpaNoteRepository implements NoteRepository {
@Override
public List<Note> findAll() {
return this.entityManager.createQuery("SELECT n FROM Note n", Note.class)
.getResultList();
return this.entityManager.createQuery("SELECT n FROM Note n", Note.class).getResultList();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,8 +33,7 @@ class JpaTagRepository implements TagRepository {
@Override
public List<Tag> findAll() {
return this.entityManager.createQuery("SELECT t FROM Tag t", Tag.class)
.getResultList();
return this.entityManager.createQuery("SELECT t FROM Tag t", Tag.class).getResultList();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -55,8 +55,7 @@ public class SampleJpaApplicationTests {
@Test
public void testHome() throws Exception {
this.mvc.perform(get("/")).andExpect(status().isOk())
.andExpect(xpath("//tbody/tr").nodeCount(4));
this.mvc.perform(get("/")).andExpect(status().isOk()).andExpect(xpath("//tbody/tr").nodeCount(4));
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,8 +26,7 @@ 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

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -45,8 +45,7 @@ public class SampleAtomikosApplicationTests {
}
private Condition<String> substring(final int times, final String substring) {
return new Condition<String>(
"containing '" + substring + "' " + times + " times") {
return new Condition<String>("containing '" + substring + "' " + times + " times") {
@Override
public boolean matches(String value) {

View File

@@ -26,8 +26,7 @@ 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

@@ -49,20 +49,17 @@ public class SampleBitronixApplicationTests {
@Test
public void testExposesXaAndNonXa() throws Exception {
ApplicationContext context = SpringApplication
.run(SampleBitronixApplication.class);
ApplicationContext context = SpringApplication.run(SampleBitronixApplication.class);
Object jmsConnectionFactory = context.getBean("jmsConnectionFactory");
Object xaJmsConnectionFactory = context.getBean("xaJmsConnectionFactory");
Object nonXaJmsConnectionFactory = context.getBean("nonXaJmsConnectionFactory");
assertThat(jmsConnectionFactory).isSameAs(xaJmsConnectionFactory);
assertThat(jmsConnectionFactory).isInstanceOf(PoolingConnectionFactory.class);
assertThat(nonXaJmsConnectionFactory)
.isNotInstanceOf(PoolingConnectionFactory.class);
assertThat(nonXaJmsConnectionFactory).isNotInstanceOf(PoolingConnectionFactory.class);
}
private Condition<String> substring(final int times, final String substring) {
return new Condition<String>(
"containing '" + substring + "' " + times + " times") {
return new Condition<String>("containing '" + substring + "' " + times + " times") {
@Override
public boolean matches(String value) {

View File

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

View File

@@ -45,8 +45,7 @@ public class SampleNarayanaApplicationTests {
}
private Condition<String> substring(final int times, final String substring) {
return new Condition<String>(
"containing '" + substring + "' " + times + " times") {
return new Condition<String>("containing '" + substring + "' " + times + " times") {
@Override
public boolean matches(String value) {

View File

@@ -43,16 +43,12 @@ public class SampleLiquibaseApplicationTests {
}
String output = this.outputCapture.toString();
assertThat(output).contains("Successfully acquired change log lock")
.contains("Creating database history "
+ "table with name: PUBLIC.DATABASECHANGELOG")
.contains("Creating database history " + "table with name: PUBLIC.DATABASECHANGELOG")
.contains("Table person created")
.contains("ChangeSet classpath:/db/"
+ "changelog/db.changelog-master.yaml::1::"
+ "marceloverdijk ran successfully")
.contains("New row inserted into person")
.contains("ChangeSet classpath:/db/changelog/"
+ "db.changelog-master.yaml::2::"
.contains("ChangeSet classpath:/db/" + "changelog/db.changelog-master.yaml::1::"
+ "marceloverdijk ran successfully")
.contains("New row inserted into person").contains("ChangeSet classpath:/db/changelog/"
+ "db.changelog-master.yaml::2::" + "marceloverdijk ran successfully")
.contains("Successfully released change log lock");
}

View File

@@ -27,8 +27,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SampleLogbackApplication {
private static final Logger logger = LoggerFactory
.getLogger(SampleLogbackApplication.class);
private static final Logger logger = LoggerFactory.getLogger(SampleLogbackApplication.class);
@PostConstruct
public void logSomething() {

View File

@@ -38,8 +38,7 @@ public class SampleLogbackApplicationTests {
@Test
public void testProfile() throws Exception {
SampleLogbackApplication
.main(new String[] { "--spring.profiles.active=staging" });
SampleLogbackApplication.main(new String[] { "--spring.profiles.active=staging" });
this.outputCapture.expect(containsString("Sample Debug Message"));
this.outputCapture.expect(containsString("Sample Trace Message"));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,8 +33,7 @@ public class SampleController {
private final GaugeService gauges;
public SampleController(HelloWorldProperties helloWorldProperties,
GaugeService gauges) {
public SampleController(HelloWorldProperties helloWorldProperties, GaugeService gauges) {
this.helloWorldProperties = helloWorldProperties;
this.gauges = gauges;
}
@@ -43,8 +42,7 @@ public class SampleController {
@ResponseBody
public Map<String, String> hello() {
this.gauges.submit("timer.test.value", Math.random() * 1000 + 1000);
return Collections.singletonMap("message",
"Hello " + this.helloWorldProperties.getName());
return Collections.singletonMap("message", "Hello " + this.helloWorldProperties.getName());
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2018 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,8 +39,7 @@ public class SampleController {
@GetMapping("/")
@ResponseBody
public Map<String, String> hello() {
return Collections.singletonMap("message",
"Hello " + this.helloWorldProperties.getName());
return Collections.singletonMap("message", "Hello " + this.helloWorldProperties.getName());
}
protected static class Message {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,8 +33,7 @@ public class AggregateMetricsConfiguration {
private final RedisConnectionFactory connectionFactory;
public AggregateMetricsConfiguration(MetricExportProperties export,
RedisConnectionFactory connectionFactory) {
public AggregateMetricsConfiguration(MetricExportProperties export, RedisConnectionFactory connectionFactory) {
this.export = export;
this.connectionFactory = connectionFactory;
}
@@ -45,14 +44,12 @@ public class AggregateMetricsConfiguration {
}
private MetricReader globalMetricsForAggregation() {
return new RedisMetricRepository(this.connectionFactory,
this.export.getRedis().getAggregatePrefix(),
return new RedisMetricRepository(this.connectionFactory, this.export.getRedis().getAggregatePrefix(),
this.export.getRedis().getKey());
}
private MetricReader aggregatesMetricReader() {
AggregateMetricReader repository = new AggregateMetricReader(
globalMetricsForAggregation());
AggregateMetricReader repository = new AggregateMetricReader(globalMetricsForAggregation());
repository.setKeyPattern(this.export.getAggregate().getKeyPattern());
return repository;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2018 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,8 +39,7 @@ public class SampleController {
@GetMapping("/")
@ResponseBody
public Map<String, String> hello() {
return Collections.singletonMap("message",
"Hello " + this.helloWorldProperties.getName());
return Collections.singletonMap("message", "Hello " + this.helloWorldProperties.getName());
}
protected static class Message {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,16 +38,14 @@ public class SampleRedisExportApplication {
@Bean
@ExportMetricWriter
public RedisMetricRepository redisMetricWriter(
RedisConnectionFactory connectionFactory) {
return new RedisMetricRepository(connectionFactory,
this.export.getRedis().getPrefix(), this.export.getRedis().getKey());
public RedisMetricRepository redisMetricWriter(RedisConnectionFactory connectionFactory) {
return new RedisMetricRepository(connectionFactory, this.export.getRedis().getPrefix(),
this.export.getRedis().getKey());
}
@Bean
@ExportMetricWriter
public JmxMetricWriter jmxMetricWriter(
@Qualifier("mbeanExporter") MBeanExporter exporter) {
public JmxMetricWriter jmxMetricWriter(@Qualifier("mbeanExporter") MBeanExporter exporter) {
return new JmxMetricWriter(exporter);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,8 +30,7 @@ import org.springframework.test.context.junit4.SpringRunner;
* @author Dave Syer
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
properties = "spring.jmx.enabled=true")
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = "spring.jmx.enabled=true")
@DirtiesContext
public class SampleRedisExportApplicationTests {

Some files were not shown because too many files have changed in this diff Show More