8000 Updated JavaClientDriver to support new tck test format. (#357) · chakra-coder/rsocket-java@f12155c · GitHub
[go: up one dir, main page]

Skip to content

Commit f12155c

Browse files
junaidkhalidyschimke
authored andcommitted
Updated JavaClientDriver to support new tck test format. (rsocket#357)
The new TCK-test format has an option to represent multiple clients. This commit is just to update the test files and javaclientdriver to run the new files. In a later commit, I will add support for multiple clients in the rsocket-java.
1 parent 79dd245 commit f12155c

File tree

5 files changed

+262
-261
lines changed

5 files changed

+262
-261
lines changed

rsocket-tck-drivers/src/main/java/io/rsocket/tckdrivers/client/JavaClientDriver.java

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,14 @@ public void runTest(List<String> test, String name) throws Exception {
8181
while (iter.hasNext()) {
8282
String line = iter.next();
8383
String[] args = line.split("%%");
84-
switch (args[0]) {
84+
if (args[0].equals("EOF")) {
85+
handleEOF();
86+
continue;
87+
}
88+
switch (args[1]) {
8589
case "subscribe":
8690
handleSubscribe(args);
87-
id.add(args[2]);
91+
id.add(args[3]);
8892
break;
8993
case "channel":
9094
channelTest = true;
@@ -94,7 +98,7 @@ public void runTest(List<String> test, String name) throws Exception {
9498
handleEchoChannel(args);
9599
break;
96100
case "await":
97-
switch (args[1]) {
101+
switch (args[2]) {
98102
case "terminal":
99103
handleAwaitTerminal(args);
100104
break;
@@ -110,7 +114,7 @@ public void runTest(List<String> test, String name) throws Exception {
110114
break;
111115

112116
case "assert":
113-
switch (args[1]) {
117+
switch (args[2]) {
114118
case "no_error":
115119
assertNoError(args);
116120
break;
@@ -146,9 +150,6 @@ public void runTest(List<String> test, String name) throws Exception {
146150
case "cancel":
147151
handleCancel(args);
148152
break;
149-
case "EOF":
150-
handleEOF();
151-
break;
152153
default:
153154
// the default behavior is to just skip the line, so we can acommodate slight changes to the TCK
154155
break;
@@ -167,32 +168,32 @@ public void runTest(List<String> test, String name) throws Exception {
167168
* @param args
168169
*/
169170
private void handleSubscribe(String[] args) {
170-
switch (args[1]) {
171+
switch (args[2]) {
171172
case "rr":
172173
MySubscriber<Payload> rrsub = new MySubscriber<>(0L, AGENT);
173-
payloadSubscribers.put(args[2], rrsub);
174-
idToType.put(args[2], args[1]);
174+
payloadSubscribers.put(args[3], rrsub);
175+
idToType.put(args[3], args[2]);
175176
RSocket rrclient = createClient.get();
176-
consoleUtils.info("Sending RR with " + args[3] + " " + args[4]);
177-
Publisher<Payload> rrpub = rrclient.requestResponse(new PayloadImpl(args[3], args[4]));
177+
consoleUtils.info("Sending RR with " + args[4] + " " + args[5]);
178+
Publisher<Payload> rrpub = rrclient.requestResponse(new PayloadImpl(args[4], args[5]));
178179
rrpub.subscribe(rrsub);
179180
break;
180181
case "rs":
181182
MySubscriber<Payload> rssub = new MySubscriber<>(0L, AGENT);
182-
payloadSubscribers.put(args[2], rssub);
183-
idToType.put(args[2], args[1]);
183+
payloadSubscribers.put(args[3], rssub);
184+
idToType.put(args[3], args[2]);
184185
RSocket rsclient = createClient.get();
185-
consoleUtils.info("Sending RS with " + args[3] + " " + args[4]);
186-
Publisher<Payload> rspub = rsclient.requestStream(new PayloadImpl(args[3], args[4]));
186+
consoleUtils.info("Sending RS with " + args[4] + " " + args[5]);
187+
Publisher<Payload> rspub = rsclient.requestStream(new PayloadImpl(args[4], args[5]));
187188
rspub.subscribe(rssub);
188189
break;
189190
case "fnf":
190191
MySubscriber<Void> fnfsub = new MySubscriber<>(0L, AGENT);
191-
fnfSubscribers.put(args[2], fnfsub);
192-
idToType.put(args[2], args[1]);
192+
fnfSubscribers.put(args[3], fnfsub);
193+
idToType.put(args[3], args[2]);
193194
RSocket fnfclient = createClient.get();
194-
consoleUtils.info("Sending fnf with " + args[3] + " " + args[4]);
195-
Publisher<Void> fnfpub = fnfclient.fireAndForget(new PayloadImpl(args[3], args[4]));
195+
consoleUtils.info("Sending fnf with " + args[4] + " " + args[5]);
196+
Publisher<Void> fnfpub = fnfclient.fireAndForget(new PayloadImpl(args[4], args[5]));
196197
fnfpub.subscribe(fnfsub);
197198
break;
198199
default:
@@ -218,7 +219,7 @@ private void handleChannel(String[] args, Iterator<String> iter, String name, bo
218219
line = iter.next();
219220
}
220221
// set the initial payload
221-
Payload initialPayload = new PayloadImpl(args[1], args[2]);
222+
Payload initialPayload = new PayloadImpl(args[2], args[3]);
222223

223224
// this is the subscriber that will request data from the server, like all the other test subscribers
224225
MySubscriber<Payload> testsub = new MySubscriber<>(1L, AGENT);
@@ -259,7 +260,7 @@ public void subscribe(Subscriber<? super Payload> s) {
259260
* @param args
260261
*/
261262
private void handleEchoChannel(String[] args) {
262-
Payload initPayload = new PayloadImpl(args[1], args[2]);
263+
Payload initPayload = new PayloadImpl(args[2], args[3]);
263264
MySubscriber<Payload> testsub = new MySubscriber<>(1L, AGENT);
264265
RSocket client = createClient.get();
265266
Publisher<Payload> pub =
@@ -278,7 +279,7 @@ public void subscribe(Subscriber<? super Payload> s) {
278279

279280
private void handleAwaitTerminal(String[] args) {
280281
consoleUtils.info("Awaiting at Terminal");
281-
String id = args[2];
282+
String id = args[3];
282283

283284
assertNotEquals("Could not find subscriber with given id", idToType.get(id), null);
284285

@@ -292,28 +293,28 @@ private void handleAwaitTerminal(String[] args) {
292293
}
293294

294295
private void handleAwaitAtLeast(String[] args) {
295-
consoleUtils.info("Awaiting at Terminal for at least " + args[3]);
296+
consoleUtils.info("Awaiting at Terminal for at least " + args[4]);
296297
try {
297-
String id = args[2];
298+
String id = args[3];
298299
MySubscriber<Payload> sub = payloadSubscribers.get(id);
299-
sub.awaitAtLeast(Long.parseLong(args[3]));
300+
sub.awaitAtLeast(Long.parseLong(args[4]));
300301
} catch (InterruptedException e) {
301302
assertNull("interrupted ", e.getMessage());
302303
}
303304
}
304305

305306
private void handleAwaitNoEvents(String[] args) {
306307
try {
307-
String id = args[2];
308+
String id = args[3];
308309
MySubscriber<Payload> sub = payloadSubscribers.get(id);
309-
sub.awaitNoEvents(Long.parseLong(args[3]));
310+
sub.awaitNoEvents(Long.parseLong(args[4]));
310311
} catch (InterruptedException e) {
311312
assertNull("interrupted ", e.getMessage());
312313
}
313314
}
314315

315316
private void assertNoError(String[] args) {
316-
String id = args[2];
317+
String id = args[3];
317318

318319
assertNotNull("Could not find subscriber with given id", idToType.get(id));
319320
if (idToType.get(id).equals("fnf")) {
@@ -335,7 +336,7 @@ private void assertNoError(String[] args) {
335336

336337
private void assertError(String[] args) {
337338
consoleUtils.info("Checking for error");
338-
String id = args[2];
339+
String id = args[3];
339340
assertNotNull("Could not find subscriber with given id", idToType.get(id));
340341
if (idToType.get(id).equals("fnf")) {
341342
MySubscriber<Void> sub = fnfSubscribers.get(id);
@@ -347,10 +348,10 @@ private void assertError(String[] args) {
347348
}
348349

349350
private void assertReceived(String[] args) {
350-
consoleUtils.info("Verify we received " + args[3]);
351-
String id = args[2];
351+
consoleUtils.info("Verify we received " + args[4]);
352+
String id = args[3];
352353
MySubscriber<Payload> sub = payloadSubscribers.get(id);
353-
String[] values = args[3].split("&&");
354+
String[] values = args[4].split("&&");
354355
List<Tuple<String, String>> assertList = new ArrayList<>();
355356
for (String v : values) {
356357
String[] vals = v.split(",");
@@ -360,24 +361,24 @@ private void assertReceived(String[] args) {
360361
}
361362

362363
private void assertReceivedN(String[] args) {
363-
String id = args[2];
364+
String id = args[3];
364365
MySubscriber<Payload> sub = payloadSubscribers.get(id);
365366
try {
366-
sub.assertValueCount(Integer.parseInt(args[3]));
367+
sub.assertValueCount(Integer.parseInt(args[4]));
367368
} catch (Throwable ex) {
368369
assertNull(ex.getMessage());
369370
}
370371
}
371372

372373
private void assertReceivedAtLeast(String[] args) {
373-
String id = args[2];
374+
String id = args[3];
374375
MySubscriber<Payload> sub = payloadSubscribers.get(id);
375-
sub.assertReceivedAtLeast(Integer.parseInt(args[3]));
376+
sub.assertReceivedAtLeast(Integer.parseInt(args[4]));
376377
}
377378

378379
private void assertCompleted(String[] args) {
379380
consoleUtils.info("Handling onComplete");
380-
String id = args[2];
381+
String id = args[3];
381382

382383
assertNotNull("Could not find subscriber with given id", idToType.get(id));
383384
if (idToType.get(id).equals("fnf")) {
@@ -399,7 +400,7 @@ private void assertCompleted(String[] args) {
399400

400401
private void assertNoCompleted(String[] args) {
401402
consoleUtils.info("Handling NO onComplete");
402-
String id = args[2];
403+
String id = args[3];
403404

404405
assertNotNull("Could not find subscriber with given id", idToType.get(id));
405406
if (idToType.get(id).equals("fnf")) {
@@ -420,14 +421,14 @@ private void assertNoCompleted(String[] args) {
420421
}
421422

422423
private void assertCancelled(String[] args) {
423-
String id = args[2];
424+
String id = args[3];
424425
MySubscriber<Payload> sub = payloadSubscribers.get(id);
425426
assertTrue(sub.isCancelled());
426427
}
427428

428429
private void handleRequest(String[] args) {
429-
Long num = Long.parseLong(args[1]);
430-
String id = args[2];
430+
Long num = Long.parseLong(args[2]);
431+
String id = args[3];
431432

432433
assertNotNull("Could not find subscriber with given id", idToType.get(id));
433434
if (idToType.get(id).equals("fnf")) {
@@ -442,14 +443,14 @@ private void handleRequest(String[] args) {
442443
}
443444

444445
private void handleTake(String[] args) {
445-
String id = args[2];
446-
Long num = Long.parseLong(args[1]);
446+
String id = args[3];
447+
Long num = Long.parseLong(args[2]);
447448
MySubscriber<Payload> sub = payloadSubscribers.get(id);
448449
sub.take(num);
449450
}
450451

451452
private void handleCancel(String[] args) {
452-
String id = args[1];
453+
String id = args[2];
453454
MySubscriber<Payload> sub = payloadSubscribers.get(id);
454455
sub.cancel();
455456
}
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
!
22
name%%fireAndForget2
3-
subscribe%%fnf%%22b84540-f916-4f7f-9211-12e235e30225%%c%%d
4-
request%%1%%22b84540-f916-4f7f-9211-12e235e30225
5-
await%%terminal%%22b84540-f916-4f7f-9211-12e235e30225
6-
assert%%no_error%%22b84540-f916-4f7f-9211-12e235e30225
7-
assert%%completed%%22b84540-f916-4f7f-9211-12e235e30225
3+
c0%%subscribe%%fnf%%43%%c%%d
4+
c0%%request%%1%%43
5+
c0%%await%%terminal%%43
6+
c0%%assert%%no_error%%43
7+
c0%%assert%%completed%%43
88
!
99
name%%fireAndForget
10-
subscribe%%fnf%%01a1ba74-cbd2-4c51-a759-a276b8051ca7%%a%%b
11-
request%%1%%01a1ba74-cbd2-4c51-a759-a276b8051ca7
12-
await%%terminal%%01a1ba74-cbd2-4c51-a759-a276b8051ca7
13-
assert%%no_error%%01a1ba74-cbd2-4c51-a759-a276b8051ca7
14-
assert%%completed%%01a1ba74-cbd2-4c51-a759-a276b8051ca7
10+
c0%%subscribe%%fnf%%44%%a%%b
11+
c0%%request%%1%%44
12+
c0%%await%%terminal%%44
13+
c0%%assert%%no_error%%44
14+
c0%%assert%%completed%%44
1515
EOF

0 commit comments

Comments
 (0)
0