|
1 | | -// Copyright 2015-2022 The NATS Authors |
2 | | -// Licensed under the Apache License, Version 2.0 (the "License"); |
3 | | -// you may not use this file except in compliance with the License. |
4 | | -// You may obtain a copy of the License at: |
5 | | -// |
6 | | -// http://www.apache.org/licenses/LICENSE-2.0 |
7 | | -// |
8 | | -// Unless required by applicable law or agreed to in writing, software |
9 | | -// distributed under the License is distributed on an "AS IS" BASIS, |
10 | | -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
11 | | -// See the License for the specific language governing permissions and |
12 | | -// limitations under the License. |
13 | | - |
14 | | -package io.nats.client; |
15 | | - |
16 | | -import io.nats.ConsoleOutput; |
17 | | -import io.nats.NatsRunnerUtils; |
18 | | -import io.nats.NatsServerRunner; |
19 | | - |
20 | | -import java.io.IOException; |
21 | | -import java.util.logging.Level; |
22 | | - |
23 | | -public class NatsTestServer extends NatsServerRunner { |
24 | | - static { |
25 | | - NatsServerRunner.setDefaultOutputSupplier(ConsoleOutput::new); |
26 | | - quiet(); |
27 | | - } |
28 | | - |
29 | | - public static void quiet() { |
30 | | - NatsServerRunner.setDefaultOutputLevel(Level.WARNING); |
31 | | - } |
32 | | - |
33 | | - public static void verbose() { |
34 | | - NatsServerRunner.setDefaultOutputLevel(Level.ALL); |
35 | | - } |
36 | | - |
37 | | - public NatsTestServer() throws IOException { |
38 | | - super(); |
39 | | - } |
40 | | - |
41 | | - public NatsTestServer(boolean debug) throws IOException { |
42 | | - super(debug); |
43 | | - } |
44 | | - |
45 | | - public NatsTestServer(boolean debug, boolean jetstream) throws IOException { |
46 | | - super(debug, jetstream); |
47 | | - } |
48 | | - |
49 | | - public NatsTestServer(int port, boolean debug) throws IOException { |
50 | | - super(port, debug); |
51 | | - } |
52 | | - |
53 | | - public NatsTestServer(int port, boolean debug, boolean jetstream) throws IOException { |
54 | | - super(port, debug, jetstream); |
55 | | - } |
56 | | - |
57 | | - public NatsTestServer(String configFilePath, boolean debug) throws IOException { |
58 | | - super(configFilePath, debug); |
59 | | - } |
60 | | - |
61 | | - public NatsTestServer(String configFilePath, boolean debug, boolean jetstream) throws IOException { |
62 | | - super(configFilePath, debug, jetstream); |
63 | | - } |
64 | | - |
65 | | - public NatsTestServer(String configFilePath, String[] configInserts, int port, boolean debug) throws IOException { |
66 | | - super(configFilePath, configInserts, port, debug); |
67 | | - } |
68 | | - |
69 | | - public NatsTestServer(String configFilePath, int port, boolean debug) throws IOException { |
70 | | - super(configFilePath, port, debug); |
71 | | - } |
72 | | - |
73 | | - public NatsTestServer(String[] customArgs, boolean debug) throws IOException { |
74 | | - super(customArgs, debug); |
75 | | - } |
76 | | - |
77 | | - public NatsTestServer(String[] customArgs, int port, boolean debug) throws IOException { |
78 | | - super(customArgs, port, debug); |
79 | | - } |
80 | | - |
81 | | - public NatsTestServer(int port, boolean debug, boolean jetstream, String configFilePath, String[] configInserts, String[] customArgs) throws IOException { |
82 | | - super(port, debug, jetstream, configFilePath, configInserts, customArgs); |
83 | | - } |
84 | | - |
85 | | - public NatsTestServer(Builder b) throws IOException { |
86 | | - super(b); |
87 | | - } |
88 | | - |
89 | | - public static int nextPort() throws IOException { |
90 | | - return NatsRunnerUtils.nextPort(); |
91 | | - } |
92 | | - |
93 | | - public String getLocalhostUri(String schema) { |
94 | | - return NatsRunnerUtils.getLocalhostUri(schema, getPort()); |
95 | | - } |
96 | | - |
97 | | - public String getNatsLocalhostUri() { |
98 | | - return NatsRunnerUtils.getNatsLocalhostUri(getPort()); |
99 | | - } |
100 | | - |
101 | | - public static String getNatsLocalhostUri(int port) { |
102 | | - return NatsRunnerUtils.getNatsLocalhostUri(port); |
103 | | - } |
104 | | - |
105 | | - public static String getLocalhostUri(String schema, int port) { |
106 | | - return NatsRunnerUtils.getLocalhostUri(schema, port); |
107 | | - } |
108 | | -} |
| 1 | +// Copyright 2015-2022 The NATS Authors |
| 2 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 | +// you may not use this file except in compliance with the License. |
| 4 | +// You may obtain a copy of the License at: |
| 5 | +// |
| 6 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | +// |
| 8 | +// Unless required by applicable law or agreed to in writing, software |
| 9 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | +// See the License for the specific language governing permissions and |
| 12 | +// limitations under the License. |
| 13 | + |
| 14 | +package io.nats.client; |
| 15 | + |
| 16 | +import io.nats.ConsoleOutput; |
| 17 | +import io.nats.NatsRunnerUtils; |
| 18 | +import io.nats.NatsServerRunner; |
| 19 | + |
| 20 | +import java.io.IOException; |
| 21 | +import java.util.logging.Level; |
| 22 | + |
| 23 | +public class NatsTestServer extends NatsServerRunner { |
| 24 | + static { |
| 25 | + NatsTestServer.quiet(); |
| 26 | + NatsServerRunner.setDefaultOutputSupplier(ConsoleOutput::new); |
| 27 | + NatsServerRunner.setDefaultValidateTries(5); |
| 28 | + NatsServerRunner.setDefaultInitialValidateDelay(100); |
| 29 | + NatsServerRunner.setDefaultSubsequentValidateDelay(50); |
| 30 | + } |
| 31 | + |
| 32 | + public static void quiet() { |
| 33 | + NatsServerRunner.setDefaultOutputLevel(Level.WARNING); |
| 34 | + } |
| 35 | + |
| 36 | + public static void verbose() { |
| 37 | + NatsServerRunner.setDefaultOutputLevel(Level.ALL); |
| 38 | + } |
| 39 | + |
| 40 | + public NatsTestServer() throws IOException { |
| 41 | + super(); |
| 42 | + } |
| 43 | + |
| 44 | + public NatsTestServer(boolean debug) throws IOException { |
| 45 | + super(debug); |
| 46 | + } |
| 47 | + |
| 48 | + public NatsTestServer(boolean debug, boolean jetstream) throws IOException { |
| 49 | + super(debug, jetstream); |
| 50 | + } |
| 51 | + |
| 52 | + public NatsTestServer(int port, boolean debug) throws IOException { |
| 53 | + super(port, debug); |
| 54 | + } |
| 55 | + |
| 56 | + public NatsTestServer(int port, boolean debug, boolean jetstream) throws IOException { |
| 57 | + super(port, debug, jetstream); |
| 58 | + } |
| 59 | + |
| 60 | + public NatsTestServer(String configFilePath, boolean debug) throws IOException { |
| 61 | + super(configFilePath, debug); |
| 62 | + } |
| 63 | + |
| 64 | + public NatsTestServer(String configFilePath, boolean debug, boolean jetstream) throws IOException { |
| 65 | + super(configFilePath, debug, jetstream); |
| 66 | + } |
| 67 | + |
| 68 | + public NatsTestServer(String configFilePath, String[] configInserts, int port, boolean debug) throws IOException { |
| 69 | + super(configFilePath, configInserts, port, debug); |
| 70 | + } |
| 71 | + |
| 72 | + public NatsTestServer(String configFilePath, int port, boolean debug) throws IOException { |
| 73 | + super(configFilePath, port, debug); |
| 74 | + } |
| 75 | + |
| 76 | + public NatsTestServer(String[] customArgs, boolean debug) throws IOException { |
| 77 | + super(customArgs, debug); |
| 78 | + } |
| 79 | + |
| 80 | + public NatsTestServer(String[] customArgs, int port, boolean debug) throws IOException { |
| 81 | + super(customArgs, port, debug); |
| 82 | + } |
| 83 | + |
| 84 | + public NatsTestServer(int port, boolean debug, boolean jetstream, String configFilePath, String[] configInserts, String[] customArgs) throws IOException { |
| 85 | + super(port, debug, jetstream, configFilePath, configInserts, customArgs); |
| 86 | + } |
| 87 | + |
| 88 | + public NatsTestServer(Builder b) throws IOException { |
| 89 | + super(b); |
| 90 | + } |
| 91 | + |
| 92 | + public static int nextPort() throws IOException { |
| 93 | + return NatsRunnerUtils.nextPort(); |
| 94 | + } |
| 95 | + |
| 96 | + public String getLocalhostUri(String schema) { |
| 97 | + return NatsRunnerUtils.getLocalhostUri(schema, getPort()); |
| 98 | + } |
| 99 | + |
| 100 | + public String getNatsLocalhostUri() { |
| 101 | + return NatsRunnerUtils.getNatsLocalhostUri(getPort()); |
| 102 | + } |
| 103 | + |
| 104 | + public static String getNatsLocalhostUri(int port) { |
| 105 | + return NatsRunnerUtils.getNatsLocalhostUri(port); |
| 106 | + } |
| 107 | + |
| 108 | + public static String getLocalhostUri(String schema, int port) { |
| 109 | + return NatsRunnerUtils.getLocalhostUri(schema, port); |
| 110 | + } |
| 111 | +} |
0 commit comments