Skip to content

Commit 23b300d

Browse files
committed
Updated to SprinBoot 2.1.2
1 parent 16b4b8d commit 23b300d

File tree

42 files changed

+411
-52
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+411
-52
lines changed

web_ejem1/pom.xml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
34
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
45
<modelVersion>4.0.0</modelVersion>
56

67
<groupId>es.urjc.code</groupId>
78
<artifactId>web_ejem1</artifactId>
8-
<version>0.0.1-SNAPSHOT</version>
9+
<version>0.1.0-SNAPSHOT</version>
910
<packaging>jar</packaging>
1011

1112
<parent>
1213
<groupId>org.springframework.boot</groupId>
1314
<artifactId>spring-boot-starter-parent</artifactId>
14-
<version>1.4.1.RELEASE</version>
15-
<relativePath/>
15+
<version>2.1.2.RELEASE</version>
16+
<relativePath />
1617
</parent>
1718

1819
<properties>
@@ -28,7 +29,14 @@
2829
<dependency>
2930
<groupId>org.springframework.boot</groupId>
3031
<artifactId>spring-boot-starter-web</artifactId>
31-
</dependency>
32+
</dependency>
33+
34+
<!-- Test dependencies -->
35+
<dependency>
36+
<groupId>org.springframework.boot</groupId>
37+
<artifactId>spring-boot-starter-test</artifactId>
38+
<scope>test</scope>
39+
</dependency>
3240
</dependencies>
3341

3442
</project>

web_ejem1/src/main/java/es/urjc/code/daw/GreetingController.java

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

33
import org.springframework.stereotype.Controller;
44
import org.springframework.ui.Model;
5-
import org.springframework.web.bind.annotation.RequestMapping;
5+
import org.springframework.web.bind.annotation.GetMapping;
66

77
@Controller
88
public class GreetingController {
99

10-
@RequestMapping("/greeting")
10+
@GetMapping("/greeting")
1111
public String greeting(Model model) {
1212

1313
model.addAttribute("name", "World");
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
spring.mustache.suffix=.html
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package es.urjc.code.daw;
2+
3+
import static org.assertj.core.api.Assertions.assertThat;
4+
5+
import org.junit.Test;
6+
import org.junit.runner.RunWith;
7+
import org.springframework.beans.factory.annotation.Autowired;
8+
import org.springframework.boot.test.context.SpringBootTest;
9+
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
10+
import org.springframework.boot.test.web.client.TestRestTemplate;
11+
import org.springframework.boot.web.server.LocalServerPort;
12+
import org.springframework.test.context.junit4.SpringRunner;
13+
14+
@RunWith(SpringRunner.class)
15+
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
16+
public class GreetingControllerTest {
17+
18+
@LocalServerPort
19+
private int port;
20+
21+
@Autowired
22+
GreetingController controller;
23+
24+
@Autowired
25+
private TestRestTemplate restTemplate;
26+
27+
@Test
28+
public void test() {
29+
30+
assertThat(controller).isNotNull();
31+
32+
assertThat(this.restTemplate.getForObject("http://localhost:" + port + "/greeting",
33+
String.class)).contains("Hello, World");
34+
}
35+
36+
}

web_ejem2/pom.xml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
<groupId>es.urjc.code</groupId>
77
<artifactId>web_ejem2</artifactId>
8-
<version>0.0.1-SNAPSHOT</version>
8+
<version>0.1.0-SNAPSHOT</version>
99
<packaging>jar</packaging>
1010

1111
<parent>
1212
<groupId>org.springframework.boot</groupId>
1313
<artifactId>spring-boot-starter-parent</artifactId>
14-
<version>1.4.1.RELEASE</version>
14+
<version>2.1.2.RELEASE</version>
1515
<relativePath/>
1616
</parent>
1717

@@ -29,6 +29,13 @@
2929
<groupId>org.springframework.boot</groupId>
3030
<artifactId>spring-boot-starter-web</artifactId>
3131
</dependency>
32+
33+
<!-- Test dependencies -->
34+
<dependency>
35+
<groupId>org.springframework.boot</groupId>
36+
<artifactId>spring-boot-starter-test</artifactId>
37+
<scope>test</scope>
38+
</dependency>
3239
</dependencies>
3340

3441
</project>

web_ejem2/src/main/java/es/urjc/code/daw/GreetingController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
import org.springframework.beans.factory.annotation.Autowired;
44
import org.springframework.stereotype.Controller;
55
import org.springframework.ui.Model;
6-
import org.springframework.web.bind.annotation.RequestMapping;
6+
import org.springframework.web.bind.annotation.GetMapping;
77

88
@Controller
99
public class GreetingController {
1010

1111
@Autowired
1212
private UserService usersService;
1313

14-
@RequestMapping("/greeting")
14+
@GetMapping("/greeting")
1515
public String greeting(Model model) {
1616

1717
model.addAttribute("name", usersService.getNumUsers() + " users");
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
spring.mustache.suffix=.html
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package es.urjc.code.daw;
2+
3+
import static org.assertj.core.api.Assertions.assertThat;
4+
5+
import org.junit.Test;
6+
import org.junit.runner.RunWith;
7+
import org.springframework.beans.factory.annotation.Autowired;
8+
import org.springframework.boot.test.context.SpringBootTest;
9+
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
10+
import org.springframework.boot.test.web.client.TestRestTemplate;
11+
import org.springframework.boot.web.server.LocalServerPort;
12+
import org.springframework.test.context.junit4.SpringRunner;
13+
14+
@RunWith(SpringRunner.class)
15+
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
16+
public class GreetingControllerTest {
17+
18+
@LocalServerPort
19+
private int port;
20+
21+
@Autowired
22+
GreetingController controller;
23+
24+
@Autowired
25+
private TestRestTemplate restTemplate;
26+
27+
@Test
28+
public void test() {
29+
30+
assertThat(controller).isNotNull();
31+
32+
assertThat(this.restTemplate.getForObject("http://localhost:" + port + "/greeting",
33+
String.class)).contains("Hello, 5 users");
34+
}
35+
36+
}

web_ejem3/pom.xml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
34
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
45
<modelVersion>4.0.0</modelVersion>
56

67
<groupId>es.urjc.code</groupId>
78
<artifactId>web_ejem3</artifactId>
8-
<version>0.0.1-SNAPSHOT</version>
9+
<version>0.1.0-SNAPSHOT</version>
910
<packaging>jar</packaging>
1011

1112
<parent>
1213
<groupId>org.springframework.boot</groupId>
1314
<artifactId>spring-boot-starter-parent</artifactId>
14-
<version>1.4.1.RELEASE</version>
15-
<relativePath/>
15+
<version>2.1.2.RELEASE</version>
16+
<relativePath />
1617
</parent>
1718

1819
<properties>
@@ -29,6 +30,13 @@
2930
<groupId>org.springframework.boot</groupId>
3031
<artifactId>spring-boot-starter-web</artifactId>
3132
</dependency>
33+
34+
<!-- Test dependencies -->
35+
<dependency>
36+
<groupId>org.springframework.boot</groupId>
37+
<artifactId>spring-boot-starter-test</artifactId>
38+
<scope>test</scope>
39+
</dependency>
3240
</dependencies>
33-
41+
3442
</project>

web_ejem3/src/main/java/es/urjc/code/daw/GreetingController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
import org.springframework.beans.factory.annotation.Autowired;
44
import org.springframework.stereotype.Controller;
55
import org.springframework.ui.Model;
6-
import org.springframework.web.bind.annotation.RequestMapping;
6+
import org.springframework.web.bind.annotation.GetMapping;
77

88
@Controller
99
public class GreetingController {
1010

1111
@Autowired
1212
private UserService usersService;
1313

14-
@RequestMapping("/greeting")
14+
@GetMapping("/greeting")
1515
public String greeting(Model model) {
1616

1717
model.addAttribute("name", usersService.getNumUsers() + " users");

0 commit comments

Comments
 (0)