45
45
import org .junit .jupiter .api .Nested ;
46
46
import org .junit .jupiter .api .Test ;
47
47
import org .junit .jupiter .api .TestInstance ;
48
+ import org .junit .jupiter .api .Timeout ;
48
49
import org .junit .jupiter .api .extension .RegisterExtension ;
49
50
import org .springframework .util .ReflectionUtils ;
50
51
import reactor .core .publisher .EmitterProcessor ;
51
52
import reactor .core .publisher .Flux ;
52
53
import reactor .core .publisher .Mono ;
53
54
import reactor .core .publisher .UnicastProcessor ;
55
+ import reactor .core .scheduler .Schedulers ;
54
56
import reactor .netty .Connection ;
55
57
import reactor .test .StepVerifier ;
56
58
75
77
import static org .assertj .core .api .Assertions .fail ;
76
78
import static org .assertj .core .api .Assumptions .assumeThat ;
77
79
80
+ /**
81
+ * Integration tests for {@link ReactorNettyClient}.
82
+ */
78
83
final class ReactorNettyClientIntegrationTests {
79
84
80
85
@ RegisterExtension
@@ -92,6 +97,37 @@ final class ReactorNettyClientIntegrationTests {
92
97
Collections .emptyMap ()))
93
98
.block ();
94
99
100
+ @ BeforeEach
101
+ void before () {
102
+ SERVER .getJdbcOperations ().execute ("DROP TABLE IF EXISTS test" );
103
+ SERVER .getJdbcOperations ().execute ("CREATE TABLE test ( value INTEGER )" );
104
+ }
105
+
106
+ @ AfterEach
107
+ void after () {
108
+ SERVER .getJdbcOperations ().execute ("DROP TABLE IF EXISTS test" );
109
+ this .client .close ()
110
+ .block ();
111
+ }
112
+
113
+
114
+ @ Test
115
+ @ Timeout (50 )
116
+ void concurrentConsumptionShouldComplete () {
117
+
118
+ IntStream .range (0 , 1000 )
119
+ .forEach (i -> SERVER .getJdbcOperations ().update ("INSERT INTO test VALUES(?),(?),(?),(?),(?),(?),(?),(?),(?),(?)" , i , i , i , i , i , i , i , i , i , i ));
120
+
121
+ this .client
122
+ .exchange (Mono .just (new Query ("SELECT value FROM test" )))
123
+ .limitRate (1 )
124
+ .publishOn (Schedulers .elastic ())
125
+ .doOnNext (ReferenceCountUtil ::release )
126
+ .as (StepVerifier ::create )
127
+ .thenConsumeWhile ((t ) -> true )
128
+ .verifyComplete ();
129
+ }
130
+
95
131
@ Test
96
132
void close () {
97
133
this .client .close ()
@@ -158,30 +194,13 @@ void shouldCancelExchangeOnCloseInFlight() throws Exception {
158
194
}
159
195
}
160
196
161
- @ AfterEach
162
- void closeClient () {
163
- SERVER .getJdbcOperations ().execute ("DROP TABLE IF EXISTS test" );
164
- this .client .close ()
165
- .block ();
166
- }
167
197
168
198
@ Test
169
199
void constructorNoHost () {
170
200
assertThatIllegalArgumentException ().isThrownBy (() -> ReactorNettyClient .connect (null , SERVER .getPort ()))
171
201
.withMessage ("host must not be null" );
172
202
}
173
203
174
- @ BeforeEach
175
- void createTable () {
176
- dropTable ();
177
- SERVER .getJdbcOperations ().execute ("CREATE TABLE test ( value INTEGER )" );
178
- }
179
-
180
- @ AfterEach
181
- void dropTable () {
182
- SERVER .getJdbcOperations ().execute ("DROP TABLE IF EXISTS test" );
183
- }
184
-
185
204
@ Test
186
205
void exchange () {
187
206
SERVER .getJdbcOperations ().execute ("INSERT INTO test VALUES (100)" );
0 commit comments