Skip to content

Commit eb7650e

Browse files
author
eugenp
committed
cleanup and testing work
1 parent 2aa2f43 commit eb7650e

24 files changed

Lines changed: 259 additions & 271 deletions

‎guava18/pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<dependency>
1818
<groupId>junit</groupId>
1919
<artifactId>junit</artifactId>
20-
<version>4.13</version>
20+
<version>4.12</version>
2121
<scope>test</scope>
2222
</dependency>
2323
</dependencies>

‎pom.xml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
<!-- <module>gatling</module> --> <!-- not meant to run as part of the standard build -->
3535

3636
<module>gson</module>
37-
<module>gson-jackson-performance</module>
3837
<module>guava</module>
3938
<module>guava18</module>
4039
<module>guava19</module>

‎spring-mvc-java/pom.xml‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<version>0.1-SNAPSHOT</version>
77
<name>spring-mvc-java</name>
88
<packaging>war</packaging>
9-
9+
1010
<dependencies>
1111
<!-- Spring -->
1212
<dependency>
@@ -35,7 +35,7 @@
3535
<artifactId>spring-messaging</artifactId>
3636
<version>${org.springframework.version}</version>
3737
</dependency>
38-
38+
3939
<!-- Jackson -->
4040
<dependency>
4141
<groupId>com.fasterxml.jackson.core</groupId>
@@ -56,7 +56,7 @@
5656
<version>1.2</version>
5757
<scope>runtime</scope>
5858
</dependency>
59-
59+
6060
<!-- AOP -->
6161
<dependency>
6262
<groupId>org.springframework</groupId>
@@ -80,6 +80,11 @@
8080
<artifactId>commons-fileupload</artifactId>
8181
<version>1.3.1</version>
8282
</dependency>
83+
<dependency>
84+
<groupId>net.sourceforge.htmlunit</groupId>
85+
<artifactId>htmlunit</artifactId>
86+
<version>${net.sourceforge.htmlunit}</version>
87+
</dependency>
8388

8489
<!-- Thymeleaf -->
8590
<dependency>
@@ -196,7 +201,7 @@
196201
<version>${maven-surefire-plugin.version}</version>
197202
<configuration>
198203
<excludes>
199-
<!-- <exclude>**/*ProductionTest.java</exclude> -->
204+
<exclude>**/*IntegrationTest.java</exclude>
200205
</excludes>
201206
<systemPropertyVariables>
202207
<!-- <provPersistenceTarget>h2</provPersistenceTarget> -->
@@ -231,22 +236,22 @@
231236
<org.springframework.security.version>4.0.4.RELEASE</org.springframework.security.version>
232237
<thymeleaf.version>2.1.4.RELEASE</thymeleaf.version>
233238
<jackson.version>2.7.8</jackson.version>
234-
239+
235240
<!-- persistence -->
236241
<hibernate.version>4.3.11.Final</hibernate.version>
237242
<mysql-connector-java.version>5.1.38</mysql-connector-java.version>
238-
243+
239244
<!-- logging -->
240245
<org.slf4j.version>1.7.21</org.slf4j.version>
241246
<logback.version>1.1.5</logback.version>
242247

243248
<!-- various -->
244249
<hibernate-validator.version>5.2.2.Final</hibernate-validator.version>
245-
250+
246251
<!-- util -->
247252
<guava.version>19.0</guava.version>
248253
<commons-lang3.version>3.4</commons-lang3.version>
249-
254+
250255
<!-- testing -->
251256
<org.hamcrest.version>1.3</org.hamcrest.version>
252257
<junit.version>4.12</junit.version>
@@ -255,6 +260,7 @@
255260
<httpclient.version>4.5</httpclient.version>
256261
<rest-assured.version>2.9.0</rest-assured.version>
257262
<net.sourceforge.htmlunit>2.23</net.sourceforge.htmlunit>
263+
258264
<!-- maven plugins -->
259265
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
260266
<maven-war-plugin.version>2.6</maven-war-plugin.version>

‎spring-mvc-java/src/main/java/com/baeldung/model/Message.java‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
public class Message {
44

5-
private String from;
6-
private String text;
5+
private String from;
6+
private String text;
77

8-
public String getText() {
9-
return text;
10-
}
8+
public String getText() {
9+
return text;
10+
}
1111

12-
public String getFrom() {
13-
return from;
14-
}
12+
public String getFrom() {
13+
return from;
14+
}
1515
}

‎spring-mvc-java/src/main/java/com/baeldung/model/OutputMessage.java‎

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@
22

33
public class OutputMessage {
44

5-
private String from;
6-
private String text;
7-
private String time;
5+
private String from;
6+
private String text;
7+
private String time;
88

9-
public OutputMessage(final String from, final String text, final String time) {
9+
public OutputMessage(final String from, final String text, final String time) {
1010

11-
this.from = from;
12-
this.text = text;
13-
this.time = time;
14-
}
11+
this.from = from;
12+
this.text = text;
13+
this.time = time;
14+
}
1515

16-
public String getText() {
17-
return text;
18-
}
16+
public String getText() {
17+
return text;
18+
}
1919

20-
public String getTime() {
21-
return time;
22-
}
20+
public String getTime() {
21+
return time;
22+
}
2323

24-
public String getFrom() {
25-
return from;
26-
}
24+
public String getFrom() {
25+
return from;
26+
}
2727
}

‎spring-mvc-java/src/main/java/com/baeldung/spring/web/config/WebSocketConfig.java‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
@EnableWebSocketMessageBroker
1111
public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
1212

13-
@Override
14-
public void configureMessageBroker(final MessageBrokerRegistry config) {
15-
config.enableSimpleBroker("/topic");
16-
config.setApplicationDestinationPrefixes("/app");
17-
}
13+
@Override
14+
public void configureMessageBroker(final MessageBrokerRegistry config) {
15+
config.enableSimpleBroker("/topic");
16+
config.setApplicationDestinationPrefixes("/app");
17+
}
1818

19-
@Override
20-
public void registerStompEndpoints(final StompEndpointRegistry registry) {
21-
registry.addEndpoint("/chat").withSockJS();
22-
}
19+
@Override
20+
public void registerStompEndpoints(final StompEndpointRegistry registry) {
21+
registry.addEndpoint("/chat").withSockJS();
22+
}
2323

2424
}

‎spring-mvc-java/src/main/java/com/baeldung/web/controller/CompanyController.java‎

Lines changed: 42 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -22,59 +22,55 @@
2222
@Controller
2323
public class CompanyController {
2424

25-
Map<Long, Company> companyMap = new HashMap<>();
25+
Map<Long, Company> companyMap = new HashMap<>();
2626

27-
@RequestMapping(value = "/company", method = RequestMethod.GET)
28-
public ModelAndView showForm() {
29-
return new ModelAndView("companyHome", "company", new Company());
30-
}
27+
@RequestMapping(value = "/company", method = RequestMethod.GET)
28+
public ModelAndView showForm() {
29+
return new ModelAndView("companyHome", "company", new Company());
30+
}
3131

32-
@RequestMapping(value = "/company/{Id}", produces = { "application/json",
33-
"application/xml" }, method = RequestMethod.GET)
34-
public @ResponseBody Company getCompanyById(@PathVariable final long Id) {
35-
return companyMap.get(Id);
36-
}
32+
@RequestMapping(value = "/company/{Id}", produces = { "application/json", "application/xml" }, method = RequestMethod.GET)
33+
public @ResponseBody Company getCompanyById(@PathVariable final long Id) {
34+
return companyMap.get(Id);
35+
}
3736

38-
@RequestMapping(value = "/addCompany", method = RequestMethod.POST)
39-
public String submit(@ModelAttribute("company") final Company company,
40-
final BindingResult result, final ModelMap model) {
41-
if (result.hasErrors()) {
42-
return "error";
43-
}
44-
model.addAttribute("name", company.getName());
45-
model.addAttribute("id", company.getId());
37+
@RequestMapping(value = "/addCompany", method = RequestMethod.POST)
38+
public String submit(@ModelAttribute("company") final Company company, final BindingResult result, final ModelMap model) {
39+
if (result.hasErrors()) {
40+
return "error";
41+
}
42+
model.addAttribute("name", company.getName());
43+
model.addAttribute("id", company.getId());
4644

47-
companyMap.put(company.getId(), company);
45+
companyMap.put(company.getId(), company);
4846

49-
return "companyView";
50-
}
47+
return "companyView";
48+
}
5149

52-
@RequestMapping(value = "/companyEmployee/{company}/employeeData/{employee}", method = RequestMethod.GET)
53-
@ResponseBody
54-
public ResponseEntity<Map<String, String>> getEmployeeDataFromCompany(
55-
@MatrixVariable(pathVar = "employee") final Map<String, String> matrixVars) {
56-
return new ResponseEntity<>(matrixVars, HttpStatus.OK);
57-
}
50+
@RequestMapping(value = "/companyEmployee/{company}/employeeData/{employee}", method = RequestMethod.GET)
51+
@ResponseBody
52+
public ResponseEntity<Map<String, String>> getEmployeeDataFromCompany(@MatrixVariable(pathVar = "employee") final Map<String, String> matrixVars) {
53+
return new ResponseEntity<>(matrixVars, HttpStatus.OK);
54+
}
5855

59-
@RequestMapping(value = "/companyData/{company}/employeeData/{employee}", method = RequestMethod.GET)
60-
@ResponseBody
61-
public ResponseEntity<Map<String, String>> getCompanyName(
62-
@MatrixVariable(value = "name", pathVar = "company") final String name) {
63-
final Map<String, String> result = new HashMap<String, String>();
64-
result.put("name", name);
65-
return new ResponseEntity<>(result, HttpStatus.OK);
66-
}
56+
@RequestMapping(value = "/companyData/{company}/employeeData/{employee}", method = RequestMethod.GET)
57+
@ResponseBody
58+
public ResponseEntity<Map<String, String>> getCompanyName(@MatrixVariable(value = "name", pathVar = "company") final String name) {
59+
final Map<String, String> result = new HashMap<String, String>();
60+
result.put("name", name);
61+
return new ResponseEntity<>(result, HttpStatus.OK);
62+
}
6763

68-
@RequestMapping(value = "/companyResponseBody", produces = MediaType.APPLICATION_JSON_VALUE)
69-
@ResponseBody
70-
public Company getCompanyResponseBody() {
71-
final Company company = new Company(2, "ABC");
72-
return company;
73-
}
64+
@RequestMapping(value = "/companyResponseBody", produces = MediaType.APPLICATION_JSON_VALUE)
65+
@ResponseBody
66+
public Company getCompanyResponseBody() {
67+
final Company company = new Company(2, "ABC");
68+
return company;
69+
}
7470

75-
@RequestMapping(value = "/companyResponseEntity", produces = MediaType.APPLICATION_JSON_VALUE)
76-
public ResponseEntity<Company> getCompanyResponseEntity() {
77-
final Company company = new Company(3, "123");
78-
return new ResponseEntity<Company>(company, HttpStatus.OK);
79-
}
71+
@RequestMapping(value = "/companyResponseEntity", produces = MediaType.APPLICATION_JSON_VALUE)
72+
public ResponseEntity<Company> getCompanyResponseEntity() {
73+
final Company company = new Company(3, "123");
74+
return new ResponseEntity<Company>(company, HttpStatus.OK);
75+
}
8076
}

‎spring-mvc-java/src/main/java/com/baeldung/web/controller/EmployeeController.java‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ public ModelAndView showForm() {
3131
return new ModelAndView("employeeHome", "employee", new Employee());
3232
}
3333

34-
@RequestMapping(value = "/employee/{Id}", produces = {"application/json", "application/xml"}, method = RequestMethod.GET)
35-
public
36-
@ResponseBody
37-
Employee getEmployeeById(@PathVariable final long Id) {
34+
@RequestMapping(value = "/employee/{Id}", produces = { "application/json", "application/xml" }, method = RequestMethod.GET)
35+
public @ResponseBody Employee getEmployeeById(@PathVariable final long Id) {
3836
return employeeMap.get(Id);
3937
}
4038

‎spring-mvc-java/src/main/java/com/baeldung/web/controller/MessageController.java‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
@RequestMapping("/message")
1111
public class MessageController {
1212

13-
@RequestMapping(value = "/showForm", method = RequestMethod.GET)
14-
public String showForm() {
15-
return "message";
16-
}
13+
@RequestMapping(value = "/showForm", method = RequestMethod.GET)
14+
public String showForm() {
15+
return "message";
16+
}
1717

18-
@RequestMapping(value = "/processForm", method = RequestMethod.POST)
19-
public String processForm(@RequestParam("message") final String message, final Model model) {
20-
model.addAttribute("message", message);
21-
return "message";
22-
}
18+
@RequestMapping(value = "/processForm", method = RequestMethod.POST)
19+
public String processForm(@RequestParam("message") final String message, final Model model) {
20+
model.addAttribute("message", message);
21+
return "message";
22+
}
2323

2424
}

‎spring-mvc-java/src/main/java/com/baeldung/web/controller/advice/JsonpControllerAdvice.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
@ControllerAdvice
77
public class JsonpControllerAdvice extends AbstractJsonpResponseBodyAdvice {
88

9-
public JsonpControllerAdvice() {
10-
super("callback");
11-
}
9+
public JsonpControllerAdvice() {
10+
super("callback");
11+
}
1212

1313
}

0 commit comments

Comments
 (0)