Skip to content

Commit 471ed5d

Browse files
author
Eugen Paraschiv
committed
new client project, general cleanup, testing work
1 parent 819e9fe commit 471ed5d

15 files changed

Lines changed: 393 additions & 7 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#folders#
2+
.idea
3+
/target
4+
/neoDb*
5+
/data
6+
/src/main/webapp/WEB-INF/classes
7+
*/META-INF/*
8+
9+
# Packaged files #
10+
*.jar
11+
*.war
12+
*.ear

‎spring-5-reactive-client/README.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## Spring REST Example Project
2+
3+
### The Course
4+
The "REST With Spring" Classes: http://bit.ly/restwithspring
5+
6+
### Relevant Articles
7+
8+
- [Concurrent Test Execution in Spring 5](http://www.baeldung.com/spring-5-concurrent-tests)
9+
- [Introduction to the Functional Web Framework in Spring 5](http://www.baeldung.com/spring-5-functional-web)
10+
- [Exploring the Spring 5 MVC URL Matching Improvements](http://www.baeldung.com/spring-5-mvc-url-matching)
11+
- [Spring 5 WebClient](http://www.baeldung.com/spring-5-webclient)
12+
- [Spring 5 Functional Bean Registration](http://www.baeldung.com/spring-5-functional-beans)
13+
- [The SpringJUnitConfig and SpringJUnitWebConfig Annotations in Spring 5](http://www.baeldung.com/spring-5-junit-config)
14+
- [Spring Security 5 for Reactive Applications](http://www.baeldung.com/spring-security-5-reactive)
15+
- [Spring 5 Testing with @EnabledIf Annotation](https://github.com/eugenp/tutorials/tree/master/spring-5)

‎spring-5-reactive-client/pom.xml‎

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
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+
5+
<groupId>com.baeldung</groupId>
6+
<artifactId>spring-5-reactive-client</artifactId>
7+
<version>0.0.1-SNAPSHOT</version>
8+
<packaging>jar</packaging>
9+
10+
<name>spring-5</name>
11+
<description>spring 5 sample project about new features</description>
12+
13+
<parent>
14+
<groupId>org.springframework.boot</groupId>
15+
<artifactId>spring-boot-starter-parent</artifactId>
16+
<version>2.0.0.M7</version>
17+
<relativePath /> <!-- lookup parent from repository -->
18+
</parent>
19+
20+
<dependencies>
21+
<dependency>
22+
<groupId>org.springframework.boot</groupId>
23+
<artifactId>spring-boot-starter-data-jpa</artifactId>
24+
</dependency>
25+
<dependency>
26+
<groupId>org.springframework.boot</groupId>
27+
<artifactId>spring-boot-starter-validation</artifactId>
28+
</dependency>
29+
<dependency>
30+
<groupId>org.springframework.boot</groupId>
31+
<artifactId>spring-boot-starter-web</artifactId>
32+
</dependency>
33+
<dependency>
34+
<groupId>org.springframework.boot</groupId>
35+
<artifactId>spring-boot-starter-webflux</artifactId>
36+
</dependency>
37+
<dependency>
38+
<groupId>org.projectreactor</groupId>
39+
<artifactId>reactor-spring</artifactId>
40+
<version>${reactor-spring.version}</version>
41+
</dependency>
42+
<dependency>
43+
<groupId>javax.json.bind</groupId>
44+
<artifactId>javax.json.bind-api</artifactId>
45+
</dependency>
46+
47+
<!-- Dependencies for Yasson -->
48+
<!-- <dependency> -->
49+
<!-- <groupId>org.eclipse</groupId> -->
50+
<!-- <artifactId>yasson</artifactId> -->
51+
<!-- <version>1.0</version> -->
52+
<!-- </dependency> -->
53+
<!-- <dependency> -->
54+
<!-- <groupId>org.glassfish</groupId> -->
55+
<!-- <artifactId>javax.json</artifactId> -->
56+
<!-- <version>1.1.2</version> -->
57+
<!-- </dependency> -->
58+
<!-- Dependencies for Johnzon -->
59+
60+
<dependency>
61+
<groupId>org.apache.geronimo.specs</groupId>
62+
<artifactId>geronimo-json_1.1_spec</artifactId>
63+
<version>${geronimo-json_1.1_spec.version}</version>
64+
</dependency>
65+
<dependency>
66+
<groupId>org.apache.johnzon</groupId>
67+
<artifactId>johnzon-jsonb</artifactId>
68+
</dependency>
69+
<!-- utils -->
70+
<dependency>
71+
<groupId>org.apache.commons</groupId>
72+
<artifactId>commons-lang3</artifactId>
73+
</dependency>
74+
75+
<!-- runtime and test scoped -->
76+
77+
<dependency>
78+
<groupId>org.springframework.boot</groupId>
79+
<artifactId>spring-boot-devtools</artifactId>
80+
<scope>runtime</scope>
81+
</dependency>
82+
<dependency>
83+
<groupId>com.h2database</groupId>
84+
<artifactId>h2</artifactId>
85+
<scope>runtime</scope>
86+
</dependency>
87+
88+
<dependency>
89+
<groupId>org.springframework</groupId>
90+
<artifactId>spring-test</artifactId>
91+
</dependency>
92+
<dependency>
93+
<groupId>org.springframework.boot</groupId>
94+
<artifactId>spring-boot-starter-test</artifactId>
95+
<scope>test</scope>
96+
</dependency>
97+
98+
<dependency>
99+
<groupId>org.apache.commons</groupId>
100+
<artifactId>commons-collections4</artifactId>
101+
<version>4.1</version>
102+
<scope>test</scope>
103+
</dependency>
104+
105+
<dependency>
106+
<groupId>org.junit.jupiter</groupId>
107+
<artifactId>junit-jupiter-api</artifactId>
108+
</dependency>
109+
<dependency>
110+
<groupId>org.junit.jupiter</groupId>
111+
<artifactId>junit-jupiter-engine</artifactId>
112+
<scope>test</scope>
113+
</dependency>
114+
<dependency>
115+
<groupId>org.junit.platform</groupId>
116+
<artifactId>junit-platform-surefire-provider</artifactId>
117+
<version>${junit.platform.version}</version>
118+
<scope>test</scope>
119+
</dependency>
120+
<dependency>
121+
<groupId>org.junit.platform</groupId>
122+
<artifactId>junit-platform-runner</artifactId>
123+
<version>${junit.platform.version}</version>
124+
<scope>test</scope>
125+
</dependency>
126+
127+
<dependency>
128+
<groupId>org.projectlombok</groupId>
129+
<artifactId>lombok</artifactId>
130+
</dependency>
131+
<dependency>
132+
<groupId>org.apache.commons</groupId>
133+
<artifactId>commons-lang3</artifactId>
134+
</dependency>
135+
136+
</dependencies>
137+
138+
<build>
139+
<plugins>
140+
<plugin>
141+
<groupId>org.springframework.boot</groupId>
142+
<artifactId>spring-boot-maven-plugin</artifactId>
143+
<configuration>
144+
<mainClass>com.baeldung.Spring5Application</mainClass>
145+
<layout>JAR</layout>
146+
</configuration>
147+
</plugin>
148+
149+
<plugin>
150+
<groupId>org.apache.maven.plugins</groupId>
151+
<artifactId>maven-surefire-plugin</artifactId>
152+
<configuration>
153+
<forkCount>3</forkCount>
154+
<reuseForks>true</reuseForks>
155+
<parallel>methods</parallel>
156+
<useUnlimitedThreads>true</useUnlimitedThreads>
157+
<excludes>
158+
<exclude>**/*IntegrationTest.java</exclude>
159+
<exclude>**/*LiveTest.java</exclude>
160+
</excludes>
161+
</configuration>
162+
</plugin>
163+
</plugins>
164+
</build>
165+
166+
<repositories>
167+
<repository>
168+
<id>spring-milestones</id>
169+
<name>Spring Milestones</name>
170+
<url>https://repo.spring.io/milestone</url>
171+
<snapshots>
172+
<enabled>false</enabled>
173+
</snapshots>
174+
</repository>
175+
</repositories>
176+
<pluginRepositories>
177+
<pluginRepository>
178+
<id>spring-milestones</id>
179+
<name>Spring Milestones</name>
180+
<url>https://repo.spring.io/milestone</url>
181+
<snapshots>
182+
<enabled>false</enabled>
183+
</snapshots>
184+
</pluginRepository>
185+
</pluginRepositories>
186+
187+
<properties>
188+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
189+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
190+
<java.version>1.8</java.version>
191+
<junit.platform.version>1.0.0</junit.platform.version>
192+
<junit.jupiter.version>5.0.0</junit.jupiter.version>
193+
<maven-surefire-plugin.version>2.20</maven-surefire-plugin.version>
194+
<spring.version>5.0.1.RELEASE</spring.version>
195+
<reactor-spring.version>1.0.1.RELEASE</reactor-spring.version>
196+
<johnzon.version>1.1.3</johnzon.version>
197+
<jsonb-api.version>1.0</jsonb-api.version>
198+
<geronimo-json_1.1_spec.version>1.0</geronimo-json_1.1_spec.version>
199+
</properties>
200+
201+
</project>

spring-5-reactive/src/main/java/com/baeldung/reactive/controller/Foo.java renamed to spring-5-reactive-client/src/main/java/com/baeldung/reactive/model/Foo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.baeldung.reactive.controller;
1+
package com.baeldung.reactive.model;
22

33
import lombok.AllArgsConstructor;
44
import lombok.Data;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
logging.level.root=INFO
2+
3+
server.port=8081
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<configuration>
3+
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
4+
<layout class="ch.qos.logback.classic.PatternLayout">
5+
# Pattern of log message for console appender
6+
<Pattern>%d{yyyy-MM-dd HH:mm:ss} %-5p %m%n</Pattern>
7+
</layout>
8+
</appender>
9+
10+
<logger name="org.springframework" level="INFO" />
11+
12+
<root level="INFO">
13+
<appender-ref ref="stdout" />
14+
</root>
15+
16+
</configuration>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
5+
version="3.1">
6+
7+
<display-name>Spring Functional Application</display-name>
8+
9+
<servlet>
10+
<servlet-name>functional</servlet-name>
11+
<servlet-class>com.baeldung.functional.RootServlet</servlet-class>
12+
<load-on-startup>1</load-on-startup>
13+
<async-supported>true</async-supported>
14+
</servlet>
15+
<servlet-mapping>
16+
<servlet-name>functional</servlet-name>
17+
<url-pattern>/</url-pattern>
18+
</servlet-mapping>
19+
20+
21+
</web-app>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package com.baeldung.reactive;
2+
3+
import org.junit.jupiter.api.BeforeEach;
4+
import org.junit.jupiter.api.Test;
5+
import org.springframework.boot.test.context.SpringBootTest;
6+
import org.springframework.web.reactive.function.client.ClientResponse;
7+
import org.springframework.web.reactive.function.client.WebClient;
8+
9+
import com.baeldung.reactive.model.Foo;
10+
11+
import reactor.core.publisher.Mono;
12+
13+
@SpringBootTest
14+
public class ReactiveIntegrationTest {
15+
16+
private WebClient client;
17+
18+
@BeforeEach
19+
public void before() {
20+
client = WebClient.create("http://localhost:8080");
21+
}
22+
23+
//
24+
25+
@Test
26+
public void whenMonoReactiveEndpointIsConsumed_thenCorrectOutput() {
27+
final Mono<ClientResponse> fooMono = client.get().uri("/foos/123").exchange().log();
28+
29+
System.out.println(fooMono.subscribe());
30+
}
31+
32+
@Test
33+
public void whenFluxReactiveEndpointIsConsumed_thenCorrectOutput() throws InterruptedException {
34+
client.get().uri("/foos")
35+
.retrieve()
36+
.bodyToFlux(Foo.class).log()
37+
.subscribe(System.out::println);
38+
39+
System.out.println();
40+
}
41+
42+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.baeldung.reactive;
2+
3+
import org.springframework.boot.CommandLineRunner;
4+
import org.springframework.boot.SpringApplication;
5+
import org.springframework.boot.autoconfigure.SpringBootApplication;
6+
import org.springframework.context.annotation.Bean;
7+
import org.springframework.web.reactive.function.client.WebClient;
8+
9+
import com.baeldung.reactive.model.Foo;
10+
11+
@SpringBootApplication
12+
public class Spring5ReactiveTestApplication {
13+
14+
@Bean
15+
public WebClient client() {
16+
return WebClient.create("http://localhost:8080");
17+
}
18+
19+
@Bean
20+
CommandLineRunner cmd(WebClient client) {
21+
return args -> {
22+
client.get().uri("/foos2")
23+
.retrieve()
24+
.bodyToFlux(Foo.class).log()
25+
.subscribe(System.out::println);
26+
};
27+
}
28+
29+
//
30+
31+
public static void main(String[] args) {
32+
SpringApplication.run(Spring5ReactiveTestApplication.class, args);
33+
}
34+
35+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<configuration>
3+
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
4+
<layout class="ch.qos.logback.classic.PatternLayout">
5+
# Pattern of log message for console appender
6+
<Pattern>%d{yyyy-MM-dd HH:mm:ss} %-5p %m%n</Pattern>
7+
</layout>
8+
</appender>
9+
10+
<logger name="org.springframework" level="INFO" />
11+
12+
<root level="INFO">
13+
<appender-ref ref="stdout" />
14+
</root>
15+
16+
</configuration>

0 commit comments

Comments
 (0)