Skip to content

Commit 7bf5a4a

Browse files
committed
intermediate revision - extracted failing tests into separate project
1 parent 689f9f8 commit 7bf5a4a

8 files changed

Lines changed: 135 additions & 12 deletions

File tree

basic-tests2/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
### Info
2+
3+
Clone of [basic](https://github.com/sergueik/springboot_study/tree/master/basic) with more recent Springboot version for skeleton test work with specific test that leads to other test stability
4+
5+
### Author
6+
[Serguei Kouzmine](kouzmine_serguei@yahoo.com)

basic-tests2/pom.xml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>example</groupId>
5+
<artifactId>basic-tests2</artifactId>
6+
<version>0.1.0-SNAPSHOT</version>
7+
<packaging>jar</packaging>
8+
<name>basic-tests2</name>
9+
<description>Demo Springboot 2.3.x with MVC tests</description>
10+
<parent>
11+
<groupId>org.springframework.boot</groupId>
12+
<artifactId>spring-boot-starter-parent</artifactId>
13+
<version>2.3.4.RELEASE</version>
14+
<relativePath/>
15+
</parent>
16+
<properties>
17+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
18+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
19+
<gson.version>2.8.9</gson.version>
20+
<java.version>1.8</java.version>
21+
<mockito.version>3.10.0</mockito.version>
22+
<finalName>${project.groupId}.${project.artifactId}</finalName>
23+
</properties>
24+
<dependencies>
25+
<dependency>
26+
<groupId>com.google.code.gson</groupId>
27+
<artifactId>gson</artifactId>
28+
<version>${gson.version}</version>
29+
<exclusions>
30+
<exclusion>
31+
<!-- exclude side by side versions of guava jar from gson -->
32+
<groupId>com.google.guava</groupId>
33+
<artifactId>guava</artifactId>
34+
</exclusion>
35+
</exclusions>
36+
</dependency>
37+
<dependency>
38+
<groupId>org.springframework.boot</groupId>
39+
<artifactId>spring-boot-starter-web</artifactId>
40+
</dependency>
41+
<dependency>
42+
<groupId>org.springframework.boot</groupId>
43+
<artifactId>spring-boot-starter-test</artifactId>
44+
<scope>test</scope>
45+
<exclusions>
46+
<exclusion>
47+
<groupId>org.junit.vintage</groupId>
48+
<artifactId>junit-vintage-engine</artifactId>
49+
</exclusion>
50+
</exclusions>
51+
</dependency>
52+
<!--
53+
NOTE: is optional and appearss to just slow down the test execution
54+
-->
55+
<!--
56+
<dependency>
57+
<groupId>org.mockito</groupId>
58+
<artifactId>mockito-junit-jupiter</artifactId>
59+
<version>${mockito.version}</version>
60+
<scope>test</scope>
61+
</dependency>
62+
-->
63+
</dependencies>
64+
<build>
65+
<sourceDirectory>src/main/java</sourceDirectory>
66+
<testSourceDirectory>src/test/java</testSourceDirectory>
67+
<plugins>
68+
<plugin>
69+
<groupId>org.springframework.boot</groupId>
70+
<artifactId>spring-boot-maven-plugin</artifactId>
71+
<configuration>
72+
<finalName>${finalName}</finalName>
73+
</configuration>
74+
</plugin>
75+
</plugins>
76+
</build>
77+
</project>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package example;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
// NOTE: SpringBootApplication cannot be default package
7+
8+
@SpringBootApplication
9+
public class Application {
10+
11+
public static void main(String[] args) {
12+
SpringApplication.run(Application.class, args);
13+
}
14+
}

basic-tests/src/main/java/example/controller/DispatchController.java renamed to basic-tests2/src/main/java/example/controller/DispatchController.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,7 @@
1717
@RestController
1818
@RequestMapping("/dispatch")
1919
public class DispatchController {
20-
// NOTE: somewhat annoying, not reproduced in a clone project with no other
21-
// components but DispatchController SimpleService DispatchControllerTest
22-
// Exception encountered during context initialization -
23-
// cancelling refresh attempt:
24-
// org.springframework.beans.factory.UnsatisfiedDependencyException:
25-
// Error creating bean with name 'dispatchController' defined in file ...
26-
// Unsatisfied dependency expressed through constructor parameter 0;
27-
// nested exception is
28-
// org.springframework.beans.factory.NoSuchBeanDefinitionException:
29-
// No qualifying bean of type 'example.service.SimpleService' available:
30-
// expected at least 1 bean which qualifies as autowire candidate.
31-
// Dependency annotations: {}
20+
3221
@Autowired
3322
private SimpleService simpleService;
3423

basic-tests/src/main/java/example/service/SimpleService.java renamed to basic-tests2/src/main/java/example/service/SimpleService.java

File renamed without changes.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
server.port=8085
2+
3+
example.Property1=data
4+
example.Property3=/tmp
5+
example.Property4=c:\\temp
6+
7+
8+
# TODO: add more profound test of the (lacking) effect of spring settings
9+
# Preferred JSON mapper to use for HTTP message conversion.
10+
# see also:
11+
# https://www.javaguides.net/2019/01/configure-spring-boot-with-gson-or-Jackson-or-json-b.html
12+
spring.http.converters.preferred-json-mapper=gson
13+
# but the correct property is
14+
# see also: https://stackoverflow.com/questions/64050458/force-spingboot-to-use-gson-over-jackson
15+
spring.mvc.converters.preferred-json-mapper=gson
16+
# https://stackoverflow.com/questions/23363843/gson-disablehtmlescaping-why-gson-html-escapes-by-default-in-the-first-place
17+
spring.gson.disable-html-escaping=true
18+
# see also: https://stackoverflow.com/questions/71645903/spring-gson-disable-html-escaping-false-is-not-working-in-spring-boot-applicatio
19+
# NOTE: neither work
20+

basic-tests/src/test/java/example/controller/DispatchControllerTest.java renamed to basic-tests2/src/test/java/example/controller/DispatchControllerTest.java

File renamed without changes.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
example.Property1=test data
2+
example.Property4=d:\\temp
3+
example.Property6=static test data
4+
5+
# TODO: add more profound test of the (lacking) effect of spring settings
6+
# Preferred JSON mapper to use for HTTP message conversion.
7+
# see also:
8+
# https://www.javaguides.net/2019/01/configure-spring-boot-with-gson-or-Jackson-or-json-b.html
9+
# spring.http.converters.preferred-json-mapper=gson
10+
# but the correct property is
11+
# see also: https://stackoverflow.com/questions/64050458/force-spingboot-to-use-gson-over-jackson
12+
# spring.mvc.converters.preferred-json-mapper=gson
13+
# https://stackoverflow.com/questions/23363843/gson-disablehtmlescaping-why-gson-html-escapes-by-default-in-the-first-place
14+
# spring.gson.disable-html-escaping=true
15+
# see also: https://stackoverflow.com/questions/71645903/spring-gson-disable-html-escaping-false-is-not-working-in-spring-boot-applicatio
16+
# NOTE: neither work
17+

0 commit comments

Comments
 (0)