Skip to content

Commit b7c0a75

Browse files
authored
add test plan for runtime class entry. (#405)
1 parent f05341a commit b7c0a75

File tree

9 files changed

+190
-0
lines changed

9 files changed

+190
-0
lines changed

TestPlan.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,3 +429,11 @@ Exception in thread "main" java.lang.IllegalStateException
429429
CustomEnv: This env is for test plan.
430430
SystemPath: <value of PATH >
431431
```
432+
433+
## Runtime classpath entry
434+
1. Open `27.runtimeClassEntry` in vscode.
435+
2. Press <kbd>F5</kbd> to start.
436+
3. Verify the output in Debug Console should be as following:
437+
```
438+
Tomcat started on port(s): 8080 (http)
439+
```
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>com.github.kdvolder</groupId>
7+
<artifactId>hello-world-service</artifactId>
8+
<version>0.0.1-SNAPSHOT</version>
9+
<packaging>jar</packaging>
10+
11+
<name>demo</name>
12+
<description>Demo project for Spring Boot</description>
13+
14+
<parent>
15+
<groupId>org.springframework.boot</groupId>
16+
<artifactId>spring-boot-starter-parent</artifactId>
17+
<version>2.0.0.RELEASE</version>
18+
<relativePath/> <!-- lookup parent from repository -->
19+
</parent>
20+
21+
<properties>
22+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
23+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
24+
<java.version>1.8</java.version>
25+
</properties>
26+
27+
<dependencies>
28+
<dependency>
29+
<groupId>org.springframework.boot</groupId>
30+
<artifactId>spring-boot-starter-actuator</artifactId>
31+
</dependency>
32+
<dependency>
33+
<groupId>org.springframework.boot</groupId>
34+
<artifactId>spring-boot-starter-web</artifactId>
35+
</dependency>
36+
<dependency>
37+
<groupId>org.springframework.boot</groupId>
38+
<artifactId>spring-boot-starter-test</artifactId>
39+
<scope>test</scope>
40+
</dependency>
41+
<dependency>
42+
<groupId>org.springframework.boot</groupId>
43+
<artifactId>spring-boot-devtools</artifactId>
44+
<scope>runtime</scope>
45+
</dependency>
46+
<dependency>
47+
<groupId>org.springframework.boot</groupId>
48+
<artifactId>spring-boot-configuration-processor</artifactId>
49+
<optional>true</optional>
50+
</dependency>
51+
</dependencies>
52+
53+
<build>
54+
<plugins>
55+
<plugin>
56+
<groupId>org.springframework.boot</groupId>
57+
<artifactId>spring-boot-maven-plugin</artifactId>
58+
</plugin>
59+
</plugins>
60+
</build>
61+
62+
63+
</project>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.github.kdvolder.helloworldservice;
2+
3+
public class Constants {
4+
public static final String GREETER_ID = "greeets";
5+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package com.github.kdvolder.helloworldservice;
2+
3+
import org.springframework.beans.factory.annotation.Autowired;
4+
import org.springframework.beans.factory.annotation.Qualifier;
5+
import org.springframework.boot.SpringApplication;
6+
import org.springframework.boot.autoconfigure.SpringBootApplication;
7+
import org.springframework.context.annotation.Bean;
8+
import org.springframework.scheduling.annotation.EnableScheduling;
9+
import org.springframework.web.bind.annotation.GetMapping;
10+
import org.springframework.web.bind.annotation.PathVariable;
11+
import org.springframework.web.bind.annotation.RestController;
12+
13+
14+
@SpringBootApplication
15+
@RestController
16+
@EnableScheduling
17+
public class DemoApplication {
18+
19+
public static class Bar {
20+
}
21+
22+
public static class Foo {
23+
}
24+
25+
@Autowired(required=false) void foo(@Qualifier("foobar")Foo foo) {
26+
System.out.println("a Foo got injected");
27+
}
28+
29+
@Autowired(required=false) void bar(@Qualifier("foobar")Bar bar) {
30+
System.out.println("a Bar got injected");
31+
}
32+
33+
public static void main(String[] args) {
34+
SpringApplication.run(DemoApplication.class, args);
35+
}
36+
37+
@GetMapping(value="/")
38+
public String mainpage() {
39+
return "Hello "+System.getProperty("greeting");
40+
}
41+
42+
43+
@GetMapping(value = "/hello/{name}")
44+
public String getMethodName(@PathVariable String name) {
45+
return "Hello "+name;
46+
}
47+
48+
49+
@Bean Foo foobar() {
50+
return new Foo();
51+
}
52+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.github.kdvolder.helloworldservice;
2+
3+
import org.springframework.stereotype.Component;
4+
5+
6+
@Component
7+
public class Greeter {
8+
9+
String greeting(String name) {
10+
return "Hello "+name;
11+
}
12+
13+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.github.kdvolder.helloworldservice;
2+
3+
import org.springframework.boot.context.properties.ConfigurationProperties;
4+
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
5+
6+
@ConfigurationProperties("my")
7+
public class MyProperties {
8+
9+
private String hello;
10+
11+
/**
12+
* @return the hello
13+
*/
14+
@DeprecatedConfigurationProperty(replacement="new.my.hello")
15+
public String getHello() {
16+
return hello;
17+
}
18+
19+
/**
20+
* @param hello the hello to set
21+
*/
22+
public void setHello(String hello) {
23+
this.hello = hello;
24+
}
25+
26+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
my.hello=Yadaya
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
my:
2+
other: stuff
3+
hello: blah
4+
new:
5+
my:
6+
other: stuff
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.github.kdvolder.helloworldservice;
2+
3+
import org.junit.Test;
4+
import org.junit.runner.RunWith;
5+
import org.springframework.boot.test.context.SpringBootTest;
6+
import org.springframework.test.context.junit4.SpringRunner;
7+
8+
@RunWith(SpringRunner.class)
9+
@SpringBootTest
10+
public class DemoApplicationTests {
11+
12+
@Test
13+
public void contextLoads() {
14+
}
15+
16+
}

0 commit comments

Comments
 (0)