Skip to content

Commit 60625c3

Browse files
authored
* switched to jnats-server-runner library (#456)
* moved some print util to make more available for general use
1 parent 5658031 commit 60625c3

File tree

8 files changed

+75
-441
lines changed

8 files changed

+75
-441
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ repositories {
7878
dependencies {
7979
implementation 'net.i2p.crypto:eddsa:0.3.0'
8080
testImplementation 'org.junit.jupiter:junit-jupiter:5.7.0'
81+
testImplementation 'io.nats:jnats-server-runner:1.0.5'
8182
}
8283

8384
sourceSets {

src/examples/java/io/nats/examples/jetstream/NatsJsMirrorSubUseCases.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import java.time.Duration;
2525
import java.util.List;
2626

27-
import static io.nats.examples.jetstream.NatsJsUtils.printFormatted;
27+
import static io.nats.client.support.JsonUtils.printFormatted;
2828
import static io.nats.examples.jetstream.NatsJsUtils.publish;
2929

3030
/**

src/examples/java/io/nats/examples/jetstream/NatsJsUtils.java

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -272,45 +272,6 @@ public static void printObject(Object o, String... subObjectNames) {
272272
System.out.println(s + "\n");
273273
}
274274

275-
static final String INDENT = " ";
276-
private static String indent(int level) {
277-
return level == 0 ? "" : INDENT.substring(0, level * 4);
278-
}
279-
280-
public static void printFormatted(Object o) {
281-
int level = 0;
282-
boolean indentNext = true;
283-
String s = o.toString();
284-
for (int x = 0; x < s.length(); x++) {
285-
char c = s.charAt(x);
286-
if (c == '{') {
287-
System.out.print(c + "\n");
288-
++level;
289-
indentNext = true;
290-
}
291-
else if (c == '}') {
292-
System.out.print("\n" + indent(--level) + c);
293-
}
294-
else if (c == ',') {
295-
System.out.print("\n");
296-
indentNext = true;
297-
}
298-
else {
299-
if (indentNext) {
300-
if (c != ' ') {
301-
System.out.print(indent(level) + c);
302-
indentNext = false;
303-
}
304-
}
305-
else {
306-
System.out.print(c);
307-
}
308-
}
309-
}
310-
311-
System.out.println();
312-
}
313-
314275
// ----------------------------------------------------------------------------------------------------
315276
// REPORT
316277
// ----------------------------------------------------------------------------------------------------

src/examples/java/io/nats/examples/stability/JsMulti.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
import java.util.concurrent.CompletableFuture;
2727
import java.util.concurrent.ThreadLocalRandom;
2828

29+
import static io.nats.client.support.JsonUtils.printFormatted;
2930
import static io.nats.examples.ExampleUtils.*;
30-
import static io.nats.examples.jetstream.NatsJsUtils.printFormatted;
3131

3232
public class JsMulti {
3333
static final String usageString =

src/main/java/io/nats/client/support/JsonUtils.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,4 +490,47 @@ public static String normalize(String s) {
490490
public static String objectString(String name, Object o) {
491491
return o == null ? name + "=null" : o.toString();
492492
}
493+
494+
// ----------------------------------------------------------------------------------------------------
495+
// PRINT UTILS
496+
// ----------------------------------------------------------------------------------------------------
497+
498+
private static final String INDENT = " ";
499+
private static String indent(int level) {
500+
return level == 0 ? "" : INDENT.substring(0, level * 4);
501+
}
502+
503+
public static void printFormatted(Object o) {
504+
int level = 0;
505+
boolean indentNext = true;
506+
String s = o.toString();
507+
for (int x = 0; x < s.length(); x++) {
508+
char c = s.charAt(x);
509+
if (c == '{') {
510+
System.out.print(c + "\n");
511+
++level;
512+
indentNext = true;
513+
}
514+
else if (c == '}') {
515+
System.out.print("\n" + indent(--level) + c);
516+
}
517+
else if (c == ',') {
518+
System.out.print("\n");
519+
indentNext = true;
520+
}
521+
else {
522+
if (indentNext) {
523+
if (c != ' ') {
524+
System.out.print(indent(level) + c);
525+
indentNext = false;
526+
}
527+
}
528+
else {
529+
System.out.print(c);
530+
}
531+
}
532+
}
533+
534+
System.out.println();
535+
}
493536
}

src/test/java/io/nats/client/NatsOutputLogger.java

Lines changed: 0 additions & 106 deletions
This file was deleted.

0 commit comments

Comments
 (0)