Skip to content

Commit 2d70daf

Browse files
committed
Merge pull request #17100 from ielatif
* pr/17100: Polish "Add JUnit 4 and the Vintage Engine sample" Add JUnit 4 and the Vintage Engine sample Closes gh-17100
2 parents dfa5480 + 900c325 commit 2d70daf

File tree

6 files changed

+131
-0
lines changed

6 files changed

+131
-0
lines changed

spring-boot-samples/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
<module>spring-boot-sample-jta-bitronix</module>
5858
<module>spring-boot-sample-jta-jndi</module>
5959
<module>spring-boot-sample-junit-jupiter</module>
60+
<module>spring-boot-sample-junit-vintage</module>
6061
<module>spring-boot-sample-kafka</module>
6162
<module>spring-boot-sample-liquibase</module>
6263
<module>spring-boot-sample-logback</module>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?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"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<!-- Your own application should inherit from spring-boot-starter-parent -->
7+
<groupId>org.springframework.boot</groupId>
8+
<artifactId>spring-boot-samples</artifactId>
9+
<version>${revision}</version>
10+
</parent>
11+
<artifactId>spring-boot-sample-junit-vintage</artifactId>
12+
<name>Spring Boot JUnit Vintage Sample</name>
13+
<description>Spring Boot JUnit Vintage Sample</description>
14+
<properties>
15+
<main.basedir>${basedir}/../..</main.basedir>
16+
</properties>
17+
<dependencies>
18+
<dependency>
19+
<groupId>org.springframework.boot</groupId>
20+
<artifactId>spring-boot-starter-web</artifactId>
21+
</dependency>
22+
<dependency>
23+
<groupId>org.springframework.boot</groupId>
24+
<artifactId>spring-boot-starter-test</artifactId>
25+
<scope>test</scope>
26+
</dependency>
27+
</dependencies>
28+
</project>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright 2012-2019 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package sample;
18+
19+
import org.springframework.web.bind.annotation.GetMapping;
20+
import org.springframework.web.bind.annotation.RestController;
21+
22+
@RestController
23+
class MessageController {
24+
25+
@GetMapping("/hi")
26+
public String hello() {
27+
return "Hello World";
28+
}
29+
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2012-2019 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package sample;
18+
19+
import org.springframework.boot.SpringApplication;
20+
import org.springframework.boot.autoconfigure.SpringBootApplication;
21+
22+
@SpringBootApplication
23+
public class SampleJunitVintageApplication {
24+
25+
public static void main(String[] args) {
26+
SpringApplication.run(SampleJunitVintageApplication.class, args);
27+
}
28+
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright 2012-2019 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package sample;
18+
19+
import org.junit.Test;
20+
import org.junit.runner.RunWith;
21+
22+
import org.springframework.beans.factory.annotation.Autowired;
23+
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
24+
import org.springframework.test.context.junit4.SpringRunner;
25+
import org.springframework.test.web.servlet.MockMvc;
26+
27+
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
28+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
29+
30+
@RunWith(SpringRunner.class)
31+
@WebMvcTest
32+
public class SampleJunitVintageApplicationTests {
33+
34+
@Autowired
35+
private MockMvc mockMvc;
36+
37+
@Test
38+
public void testMessage() throws Exception {
39+
this.mockMvc.perform(get("/hi")).andExpect(content().string("Hello World"));
40+
}
41+
42+
}

src/checkstyle/checkstyle-suppressions.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,5 @@
4444
<suppress files="JavaLoggingSystemTests" checks="SpringJUnit5" />
4545
<suppress files="Log4J2LoggingSystemTests" checks="SpringJUnit5" />
4646
<suppress files="RestClientTestWithComponentIntegrationTests" checks="SpringJUnit5" />
47+
<suppress files="SampleJunitVintageApplicationTests" checks="SpringJUnit5" />
4748
</suppressions>

0 commit comments

Comments
 (0)