aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2022-09-14 13:25:50 +0200
committerJon Bratseth <bratseth@gmail.com>2022-09-14 13:25:50 +0200
commit78c9bfbe44faa52006e268bd829d83b2d907dbf3 (patch)
tree16aa34516009643c9199ca2c68947f8627726b70
parentdda637d7693328ad2f246e88d13d1d2293c59ae8 (diff)
No functional changes
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/query/Item.java2
-rwxr-xr-xdocumentapi/src/main/java/com/yahoo/documentapi/SyncSession.java3
-rwxr-xr-xdocumentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/ANDPolicy.java1
-rwxr-xr-xdocumentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/LocalServicePolicy.java4
-rwxr-xr-xdocumentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/RoundRobinPolicy.java3
-rwxr-xr-xdocumentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/SubsetServicePolicy.java2
-rw-r--r--messagebus/src/main/java/com/yahoo/messagebus/routing/HopSpec.java8
-rwxr-xr-xmessagebus/src/main/java/com/yahoo/messagebus/routing/RoutingContext.java4
-rw-r--r--messagebus/src/main/java/com/yahoo/messagebus/routing/RoutingSpec.java2
-rw-r--r--messagebus/src/test/java/com/yahoo/messagebus/network/IdentityTestCase.java1
-rw-r--r--messagebus/src/test/java/com/yahoo/messagebus/network/rpc/BasicNetworkTestCase.java16
-rw-r--r--messagebus/src/test/java/com/yahoo/messagebus/network/rpc/LoadBalanceTestCase.java11
-rw-r--r--messagebus/src/test/java/com/yahoo/messagebus/network/rpc/RPCNetworkTestCase.java1
-rwxr-xr-xmessagebus/src/test/java/com/yahoo/messagebus/network/rpc/SendAdapterTestCase.java28
-rwxr-xr-xmessagebus/src/test/java/com/yahoo/messagebus/network/rpc/ServiceAddressTestCase.java2
-rw-r--r--messagebus/src/test/java/com/yahoo/messagebus/network/rpc/SlobrokTestCase.java6
-rwxr-xr-xmessagebus/src/test/java/com/yahoo/messagebus/routing/AdvancedRoutingTestCase.java1
-rwxr-xr-xmessagebus/src/test/java/com/yahoo/messagebus/routing/ResenderTestCase.java7
-rw-r--r--messagebus/src/test/java/com/yahoo/messagebus/routing/RetryPolicyTestCase.java1
-rwxr-xr-xmessagebus/src/test/java/com/yahoo/messagebus/routing/RouteParserTestCase.java1
-rwxr-xr-xmessagebus/src/test/java/com/yahoo/messagebus/routing/RoutingContextTestCase.java9
-rwxr-xr-xmessagebus/src/test/java/com/yahoo/messagebus/routing/RoutingSpecTestCase.java36
-rw-r--r--messagebus/src/test/java/com/yahoo/messagebus/routing/RoutingTestCase.java271
-rw-r--r--messagebus/src/test/java/com/yahoo/messagebus/test/QueueAdapterTestCase.java1
-rw-r--r--messagebus/src/test/java/com/yahoo/messagebus/test/ReceptorTestCase.java1
-rw-r--r--messagebus/src/test/java/com/yahoo/messagebus/test/SimpleMessageTestCase.java1
-rw-r--r--messagebus/src/test/java/com/yahoo/messagebus/test/SimpleProtocolTestCase.java1
-rw-r--r--messagebus/src/test/java/com/yahoo/messagebus/test/SimpleReplyTestCase.java1
28 files changed, 104 insertions, 321 deletions
diff --git a/container-search/src/main/java/com/yahoo/prelude/query/Item.java b/container-search/src/main/java/com/yahoo/prelude/query/Item.java
index c1397ca9d4b..7f421832d5f 100644
--- a/container-search/src/main/java/com/yahoo/prelude/query/Item.java
+++ b/container-search/src/main/java/com/yahoo/prelude/query/Item.java
@@ -432,7 +432,7 @@ public abstract class Item implements Cloneable {
this.isRanked = isRanked;
}
- /** Returns whether or not this item should affect ranking. */
+ /** Returns whether this item should affect ranking. */
public boolean isRanked() {
return isRanked;
}
diff --git a/documentapi/src/main/java/com/yahoo/documentapi/SyncSession.java b/documentapi/src/main/java/com/yahoo/documentapi/SyncSession.java
index 01d67c8e1d9..0fd579e2f5d 100755
--- a/documentapi/src/main/java/com/yahoo/documentapi/SyncSession.java
+++ b/documentapi/src/main/java/com/yahoo/documentapi/SyncSession.java
@@ -14,8 +14,9 @@ import java.time.Duration;
import static com.yahoo.documentapi.DocumentOperationParameters.parameters;
/**
- * A session for synchronous access to a document repository. This class
+ * A session for synchronous access to a document repository,
* provides simple document access where throughput is not a concern.
+ * This is multithread safe.
*
* @author Simon Thoresen Hult
* @author bjorncs
diff --git a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/ANDPolicy.java b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/ANDPolicy.java
index ec4ec5ae790..c9ba1f5808c 100755
--- a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/ANDPolicy.java
+++ b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/ANDPolicy.java
@@ -59,4 +59,5 @@ public class ANDPolicy implements DocumentProtocolRoutingPolicy {
public void destroy() {
}
+
}
diff --git a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/LocalServicePolicy.java b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/LocalServicePolicy.java
index 0fe44a74968..e835cc4e5e0 100755
--- a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/LocalServicePolicy.java
+++ b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/LocalServicePolicy.java
@@ -20,7 +20,7 @@ import java.util.Map;
public class LocalServicePolicy implements DocumentProtocolRoutingPolicy {
private final String localAddress;
- private Map<String, CacheEntry> cache = new HashMap<>();
+ private final Map<String, CacheEntry> cache = new HashMap<>();
/**
* Constructs a policy that will choose local services that match the slobrok pattern in which this policy occured.
@@ -32,14 +32,12 @@ public class LocalServicePolicy implements DocumentProtocolRoutingPolicy {
localAddress = (param != null && param.length() > 0) ? param : null;
}
- // Inherit doc from RoutingPolicy.
public void select(RoutingContext ctx) {
Route route = new Route(ctx.getRoute());
route.setHop(0, getRecipient(ctx));
ctx.addChild(route);
}
- // Inherit doc from RoutingPolicy.
public void merge(RoutingContext ctx) {
DocumentProtocol.merge(ctx);
}
diff --git a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/RoundRobinPolicy.java b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/RoundRobinPolicy.java
index 5187ee9d255..b7f32ac958e 100755
--- a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/RoundRobinPolicy.java
+++ b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/RoundRobinPolicy.java
@@ -22,7 +22,7 @@ import java.util.Map;
*/
public class RoundRobinPolicy implements DocumentProtocolRoutingPolicy {
- private final Map<String, CacheEntry> cache = new HashMap<String, CacheEntry>();
+ private final Map<String, CacheEntry> cache = new HashMap<>();
// Inherit doc from RoutingPolicy.
public void select(RoutingContext ctx) {
@@ -117,4 +117,5 @@ public class RoundRobinPolicy implements DocumentProtocolRoutingPolicy {
public void destroy() {
}
+
}
diff --git a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/SubsetServicePolicy.java b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/SubsetServicePolicy.java
index 72e88e6c0b9..8519f543909 100755
--- a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/SubsetServicePolicy.java
+++ b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/SubsetServicePolicy.java
@@ -21,7 +21,7 @@ import java.util.logging.Logger;
*/
public class SubsetServicePolicy implements DocumentProtocolRoutingPolicy {
- private static Logger log = Logger.getLogger(SubsetServicePolicy.class.getName());
+ private static final Logger log = Logger.getLogger(SubsetServicePolicy.class.getName());
private final int subsetSize;
private final Map<String, CacheEntry> cache = new HashMap<>();
diff --git a/messagebus/src/main/java/com/yahoo/messagebus/routing/HopSpec.java b/messagebus/src/main/java/com/yahoo/messagebus/routing/HopSpec.java
index d7f117f0452..632e7d65836 100644
--- a/messagebus/src/main/java/com/yahoo/messagebus/routing/HopSpec.java
+++ b/messagebus/src/main/java/com/yahoo/messagebus/routing/HopSpec.java
@@ -78,7 +78,7 @@ public class HopSpec {
}
/**
- * Returns whether or not there are any recipients that the selector can choose from.
+ * Returns whether there are any recipients that the selector can choose from.
*
* @return True if there is at least one recipient.
*/
@@ -160,7 +160,7 @@ public class HopSpec {
}
/**
- * Returns whether or not to ignore the result when routing through this hop.
+ * Returns whether to ignore the result when routing through this hop.
*
* @return True to ignore the result.
*/
@@ -169,9 +169,9 @@ public class HopSpec {
}
/**
- * Sets whether or not to ignore the result when routing through this hop.
+ * Sets whether to ignore the result when routing through this hop.
*
- * @param ignoreResult Whether or not to ignore the result.
+ * @param ignoreResult Whether to ignore the result.
* @return This, to allow chaining.
*/
public HopSpec setIgnoreResult(boolean ignoreResult) {
diff --git a/messagebus/src/main/java/com/yahoo/messagebus/routing/RoutingContext.java b/messagebus/src/main/java/com/yahoo/messagebus/routing/RoutingContext.java
index 518106f5818..5ae422a46ef 100755
--- a/messagebus/src/main/java/com/yahoo/messagebus/routing/RoutingContext.java
+++ b/messagebus/src/main/java/com/yahoo/messagebus/routing/RoutingContext.java
@@ -83,8 +83,8 @@ public class RoutingContext {
* @return A modifiable list of recipients.
*/
public List<Route> getMatchedRecipients() {
- List<Route> ret = new ArrayList<Route>();
- Set<String> done = new HashSet<String>();
+ List<Route> ret = new ArrayList<>();
+ Set<String> done = new HashSet<>();
Hop hop = getHop();
for (Route route : node.getRecipients()) {
if (route.hasHops() && hop.matches(route.getHop(0))) {
diff --git a/messagebus/src/main/java/com/yahoo/messagebus/routing/RoutingSpec.java b/messagebus/src/main/java/com/yahoo/messagebus/routing/RoutingSpec.java
index cc1ea562138..5d093567cbd 100644
--- a/messagebus/src/main/java/com/yahoo/messagebus/routing/RoutingSpec.java
+++ b/messagebus/src/main/java/com/yahoo/messagebus/routing/RoutingSpec.java
@@ -30,7 +30,7 @@ public class RoutingSpec {
/**
* Creates an empty specification.
*
- * @param verify Whether or not this should be verified.
+ * @param verify Whether this should be verified.
*/
public RoutingSpec(boolean verify) {
this.verify = verify;
diff --git a/messagebus/src/test/java/com/yahoo/messagebus/network/IdentityTestCase.java b/messagebus/src/test/java/com/yahoo/messagebus/network/IdentityTestCase.java
index 5d2ca40df1a..78140eafd6d 100644
--- a/messagebus/src/test/java/com/yahoo/messagebus/network/IdentityTestCase.java
+++ b/messagebus/src/test/java/com/yahoo/messagebus/network/IdentityTestCase.java
@@ -25,4 +25,5 @@ public class IdentityTestCase {
assertEquals(lhs.getHostname(), rhs.getHostname());
assertEquals(lhs.getServicePrefix(), rhs.getServicePrefix());
}
+
}
diff --git a/messagebus/src/test/java/com/yahoo/messagebus/network/rpc/BasicNetworkTestCase.java b/messagebus/src/test/java/com/yahoo/messagebus/network/rpc/BasicNetworkTestCase.java
index ffe15a7da29..238e59b3a40 100644
--- a/messagebus/src/test/java/com/yahoo/messagebus/network/rpc/BasicNetworkTestCase.java
+++ b/messagebus/src/test/java/com/yahoo/messagebus/network/rpc/BasicNetworkTestCase.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.messagebus.network.rpc;
-
import com.yahoo.concurrent.SystemTimer;
import com.yahoo.jrt.ListenFailedException;
import com.yahoo.jrt.slobrok.server.Slobrok;
@@ -17,12 +16,11 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import java.net.UnknownHostException;
import java.util.Arrays;
+import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
-
/**
* @author havardpe
*/
@@ -36,8 +34,8 @@ public class BasicNetworkTestCase {
@BeforeEach
public void setUp() throws ListenFailedException {
RoutingTableSpec table = new RoutingTableSpec(SimpleProtocol.NAME);
- table.addHop("pxy", "test/pxy/session", Arrays.asList("test/pxy/session"));
- table.addHop("dst", "test/dst/session", Arrays.asList("test/dst/session"));
+ table.addHop("pxy", "test/pxy/session", List.of("test/pxy/session"));
+ table.addHop("dst", "test/dst/session", List.of("test/dst/session"));
table.addRoute("test", Arrays.asList("pxy", "dst"));
slobrok = new Slobrok();
src = new TestServer("test/src", table, slobrok, null);
@@ -79,7 +77,7 @@ public class BasicNetworkTestCase {
// check message on proxy
Message msg = pxy_mr.getMessage(60);
- assertTrue(msg != null);
+ assertNotNull(msg);
assertEquals(SimpleProtocol.MESSAGE, msg.getType());
SimpleMessage sm = (SimpleMessage) msg;
assertEquals("test message", sm.getValue());
@@ -90,7 +88,7 @@ public class BasicNetworkTestCase {
// check message on server
msg = dst_mr.getMessage(60);
- assertTrue(msg != null);
+ assertNotNull(msg);
assertEquals(SimpleProtocol.MESSAGE, msg.getType());
sm = (SimpleMessage) msg;
assertEquals("test message pxy", sm.getValue());
@@ -102,7 +100,7 @@ public class BasicNetworkTestCase {
// check reply on proxy
Reply reply = pxy_rr.getReply(60);
- assertTrue(reply != null);
+ assertNotNull(reply);
assertEquals(SimpleProtocol.REPLY, reply.getType());
sr = (SimpleReply) reply;
assertEquals("test reply", sr.getValue());
@@ -113,7 +111,7 @@ public class BasicNetworkTestCase {
// check reply on client
reply = src_rr.getReply(60);
- assertTrue(reply != null);
+ assertNotNull(reply);
assertEquals(SimpleProtocol.REPLY, reply.getType());
sr = (SimpleReply) reply;
assertEquals("test reply pxy", sr.getValue());
diff --git a/messagebus/src/test/java/com/yahoo/messagebus/network/rpc/LoadBalanceTestCase.java b/messagebus/src/test/java/com/yahoo/messagebus/network/rpc/LoadBalanceTestCase.java
index 0856fb09318..bd13e73ed98 100644
--- a/messagebus/src/test/java/com/yahoo/messagebus/network/rpc/LoadBalanceTestCase.java
+++ b/messagebus/src/test/java/com/yahoo/messagebus/network/rpc/LoadBalanceTestCase.java
@@ -32,13 +32,10 @@ public class LoadBalanceTestCase {
// set up handlers
final QueueAdapter sq = new QueueAdapter();
SourceSession ss = src.mb.createSourceSession(new SourceSessionParams().setTimeout(600.0).setThrottlePolicy(null)
- .setReplyHandler(new ReplyHandler() {
- @Override
- public void handleReply(Reply reply) {
- System.out.println(Thread.currentThread().getName() + ": Reply '" +
- ((SimpleMessage) reply.getMessage()).getValue() + "' received at source.");
- sq.handleReply(reply);
- }
+ .setReplyHandler(reply -> {
+ System.out.println(Thread.currentThread().getName() + ": Reply '" +
+ ((SimpleMessage) reply.getMessage()).getValue() + "' received at source.");
+ sq.handleReply(reply);
}));
SimpleDestination h1 = new SimpleDestination(dst1.mb, dst1.net.getIdentity());
SimpleDestination h2 = new SimpleDestination(dst2.mb, dst2.net.getIdentity());
diff --git a/messagebus/src/test/java/com/yahoo/messagebus/network/rpc/RPCNetworkTestCase.java b/messagebus/src/test/java/com/yahoo/messagebus/network/rpc/RPCNetworkTestCase.java
index e8ea5f60715..2c8264addf2 100644
--- a/messagebus/src/test/java/com/yahoo/messagebus/network/rpc/RPCNetworkTestCase.java
+++ b/messagebus/src/test/java/com/yahoo/messagebus/network/rpc/RPCNetworkTestCase.java
@@ -99,4 +99,5 @@ public class RPCNetworkTestCase {
return new MyProtocol(e);
}
}
+
}
diff --git a/messagebus/src/test/java/com/yahoo/messagebus/network/rpc/SendAdapterTestCase.java b/messagebus/src/test/java/com/yahoo/messagebus/network/rpc/SendAdapterTestCase.java
index c4cbf8ce6fb..3daa4a08781 100755
--- a/messagebus/src/test/java/com/yahoo/messagebus/network/rpc/SendAdapterTestCase.java
+++ b/messagebus/src/test/java/com/yahoo/messagebus/network/rpc/SendAdapterTestCase.java
@@ -37,12 +37,6 @@ import static org.junit.jupiter.api.Assertions.*;
*/
public class SendAdapterTestCase {
- ////////////////////////////////////////////////////////////////////////////////
- //
- // Setup
- //
- ////////////////////////////////////////////////////////////////////////////////
-
Slobrok slobrok;
TestServer srcServer, itrServer, dstServer;
SourceSession srcSession;
@@ -82,12 +76,6 @@ public class SendAdapterTestCase {
srcServer.destroy();
}
- ////////////////////////////////////////////////////////////////////////////////
- //
- // Tests
- //
- ////////////////////////////////////////////////////////////////////////////////
-
@Test
void requireCorrectVersionSelection() {
assertNull(srcServer.net.getSendAdapter(new Version(4, 999)));
@@ -113,14 +101,7 @@ public class SendAdapterTestCase {
}
}
- ////////////////////////////////////////////////////////////////////////////////
- //
- // Utilities
- //
- ////////////////////////////////////////////////////////////////////////////////
-
private void assertVersionedSend(Version srcVersion, Version itrVersion, Version dstVersion) {
- System.out.println("Sending from " + srcVersion + " through " + itrVersion + " to " + dstVersion + ":");
srcServer.net.setVersion(srcVersion);
itrServer.net.setVersion(itrVersion);
dstServer.net.setVersion(dstVersion);
@@ -129,36 +110,28 @@ public class SendAdapterTestCase {
msg.getTrace().setLevel(9);
assertTrue(srcSession.send(msg, Route.parse("itr/session dst/session")).isAccepted());
assertNotNull(msg = ((Receptor)itrSession.getMessageHandler()).getMessage(300));
- System.out.println("\tMessage version " + srcProtocol.lastVersion + " serialized at source.");
Version minVersion = srcVersion.compareTo(itrVersion) < 0 ? srcVersion : itrVersion;
assertEquals(minVersion, srcProtocol.lastVersion);
- System.out.println("\tMessage version " + itrProtocol.lastVersion + " reached intermediate.");
assertEquals(minVersion, itrProtocol.lastVersion);
itrSession.forward(msg);
assertNotNull(msg = ((Receptor)dstSession.getMessageHandler()).getMessage(300));
- System.out.println("\tMessage version " + itrProtocol.lastVersion + " serialized at intermediate.");
minVersion = itrVersion.compareTo(dstVersion) < 0 ? itrVersion : dstVersion;
assertEquals(minVersion, itrProtocol.lastVersion);
- System.out.println("\tMessage version " + dstProtocol.lastVersion + " reached destination.");
assertEquals(minVersion, dstProtocol.lastVersion);
Reply reply = new SimpleReply("bar");
reply.swapState(msg);
dstSession.reply(reply);
assertNotNull(reply = ((Receptor)itrSession.getReplyHandler()).getReply(300));
- System.out.println("\tReply version " + dstProtocol.lastVersion + " serialized at destination.");
assertEquals(minVersion, dstProtocol.lastVersion);
- System.out.println("\tReply version " + itrProtocol.lastVersion + " reached intermediate.");
assertEquals(minVersion, itrProtocol.lastVersion);
itrSession.forward(reply);
assertNotNull(((Receptor)srcSession.getReplyHandler()).getReply(300));
- System.out.println("\tReply version " + itrProtocol.lastVersion + " serialized at intermediate.");
minVersion = srcVersion.compareTo(itrVersion) < 0 ? srcVersion : itrVersion;
assertEquals(minVersion, itrProtocol.lastVersion);
- System.out.println("\tReply version " + srcProtocol.lastVersion + " reached source.");
assertEquals(minVersion, srcProtocol.lastVersion);
}
@@ -177,4 +150,5 @@ public class SendAdapterTestCase {
return super.decode(version, payload);
}
}
+
}
diff --git a/messagebus/src/test/java/com/yahoo/messagebus/network/rpc/ServiceAddressTestCase.java b/messagebus/src/test/java/com/yahoo/messagebus/network/rpc/ServiceAddressTestCase.java
index af039dc46cb..ecf84ab3a68 100755
--- a/messagebus/src/test/java/com/yahoo/messagebus/network/rpc/ServiceAddressTestCase.java
+++ b/messagebus/src/test/java/com/yahoo/messagebus/network/rpc/ServiceAddressTestCase.java
@@ -29,7 +29,7 @@ public class ServiceAddressTestCase {
network = new RPCNetwork(new RPCNetworkParams()
.setIdentity(new Identity("foo"))
.setSlobrokConfigId("raw:slobrok[1]\nslobrok[0].connectionspec \"" +
- new Spec("localhost", slobrok.port()).toString() + "\"\n"));
+ new Spec("localhost", slobrok.port()) + "\"\n"));
}
@AfterEach
diff --git a/messagebus/src/test/java/com/yahoo/messagebus/network/rpc/SlobrokTestCase.java b/messagebus/src/test/java/com/yahoo/messagebus/network/rpc/SlobrokTestCase.java
index 35dad077809..0badfd58929 100644
--- a/messagebus/src/test/java/com/yahoo/messagebus/network/rpc/SlobrokTestCase.java
+++ b/messagebus/src/test/java/com/yahoo/messagebus/network/rpc/SlobrokTestCase.java
@@ -43,11 +43,7 @@ public class SlobrokTestCase {
int port3;
void check(RPCNetwork net, String pattern, List<Mirror.Entry> expect) {
- Comparator<Mirror.Entry> cmp = new Comparator<Mirror.Entry>() {
- public int compare(Mirror.Entry a, Mirror.Entry b) {
- return a.compareTo(b);
- }
- };
+ Comparator<Mirror.Entry> cmp = Comparator.naturalOrder();
expect.sort(cmp);
List<Mirror.Entry> actual = null;
for (int i = 0; i < 1000; i++) {
diff --git a/messagebus/src/test/java/com/yahoo/messagebus/routing/AdvancedRoutingTestCase.java b/messagebus/src/test/java/com/yahoo/messagebus/routing/AdvancedRoutingTestCase.java
index 37024456878..e66756992ee 100755
--- a/messagebus/src/test/java/com/yahoo/messagebus/routing/AdvancedRoutingTestCase.java
+++ b/messagebus/src/test/java/com/yahoo/messagebus/routing/AdvancedRoutingTestCase.java
@@ -113,7 +113,6 @@ public class AdvancedRoutingTestCase {
// Done.
reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
- System.out.println(reply.getTrace());
assertEquals(2, reply.getNumErrors());
assertEquals(ErrorCode.FATAL_ERROR, reply.getError(0).getCode());
assertEquals(ErrorCode.NO_ADDRESS_FOR_SERVICE, reply.getError(1).getCode());
diff --git a/messagebus/src/test/java/com/yahoo/messagebus/routing/ResenderTestCase.java b/messagebus/src/test/java/com/yahoo/messagebus/routing/ResenderTestCase.java
index 3bc607f169b..ac0d709bc2c 100755
--- a/messagebus/src/test/java/com/yahoo/messagebus/routing/ResenderTestCase.java
+++ b/messagebus/src/test/java/com/yahoo/messagebus/routing/ResenderTestCase.java
@@ -67,7 +67,7 @@ public class ResenderTestCase {
assertNotNull(msg);
for (int i = 0; i < 5; ++i) {
assertEquals(i, msg.getRetry());
- assertEquals(true, msg.getRetryEnabled());
+ assertTrue(msg.getRetryEnabled());
replyFromDestination(msg, ErrorCode.APP_TRANSIENT_ERROR, 0);
assertNotNull(msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60));
}
@@ -76,7 +76,6 @@ public class ResenderTestCase {
assertNotNull(reply);
assertFalse(reply.hasErrors());
assertNull(((Receptor) dstSession.getMessageHandler()).getMessage(0));
- System.out.println(reply.getTrace());
}
@Test
@@ -85,13 +84,12 @@ public class ResenderTestCase {
msg.setRetryEnabled(false);
assertTrue(srcSession.send(msg, Route.parse("dst/session")).isAccepted());
assertNotNull(msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60));
- assertEquals(false, msg.getRetryEnabled());
+ assertFalse(msg.getRetryEnabled());
replyFromDestination(msg, ErrorCode.APP_TRANSIENT_ERROR, 0);
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
assertTrue(reply.hasErrors());
assertNull(((Receptor) dstSession.getMessageHandler()).getMessage(0));
- System.out.println(reply.getTrace());
}
@Test
@@ -174,7 +172,6 @@ public class ResenderTestCase {
assertNull(((Receptor) dstSession.getMessageHandler()).getMessage(0));
String trace = reply.getTrace().toString();
- System.out.println(trace);
assertTrue(trace.contains("retry 1 in 0"));
assertTrue(trace.contains("retry 2 in 0.02"));
assertTrue(trace.contains("retry 3 in 0.04"));
diff --git a/messagebus/src/test/java/com/yahoo/messagebus/routing/RetryPolicyTestCase.java b/messagebus/src/test/java/com/yahoo/messagebus/routing/RetryPolicyTestCase.java
index 6d3790e1407..158d52fbcbb 100644
--- a/messagebus/src/test/java/com/yahoo/messagebus/routing/RetryPolicyTestCase.java
+++ b/messagebus/src/test/java/com/yahoo/messagebus/routing/RetryPolicyTestCase.java
@@ -10,6 +10,7 @@ import static org.junit.jupiter.api.Assertions.*;
* @author Simon Thoresen Hult
*/
public class RetryPolicyTestCase {
+
private static final double SMALL = 0.00000000000000000001;
@Test
diff --git a/messagebus/src/test/java/com/yahoo/messagebus/routing/RouteParserTestCase.java b/messagebus/src/test/java/com/yahoo/messagebus/routing/RouteParserTestCase.java
index aef61a05263..e6f3ca7fbd5 100755
--- a/messagebus/src/test/java/com/yahoo/messagebus/routing/RouteParserTestCase.java
+++ b/messagebus/src/test/java/com/yahoo/messagebus/routing/RouteParserTestCase.java
@@ -138,7 +138,6 @@ public class RouteParserTestCase {
private static void assertError(Hop hop, String msg) {
assertNotNull(hop);
- System.out.println(hop.toDebugString());
assertEquals(1, hop.getNumDirectives());
assertErrorDirective(hop.getDirective(0), msg);
}
diff --git a/messagebus/src/test/java/com/yahoo/messagebus/routing/RoutingContextTestCase.java b/messagebus/src/test/java/com/yahoo/messagebus/routing/RoutingContextTestCase.java
index 42a6b244508..b8aa6db8d8a 100755
--- a/messagebus/src/test/java/com/yahoo/messagebus/routing/RoutingContextTestCase.java
+++ b/messagebus/src/test/java/com/yahoo/messagebus/routing/RoutingContextTestCase.java
@@ -96,7 +96,6 @@ public class RoutingContextTestCase {
assertTrue(srcSession.send(createMessage("msg"), "myroute").isAccepted());
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(TIMEOUT_SECS);
assertNotNull(reply);
- System.out.println(reply.getTrace());
assertFalse(reply.hasErrors());
}
}
@@ -104,8 +103,8 @@ public class RoutingContextTestCase {
@Test
void testRecipientsRemain() {
SimpleProtocol protocol = new SimpleProtocol();
- protocol.addPolicyFactory("First", new CustomPolicyFactory(true, Arrays.asList("foo/bar"), Arrays.asList("foo/[Second]")));
- protocol.addPolicyFactory("Second", new CustomPolicyFactory(false, Arrays.asList("foo/bar"), Arrays.asList("foo/bar")));
+ protocol.addPolicyFactory("First", new CustomPolicyFactory(true, List.of("foo/bar"), List.of("foo/[Second]")));
+ protocol.addPolicyFactory("Second", new CustomPolicyFactory(false, List.of("foo/bar"), List.of("foo/bar")));
srcServer.mb.putProtocol(protocol);
srcServer.setupRouting(new RoutingTableSpec(SimpleProtocol.NAME)
.addRoute(new RouteSpec("myroute").addHop("myhop"))
@@ -115,7 +114,6 @@ public class RoutingContextTestCase {
assertTrue(srcSession.send(createMessage("msg"), "myroute").isAccepted());
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(TIMEOUT_SECS);
assertNotNull(reply);
- System.out.println(reply.getTrace());
assertFalse(reply.hasErrors());
}
}
@@ -129,7 +127,7 @@ public class RoutingContextTestCase {
void testConstRoute() {
SimpleProtocol protocol = new SimpleProtocol();
protocol.addPolicyFactory("DocumentRouteSelector",
- new CustomPolicyFactory(true, Arrays.asList("dst"), Arrays.asList("dst")));
+ new CustomPolicyFactory(true, List.of("dst"), List.of("dst")));
srcServer.mb.putProtocol(protocol);
srcServer.setupRouting(new RoutingTableSpec(SimpleProtocol.NAME)
.addRoute(new RouteSpec("default").addHop("indexing"))
@@ -142,7 +140,6 @@ public class RoutingContextTestCase {
dstSession.acknowledge(msg);
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(TIMEOUT_SECS);
assertNotNull(reply);
- System.out.println(reply.getTrace());
assertFalse(reply.hasErrors());
}
}
diff --git a/messagebus/src/test/java/com/yahoo/messagebus/routing/RoutingSpecTestCase.java b/messagebus/src/test/java/com/yahoo/messagebus/routing/RoutingSpecTestCase.java
index 28dcadf1896..b38ac632a37 100755
--- a/messagebus/src/test/java/com/yahoo/messagebus/routing/RoutingSpecTestCase.java
+++ b/messagebus/src/test/java/com/yahoo/messagebus/routing/RoutingSpecTestCase.java
@@ -70,11 +70,11 @@ public class RoutingSpecTestCase {
@Test
void testApplicationSpec() {
- assertApplicationSpec(Arrays.asList("foo"),
- Arrays.asList("foo",
+ assertApplicationSpec(List.of("foo"),
+ Arrays.asList("foo",
"*"));
- assertApplicationSpec(Arrays.asList("foo/bar"),
- Arrays.asList("foo/bar",
+ assertApplicationSpec(List.of("foo/bar"),
+ Arrays.asList("foo/bar",
"foo/*",
"*/bar",
"*/*"));
@@ -149,7 +149,7 @@ public class RoutingSpecTestCase {
.addTable(new RoutingTableSpec("mytable"))
.addTable(new RoutingTableSpec("mytable")),
new ApplicationSpec(),
- Arrays.asList("Routing table 'mytable' is defined 2 times."));
+ List.of("Routing table 'mytable' is defined 2 times."));
// Duplicate hop.
assertVerifyFail(new RoutingSpec().addTable(new RoutingTableSpec("mytable")
@@ -158,7 +158,7 @@ public class RoutingSpecTestCase {
new ApplicationSpec()
.addService("mytable", "bar")
.addService("mytable", "baz"),
- Arrays.asList("Hop 'foo' in routing table 'mytable' is defined 2 times."));
+ List.of("Hop 'foo' in routing table 'mytable' is defined 2 times."));
// Duplicate route.
assertVerifyFail(new RoutingSpec().addTable(new RoutingTableSpec("mytable")
@@ -167,67 +167,67 @@ public class RoutingSpecTestCase {
new ApplicationSpec()
.addService("mytable", "bar")
.addService("mytable", "baz"),
- Arrays.asList("Route 'foo' in routing table 'mytable' is defined 2 times."));
+ List.of("Route 'foo' in routing table 'mytable' is defined 2 times."));
// Empty hop.
assertVerifyFail(new RoutingSpec().addTable(new RoutingTableSpec("mytable")
.addHop(new HopSpec("foo", ""))),
new ApplicationSpec(),
- Arrays.asList("For hop 'foo' in routing table 'mytable'; Failed to parse empty string."));
+ List.of("For hop 'foo' in routing table 'mytable'; Failed to parse empty string."));
// Empty route.
assertVerifyFail(new RoutingSpec().addTable(new RoutingTableSpec("mytable")
.addRoute(new RouteSpec("foo"))),
new ApplicationSpec(),
- Arrays.asList("Route 'foo' in routing table 'mytable' has no hops."));
+ List.of("Route 'foo' in routing table 'mytable' has no hops."));
// Hop error.
assertVerifyFail(new RoutingSpec().addTable(new RoutingTableSpec("mytable")
.addHop(new HopSpec("foo", "bar/baz cox"))),
new ApplicationSpec(),
- Arrays.asList("For hop 'foo' in routing table 'mytable'; Failed to completely parse 'bar/baz cox'."));
+ List.of("For hop 'foo' in routing table 'mytable'; Failed to completely parse 'bar/baz cox'."));
// Hop error in recipient.
assertVerifyFail(new RoutingSpec().addTable(new RoutingTableSpec("mytable")
.addHop(new HopSpec("foo", "[bar]").addRecipient("bar/baz cox"))),
new ApplicationSpec(),
- Arrays.asList("For recipient 'bar/baz cox' in hop 'foo' in routing table 'mytable'; Failed to completely parse 'bar/baz cox'."));
+ List.of("For recipient 'bar/baz cox' in hop 'foo' in routing table 'mytable'; Failed to completely parse 'bar/baz cox'."));
// Hop error in route.
assertVerifyFail(new RoutingSpec().addTable(new RoutingTableSpec("mytable")
.addRoute(new RouteSpec("foo").addHop("bar/baz cox"))),
new ApplicationSpec(),
- Arrays.asList("For hop 1 in route 'foo' in routing table 'mytable'; Failed to completely parse 'bar/baz cox'."));
+ List.of("For hop 1 in route 'foo' in routing table 'mytable'; Failed to completely parse 'bar/baz cox'."));
// Hop not found.
assertVerifyFail(new RoutingSpec().addTable(new RoutingTableSpec("mytable")
.addRoute(new RouteSpec("foo").addHop("bar"))),
new ApplicationSpec(),
- Arrays.asList("Hop 1 in route 'foo' in routing table 'mytable' references 'bar' which is neither a service, a route nor another hop."));
+ List.of("Hop 1 in route 'foo' in routing table 'mytable' references 'bar' which is neither a service, a route nor another hop."));
// Mismatched recipient.
assertVerifyFail(new RoutingSpec().addTable(new RoutingTableSpec("mytable")
.addHop(new HopSpec("foo", "bar/[baz]/cox").addRecipient("cox/0/bar"))),
new ApplicationSpec(),
- Arrays.asList("Selector 'bar/[baz]/cox' does not match recipient 'cox/0/bar' in hop 'foo' in routing table 'mytable'."));
+ List.of("Selector 'bar/[baz]/cox' does not match recipient 'cox/0/bar' in hop 'foo' in routing table 'mytable'."));
// Route not found.
assertVerifyFail(new RoutingSpec().addTable(new RoutingTableSpec("mytable")
.addHop(new HopSpec("foo", "route:bar"))),
new ApplicationSpec(),
- Arrays.asList("Hop 'foo' in routing table 'mytable' references route 'bar' which does not exist."));
+ List.of("Hop 'foo' in routing table 'mytable' references route 'bar' which does not exist."));
// Route not found in route.
assertVerifyFail(new RoutingSpec().addTable(new RoutingTableSpec("mytable")
.addRoute(new RouteSpec("foo").addHop("route:bar"))),
new ApplicationSpec(),
- Arrays.asList("Hop 1 in route 'foo' in routing table 'mytable' references route 'bar' which does not exist."));
+ List.of("Hop 1 in route 'foo' in routing table 'mytable' references route 'bar' which does not exist."));
// Service not found.
assertVerifyFail(new RoutingSpec().addTable(new RoutingTableSpec("mytable")
.addHop(new HopSpec("foo", "bar/baz"))),
new ApplicationSpec(),
- Arrays.asList("Hop 'foo' in routing table 'mytable' references 'bar/baz' which is neither a service, a route nor another hop."));
+ List.of("Hop 'foo' in routing table 'mytable' references 'bar/baz' which is neither a service, a route nor another hop."));
// Unexpected recipient.
assertVerifyFail(new RoutingSpec().addTable(new RoutingTableSpec("mytable")
@@ -235,7 +235,7 @@ public class RoutingSpecTestCase {
new ApplicationSpec()
.addService("mytable", "bar")
.addService("mytable", "baz"),
- Arrays.asList("Hop 'foo' in routing table 'mytable' has recipients but no policy directive."));
+ List.of("Hop 'foo' in routing table 'mytable' has recipients but no policy directive."));
// Multiple errors.
assertVerifyFail(new RoutingSpec()
diff --git a/messagebus/src/test/java/com/yahoo/messagebus/routing/RoutingTestCase.java b/messagebus/src/test/java/com/yahoo/messagebus/routing/RoutingTestCase.java
index db5dce04af0..174895b17a1 100644
--- a/messagebus/src/test/java/com/yahoo/messagebus/routing/RoutingTestCase.java
+++ b/messagebus/src/test/java/com/yahoo/messagebus/routing/RoutingTestCase.java
@@ -105,31 +105,24 @@ public class RoutingTestCase {
@Test
void requireThatNullRouteIsCaught() {
- log.log(Level.INFO, "Starting: requireThatNullRouteIsCaught");
assertTrue(srcSession.send(createMessage("msg")).isAccepted());
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
- System.out.println(reply.getTrace());
assertEquals(1, reply.getNumErrors());
assertEquals(ErrorCode.ILLEGAL_ROUTE, reply.getError(0).getCode());
- log.log(Level.INFO, "Finished: requireThatNullRouteIsCaught");
}
@Test
void requireThatEmptyRouteIsCaught() {
- log.log(Level.INFO, "Starting: requireThatEmptyRouteIsCaught");
assertTrue(srcSession.send(createMessage("msg"), new Route()).isAccepted());
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
- System.out.println(reply.getTrace());
assertEquals(1, reply.getNumErrors());
assertEquals(ErrorCode.ILLEGAL_ROUTE, reply.getError(0).getCode());
- log.log(Level.INFO, "Finished: requireThatEmptyRouteIsCaught");
}
@Test
void requireThatHopNameIsExpanded() {
- log.log(Level.INFO, "Starting: requireThatHopNameIsExpanded");
srcServer.setupRouting(new RoutingTableSpec(SimpleProtocol.NAME)
.addHop(new HopSpec("dst", dstSessName)));
assertTrue(srcSession.send(createMessage("msg"), Route.parse("dst")).isAccepted());
@@ -138,14 +131,11 @@ public class RoutingTestCase {
dstSession.acknowledge(msg);
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
- System.out.println(reply.getTrace());
assertFalse(reply.hasErrors());
- log.log(Level.INFO, "Finished: requireThatHopNameIsExpanded");
}
@Test
void requireThatRouteDirectiveWorks() {
- log.log(Level.INFO, "Starting: requireThatRouteDirectiveWorks");
srcServer.setupRouting(new RoutingTableSpec(SimpleProtocol.NAME)
.addRoute(new RouteSpec("dst").addHop(dstSessName))
.addHop(new HopSpec("dir", "route:dst")));
@@ -155,14 +145,11 @@ public class RoutingTestCase {
dstSession.acknowledge(msg);
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
- System.out.println(reply.getTrace());
assertFalse(reply.hasErrors());
- log.log(Level.INFO, "Finished: requireThatRouteDirectiveWorks");
}
@Test
void requireThatRouteNameIsExpanded() {
- log.log(Level.INFO, "Starting: requireThatRouteNameIsExpanded");
srcServer.setupRouting(new RoutingTableSpec(SimpleProtocol.NAME)
.addRoute(new RouteSpec("dst").addHop(dstSessName)));
assertTrue(srcSession.send(createMessage("msg"), Route.parse("dst")).isAccepted());
@@ -171,43 +158,34 @@ public class RoutingTestCase {
dstSession.acknowledge(msg);
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
- System.out.println(reply.getTrace());
assertFalse(reply.hasErrors());
- log.log(Level.INFO, "Finished: requireThatRouteNameIsExpanded");
}
@Test
void requireThatHopResolutionOverflowIsCaught() {
- log.log(Level.INFO, "Starting: requireThatHopResolutionOverflowIsCaught");
srcServer.setupRouting(new RoutingTableSpec(SimpleProtocol.NAME)
.addHop(new HopSpec("foo", "bar"))
.addHop(new HopSpec("bar", "foo")));
assertTrue(srcSession.send(createMessage("msg"), Route.parse("foo")).isAccepted());
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
- System.out.println(reply.getTrace());
assertEquals(1, reply.getNumErrors());
assertEquals(ErrorCode.ILLEGAL_ROUTE, reply.getError(0).getCode());
- log.log(Level.INFO, "Finished: requireThatHopResolutionOverflowIsCaught");
}
@Test
void requireThatRouteResolutionOverflowIsCaught() {
- log.log(Level.INFO, "Starting: requireThatRouteResolutionOverflowIsCaught");
srcServer.setupRouting(new RoutingTableSpec(SimpleProtocol.NAME)
.addRoute(new RouteSpec("foo").addHop("route:foo")));
assertTrue(srcSession.send(createMessage("msg"), "foo").isAccepted());
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
- System.out.println(reply.getTrace());
assertEquals(1, reply.getNumErrors());
assertEquals(ErrorCode.ILLEGAL_ROUTE, reply.getError(0).getCode());
- log.log(Level.INFO, "Finished: requireThatRouteResolutionOverflowIsCaught");
}
@Test
void requireThatRouteExpansionOnlyReplacesFirstHop() {
- log.log(Level.INFO, "Starting: requireThatRouteExpansionOnlyReplacesFirstHop");
srcServer.setupRouting(new RoutingTableSpec(SimpleProtocol.NAME)
.addRoute(new RouteSpec("foo").addHop(dstSessName).addHop("bar")));
assertTrue(srcSession.send(createMessage("msg"), Route.parse("route:foo baz")).isAccepted());
@@ -219,29 +197,23 @@ public class RoutingTestCase {
dstSession.acknowledge(msg);
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
- System.out.println(reply.getTrace());
assertFalse(reply.hasErrors());
- log.log(Level.INFO, "Finished: requireThatRouteExpansionOnlyReplacesFirstHop");
}
@Test
void requireThatErrorDirectiveWorks() {
- log.log(Level.INFO, "Starting: requireThatErrorDirectiveWorks");
Route route = Route.parse("foo/bar/baz");
route.getHop(0).setDirective(1, new ErrorDirective("err"));
assertTrue(srcSession.send(createMessage("msg"), route).isAccepted());
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
- System.out.println(reply.getTrace());
assertEquals(1, reply.getNumErrors());
assertEquals(ErrorCode.ILLEGAL_ROUTE, reply.getError(0).getCode());
assertEquals("err", reply.getError(0).getMessage());
- log.log(Level.INFO, "Finished: requireThatErrorDirectiveWorks");
}
@Test
void requireThatIllegalSelectIsCaught() {
- log.log(Level.INFO, "Starting: requireThatIllegalSelectIsCaught");
SimpleProtocol protocol = new SimpleProtocol();
protocol.addPolicyFactory("Custom", new CustomPolicyFactory());
srcServer.mb.putProtocol(protocol);
@@ -250,30 +222,24 @@ public class RoutingTestCase {
assertTrue(srcSession.send(createMessage("msg"), route).isAccepted());
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
- System.out.println(reply.getTrace());
assertEquals(1, reply.getNumErrors());
assertEquals(ErrorCode.NO_SERVICES_FOR_ROUTE, reply.getError(0).getCode());
- log.log(Level.INFO, "Finished: requireThatIllegalSelectIsCaught");
}
@Test
void requireThatEmptySelectIsCaught() {
- log.log(Level.INFO, "Starting: requireThatEmptySelectIsCaught");
SimpleProtocol protocol = new SimpleProtocol();
protocol.addPolicyFactory("Custom", new CustomPolicyFactory());
srcServer.mb.putProtocol(protocol);
assertTrue(srcSession.send(createMessage("msg"), Route.parse("[Custom]")).isAccepted());
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
- System.out.println(reply.getTrace());
assertEquals(1, reply.getNumErrors());
assertEquals(ErrorCode.NO_SERVICES_FOR_ROUTE, reply.getError(0).getCode());
- log.log(Level.INFO, "Finished: requireThatEmptySelectIsCaught");
}
@Test
void requireThatPolicySelectWorks() {
- log.log(Level.INFO, "Starting: requireThatPolicySelectWorks");
SimpleProtocol protocol = new SimpleProtocol();
protocol.addPolicyFactory("Custom", new CustomPolicyFactory());
srcServer.mb.putProtocol(protocol);
@@ -283,14 +249,11 @@ public class RoutingTestCase {
dstSession.acknowledge(msg);
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
- System.out.println(reply.getTrace());
assertFalse(reply.hasErrors());
- log.log(Level.INFO, "Finished: requireThatPolicySelectWorks");
}
@Test
void requireThatTransientErrorsAreRetried() {
- log.log(Level.INFO, "Starting: requireThatTransientErrorsAreRetried");
assertTrue(srcSession.send(createMessage("msg"), Route.parse(dstSessName)).isAccepted());
Message msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60);
assertNotNull(msg);
@@ -306,19 +269,16 @@ public class RoutingTestCase {
assertNotNull(msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60));
dstSession.acknowledge(msg);
assertNotNull(reply = ((Receptor) srcSession.getReplyHandler()).getReply(60));
- System.out.println(reply.getTrace());
assertFalse(reply.hasErrors());
assertTrace(Arrays.asList("[APP_TRANSIENT_ERROR @ localhost]: err1",
"-[APP_TRANSIENT_ERROR @ localhost]: err1",
"[APP_TRANSIENT_ERROR @ localhost]: err2",
"-[APP_TRANSIENT_ERROR @ localhost]: err2"),
reply.getTrace());
- log.log(Level.INFO, "Finished: requireThatTransientErrorsAreRetried");
}
@Test
void requireThatTransientErrorsAreRetriedWithPolicy() {
- log.log(Level.INFO, "Starting: requireThatTransientErrorsAreRetriedWithPolicy");
SimpleProtocol protocol = new SimpleProtocol();
protocol.addPolicyFactory("Custom", new CustomPolicyFactory());
srcServer.mb.putProtocol(protocol);
@@ -337,7 +297,6 @@ public class RoutingTestCase {
assertNotNull(msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60));
dstSession.acknowledge(msg);
assertNotNull(reply = ((Receptor) srcSession.getReplyHandler()).getReply(60));
- System.out.println(reply.getTrace());
assertFalse(reply.hasErrors());
assertTrace(Arrays.asList("Source session accepted a 3 byte message. 1 message(s) now pending.",
"Running routing policy 'Custom'.",
@@ -378,12 +337,10 @@ public class RoutingTestCase {
"Merged [" + dstSessName + "].",
"Source session received reply. 0 message(s) now pending."),
reply.getTrace());
- log.log(Level.INFO, "Finished: requireThatTransientErrorsAreRetriedWithPolicy");
}
@Test
void requireThatRetryCanBeDisabled() {
- log.log(Level.INFO, "Starting: requireThatRetryCanBeDisabled");
retryPolicy.setEnabled(false);
assertTrue(srcSession.send(createMessage("msg"), Route.parse(dstSessName)).isAccepted());
Message msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60);
@@ -394,15 +351,12 @@ public class RoutingTestCase {
dstSession.reply(reply);
reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
- System.out.println(reply.getTrace());
assertEquals(1, reply.getNumErrors());
assertEquals(ErrorCode.APP_TRANSIENT_ERROR, reply.getError(0).getCode());
- log.log(Level.INFO, "Finished: requireThatRetryCanBeDisabled");
}
@Test
void requireThatRetryCallsSelect() {
- log.log(Level.INFO, "Starting: requireThatRetryCallsSelect");
SimpleProtocol protocol = new SimpleProtocol();
protocol.addPolicyFactory("Custom", new CustomPolicyFactory());
srcServer.mb.putProtocol(protocol);
@@ -416,7 +370,6 @@ public class RoutingTestCase {
assertNotNull(msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60));
dstSession.acknowledge(msg);
assertNotNull(reply = ((Receptor) srcSession.getReplyHandler()).getReply(60));
- System.out.println(reply.getTrace());
assertFalse(reply.hasErrors());
assertTrace(Arrays.asList("Selecting [" + dstSessName + "].",
"[APP_TRANSIENT_ERROR @ localhost]",
@@ -426,12 +379,10 @@ public class RoutingTestCase {
"Sending reply",
"Merged [" + dstSessName + "]."),
reply.getTrace());
- log.log(Level.INFO, "Finished: requireThatRetryCallsSelect");
}
@Test
void requireThatPolicyCanDisableReselectOnRetry() {
- log.log(Level.INFO, "Starting: requireThatPolicyCanDisableReselectOnRetry");
SimpleProtocol protocol = new SimpleProtocol();
protocol.addPolicyFactory("Custom", new CustomPolicyFactory(false));
srcServer.mb.putProtocol(protocol);
@@ -445,7 +396,6 @@ public class RoutingTestCase {
assertNotNull(msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60));
dstSession.acknowledge(msg);
assertNotNull(reply = ((Receptor) srcSession.getReplyHandler()).getReply(60));
- System.out.println(reply.getTrace());
assertFalse(reply.hasErrors());
assertTrace(Arrays.asList("Selecting [" + dstSessName + "].",
"[APP_TRANSIENT_ERROR @ localhost]",
@@ -455,12 +405,10 @@ public class RoutingTestCase {
"Sending reply",
"Merged [" + dstSessName + "]."),
reply.getTrace());
- log.log(Level.INFO, "Finished: requireThatPolicyCanDisableReselectOnRetry");
}
@Test
void requireThatPolicyCanConsumeErrors() {
- log.log(Level.INFO, "Starting: requireThatPolicyCanConsumeErrors");
SimpleProtocol protocol = new SimpleProtocol();
protocol.addPolicyFactory("Custom", new CustomPolicyFactory(true, ErrorCode.NO_ADDRESS_FOR_SERVICE));
srcServer.mb.putProtocol(protocol);
@@ -471,7 +419,6 @@ public class RoutingTestCase {
dstSession.acknowledge(msg);
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
- System.out.println(reply.getTrace());
assertEquals(1, reply.getNumErrors());
assertEquals(ErrorCode.NO_ADDRESS_FOR_SERVICE, reply.getError(0).getCode());
assertTrace(Arrays.asList("Selecting [" + dstSessName + ", dst/unknown].",
@@ -479,12 +426,10 @@ public class RoutingTestCase {
"Sending reply",
"Merged [" + dstSessName + ", dst/unknown]."),
reply.getTrace());
- log.log(Level.INFO, "Finished: requireThatPolicyCanConsumeErrors");
}
@Test
void requireThatPolicyOnlyConsumesDeclaredErrors() {
- log.log(Level.INFO, "Starting: requireThatPolicyOnlyConsumesDeclaredErrors");
SimpleProtocol protocol = new SimpleProtocol();
protocol.addPolicyFactory("Custom", new CustomPolicyFactory());
srcServer.mb.putProtocol(protocol);
@@ -492,19 +437,16 @@ public class RoutingTestCase {
assertTrue(srcSession.send(createMessage("msg"), Route.parse("[Custom:dst/unknown]")).isAccepted());
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
- System.out.println(reply.getTrace());
assertEquals(1, reply.getNumErrors());
assertEquals(ErrorCode.NO_ADDRESS_FOR_SERVICE, reply.getError(0).getCode());
assertTrace(Arrays.asList("Selecting [dst/unknown].",
"[NO_ADDRESS_FOR_SERVICE @ localhost]",
"Merged [dst/unknown]."),
reply.getTrace());
- log.log(Level.INFO, "Finished: requireThatPolicyOnlyConsumesDeclaredErrors");
}
@Test
void requireThatPolicyCanExpandToPolicy() {
- log.log(Level.INFO, "Starting: requireThatPolicyCanExpandToPolicy");
SimpleProtocol protocol = new SimpleProtocol();
protocol.addPolicyFactory("Custom", new CustomPolicyFactory(true, ErrorCode.NO_ADDRESS_FOR_SERVICE));
srcServer.mb.putProtocol(protocol);
@@ -516,26 +458,17 @@ public class RoutingTestCase {
dstSession.acknowledge(msg);
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
- System.out.println(reply.getTrace());
assertEquals(1, reply.getNumErrors());
assertEquals(ErrorCode.NO_ADDRESS_FOR_SERVICE, reply.getError(0).getCode());
- log.log(Level.INFO, "Finished: requireThatPolicyCanExpandToPolicy");
}
@Test
void requireThatReplyCanBeRemovedFromChildNodes() {
- log.log(Level.INFO, "Starting: requireThatReplyCanBeRemovedFromChildNodes");
SimpleProtocol protocol = new SimpleProtocol();
- protocol.addPolicyFactory("Custom", new SimpleProtocol.PolicyFactory() {
-
- @Override
- public RoutingPolicy create(String param) {
- return new RemoveReplyPolicy(true,
- Arrays.asList(ErrorCode.NO_ADDRESS_FOR_SERVICE),
- CustomPolicyFactory.parseRoutes(param),
- 0);
- }
- });
+ protocol.addPolicyFactory("Custom", param -> new RemoveReplyPolicy(true,
+ List.of(ErrorCode.NO_ADDRESS_FOR_SERVICE),
+ CustomPolicyFactory.parseRoutes(param),
+ 0));
srcServer.mb.putProtocol(protocol);
retryPolicy.setEnabled(false);
assertTrue(srcSession.send(createMessage("msg"),
@@ -545,28 +478,19 @@ public class RoutingTestCase {
dstSession.acknowledge(msg);
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
- System.out.println(reply.getTrace());
assertFalse(reply.hasErrors());
assertTrace(Arrays.asList("[NO_ADDRESS_FOR_SERVICE @ localhost]",
"-[NO_ADDRESS_FOR_SERVICE @ localhost]",
"Sending message",
"-Sending message"),
reply.getTrace());
- log.log(Level.INFO, "Finished: requireThatReplyCanBeRemovedFromChildNodes");
}
@Test
void requireThatSetReplyWorks() {
- log.log(Level.INFO, "Starting: requireThatSetReplyWorks");
SimpleProtocol protocol = new SimpleProtocol();
protocol.addPolicyFactory("Select", new CustomPolicyFactory(true, ErrorCode.APP_FATAL_ERROR));
- protocol.addPolicyFactory("SetReply", new SimpleProtocol.PolicyFactory() {
-
- @Override
- public RoutingPolicy create(String param) {
- return new SetReplyPolicy(true, Arrays.asList(ErrorCode.APP_FATAL_ERROR), param);
- }
- });
+ protocol.addPolicyFactory("SetReply", param -> new SetReplyPolicy(true, List.of(ErrorCode.APP_FATAL_ERROR), param));
srcServer.mb.putProtocol(protocol);
retryPolicy.setEnabled(false);
assertTrue(
@@ -576,35 +500,20 @@ public class RoutingTestCase {
dstSession.acknowledge(msg);
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
- System.out.println(reply.getTrace());
assertEquals(1, reply.getNumErrors());
assertEquals(ErrorCode.APP_FATAL_ERROR, reply.getError(0).getCode());
assertEquals("foo", reply.getError(0).getMessage());
- log.log(Level.INFO, "Finished: requireThatSetReplyWorks");
}
@Test
void requireThatReplyCanBeReusedOnRetry() {
- log.log(Level.INFO, "Starting: requireThatReplyCanBeReusedOnRetry");
SimpleProtocol protocol = new SimpleProtocol();
- protocol.addPolicyFactory("ReuseReply", new SimpleProtocol.PolicyFactory() {
-
- @Override
- public RoutingPolicy create(String param) {
- return new ReuseReplyPolicy(false,
- Arrays.asList(ErrorCode.APP_FATAL_ERROR),
- CustomPolicyFactory.parseRoutes(param));
- }
- });
- protocol.addPolicyFactory("SetReply", new SimpleProtocol.PolicyFactory() {
-
- @Override
- public RoutingPolicy create(String param) {
- return new SetReplyPolicy(false,
- Arrays.asList(ErrorCode.APP_FATAL_ERROR),
- param);
- }
- });
+ protocol.addPolicyFactory("ReuseReply", param -> new ReuseReplyPolicy(false,
+ List.of(ErrorCode.APP_FATAL_ERROR),
+ CustomPolicyFactory.parseRoutes(param)));
+ protocol.addPolicyFactory("SetReply", param -> new SetReplyPolicy(false,
+ List.of(ErrorCode.APP_FATAL_ERROR),
+ param));
srcServer.mb.putProtocol(protocol);
assertTrue(srcSession.send(createMessage("msg"),
Route.parse("[ReuseReply:[SetReply:foo]," + dstSessName + "]")).isAccepted());
@@ -617,34 +526,19 @@ public class RoutingTestCase {
assertNotNull(msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60));
dstSession.acknowledge(msg);
assertNotNull(reply = ((Receptor) srcSession.getReplyHandler()).getReply(60));
- System.out.println(reply.getTrace());
assertFalse(reply.hasErrors());
- log.log(Level.INFO, "Finished: requireThatReplyCanBeReusedOnRetry");
}
@Test
void requireThatReplyCanBeRemovedAndRetried() {
- log.log(Level.INFO, "Starting: requireThatReplyCanBeRemovedAndRetried");
SimpleProtocol protocol = new SimpleProtocol();
- protocol.addPolicyFactory("RemoveReply", new SimpleProtocol.PolicyFactory() {
-
- @Override
- public RoutingPolicy create(String param) {
- return new RemoveReplyPolicy(false,
- Arrays.asList(ErrorCode.APP_TRANSIENT_ERROR),
- CustomPolicyFactory.parseRoutes(param),
- 0);
- }
- });
- protocol.addPolicyFactory("SetReply", new SimpleProtocol.PolicyFactory() {
-
- @Override
- public RoutingPolicy create(String param) {
- return new SetReplyPolicy(false,
- Arrays.asList(ErrorCode.APP_TRANSIENT_ERROR, ErrorCode.APP_FATAL_ERROR),
- param);
- }
- });
+ protocol.addPolicyFactory("RemoveReply", param -> new RemoveReplyPolicy(false,
+ List.of(ErrorCode.APP_TRANSIENT_ERROR),
+ CustomPolicyFactory.parseRoutes(param),
+ 0));
+ protocol.addPolicyFactory("SetReply", param -> new SetReplyPolicy(false,
+ Arrays.asList(ErrorCode.APP_TRANSIENT_ERROR, ErrorCode.APP_FATAL_ERROR),
+ param));
srcServer.mb.putProtocol(protocol);
assertTrue(srcSession
.send(createMessage("msg"), Route.parse("[RemoveReply:[SetReply:foo]," + dstSessName + "]")).isAccepted());
@@ -653,7 +547,6 @@ public class RoutingTestCase {
dstSession.acknowledge(msg);
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
- System.out.println(reply.getTrace());
assertEquals(1, reply.getNumErrors());
assertEquals(ErrorCode.APP_FATAL_ERROR, reply.getError(0).getCode());
assertEquals("foo", reply.getError(0).getMessage());
@@ -663,12 +556,10 @@ public class RoutingTestCase {
"Resolving '" + dstSessName + "'.",
"Resolving '[SetReply:foo]'."),
reply.getTrace());
- log.log(Level.INFO, "Finished: requireThatReplyCanBeRemovedAndRetried");
}
@Test
void requireThatIgnoreResultWorks() {
- log.log(Level.INFO, "Starting: requireThatIgnoreResultWorks");
assertTrue(srcSession.send(createMessage("msg"), Route.parse("?" + dstSessName)).isAccepted());
Message msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60);
assertNotNull(msg);
@@ -677,16 +568,12 @@ public class RoutingTestCase {
reply.addError(new Error(ErrorCode.APP_FATAL_ERROR, "dst"));
dstSession.reply(reply);
assertNotNull(reply = ((Receptor) srcSession.getReplyHandler()).getReply(60));
- System.out.println(reply.getTrace());
assertFalse(reply.hasErrors());
- assertTrace(Arrays.asList("Not waiting for a reply from '" + dstSessName + "'."),
- reply.getTrace());
- log.log(Level.INFO, "Finished: requireThatIgnoreResultWorks");
+ assertTrace(List.of("Not waiting for a reply from '" + dstSessName + "'."), reply.getTrace());
}
@Test
void requireThatIgnoreResultCanBeSetInHopBlueprint() {
- log.log(Level.INFO, "Starting: requireThatIgnoreResultCanBeSetInHopBlueprint");
srcServer.setupRouting(new RoutingTableSpec(SimpleProtocol.NAME)
.addHop(new HopSpec("foo", dstSessName).setIgnoreResult(true)));
assertTrue(srcSession.send(createMessage("msg"), Route.parse("foo")).isAccepted());
@@ -697,43 +584,33 @@ public class RoutingTestCase {
reply.addError(new Error(ErrorCode.APP_FATAL_ERROR, "dst"));
dstSession.reply(reply);
assertNotNull(reply = ((Receptor) srcSession.getReplyHandler()).getReply(60));
- System.out.println(reply.getTrace());
assertFalse(reply.hasErrors());
- assertTrace(Arrays.asList("Not waiting for a reply from '" + dstSessName + "'."),
- reply.getTrace());
- log.log(Level.INFO, "Finished: requireThatIgnoreResultCanBeSetInHopBlueprint");
+ assertTrace(List.of("Not waiting for a reply from '" + dstSessName + "'."), reply.getTrace());
}
@Test
void requireThatIgnoreFlagPersistsThroughHopLookup() {
- log.log(Level.INFO, "Starting: requireThatIgnoreFlagPersistsThroughHopLookup");
setupRouting(new RoutingTableSpec(SimpleProtocol.NAME).addHop(new HopSpec("foo", "dst/unknown")));
assertSend("?foo");
assertTrace("Ignoring errors in reply.");
- log.log(Level.INFO, "Finished: requireThatIgnoreFlagPersistsThroughHopLookup");
}
@Test
void requireThatIgnoreFlagPersistsThroughRouteLookup() {
- log.log(Level.INFO, "Starting: requireThatIgnoreFlagPersistsThroughRouteLookup");
setupRouting(new RoutingTableSpec(SimpleProtocol.NAME).addRoute(new RouteSpec("foo").addHop("dst/unknown")));
assertSend("?foo");
assertTrace("Ignoring errors in reply.");
- log.log(Level.INFO, "Finished: requireThatIgnoreFlagPersistsThroughRouteLookup");
}
@Test
void requireThatIgnoreFlagPersistsThroughPolicySelect() {
- log.log(Level.INFO, "Starting: requireThatIgnoreFlagPersistsThroughPolicySelect");
setupPolicy("Custom", MyPolicy.newSelectAndMerge("dst/unknown"));
assertSend("?[Custom]");
assertTrace("Ignoring errors in reply.");
- log.log(Level.INFO, "Finished: requireThatIgnoreFlagPersistsThroughPolicySelect");
}
@Test
void requireThatIgnoreFlagIsSerializedWithMessage() {
- log.log(Level.INFO, "Starting: requireThatIgnoreFlagIsSerializedWithMessage");
assertSend(dstSessName + " foo ?bar");
Message msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60);
assertNotNull(msg);
@@ -747,114 +624,90 @@ public class RoutingTestCase {
assertTrue(hop.getIgnoreResult());
dstSession.acknowledge(msg);
assertTrace("-Ignoring errors in reply.");
- log.log(Level.INFO, "Finished: requireThatIgnoreFlagIsSerializedWithMessage");
}
@Test
void requireThatIgnoreFlagDoesNotInterfere() {
- log.log(Level.INFO, "Starting: requireThatIgnoreFlagDoesNotInterfere");
setupPolicy("Custom", MyPolicy.newSelectAndMerge(dstSessName));
assertSend("?[Custom]");
assertTrace("-Ignoring errors in reply.");
- log.log(Level.INFO, "Finished: requireThatIgnoreFlagDoesNotInterfere");
}
@Test
void requireThatEmptySelectionCanBeIgnored() {
- log.log(Level.INFO, "Starting: requireThatEmptySelectionCanBeIgnored");
setupPolicy("Custom", MyPolicy.newEmptySelection());
assertSend("?[Custom]");
assertTrace("Ignoring errors in reply.");
- log.log(Level.INFO, "Finished: requireThatEmptySelectionCanBeIgnored");
}
@Test
void requireThatSelectErrorCanBeIgnored() {
- log.log(Level.INFO, "Starting: requireThatSelectErrorCanBeIgnored");
setupPolicy("Custom", MyPolicy.newSelectError(ErrorCode.APP_FATAL_ERROR, "foo"));
assertSend("?[Custom]");
assertTrace("Ignoring errors in reply.");
- log.log(Level.INFO, "Finished: requireThatSelectErrorCanBeIgnored");
}
@Test
void requireThatSelectExceptionCanBeIgnored() {
- log.log(Level.INFO, "Starting: requireThatSelectExceptionCanBeIgnored");
setupPolicy("Custom", MyPolicy.newSelectException(new RuntimeException()));
assertSend("?[Custom]");
assertTrace("Ignoring errors in reply.");
- log.log(Level.INFO, "Finished: requireThatSelectExceptionCanBeIgnored");
}
@Test
void requireThatSelectAndThrowCanBeIgnored() {
- log.log(Level.INFO, "Starting: requireThatSelectAndThrowCanBeIgnored");
setupPolicy("Custom", MyPolicy.newSelectAndThrow(dstSessName, new RuntimeException()));
assertSend("?[Custom]");
assertTrace("Ignoring errors in reply.");
- log.log(Level.INFO, "Finished: requireThatSelectAndThrowCanBeIgnored");
}
@Test
void requireThatEmptyMergeCanBeIgnored() {
- log.log(Level.INFO, "Starting: requireThatEmptyMergeCanBeIgnored");
setupPolicy("Custom", MyPolicy.newEmptyMerge(dstSessName));
assertSend("?[Custom]");
assertAcknowledge();
assertTrace("Ignoring errors in reply.");
- log.log(Level.INFO, "Finished: requireThatEmptyMergeCanBeIgnored");
}
@Test
void requireThatMergeErrorCanBeIgnored() {
- log.log(Level.INFO, "Starting: requireThatMergeErrorCanBeIgnored");
setupPolicy("Custom", MyPolicy.newMergeError(dstSessName, ErrorCode.APP_FATAL_ERROR, "foo"));
assertSend("?[Custom]");
assertAcknowledge();
assertTrace("Ignoring errors in reply.");
- log.log(Level.INFO, "Finished: requireThatMergeErrorCanBeIgnored");
}
@Test
void requireThatMergeExceptionCanBeIgnored() {
- log.log(Level.INFO, "Starting: requireThatMergeExceptionCanBeIgnored");
setupPolicy("Custom", MyPolicy.newMergeException(dstSessName, new RuntimeException()));
assertSend("?[Custom]");
assertAcknowledge();
assertTrace("Ignoring errors in reply.");
- log.log(Level.INFO, "Finished: requireThatMergeExceptionCanBeIgnored");
}
@Test
void requireThatMergeAndThrowCanBeIgnored() {
- log.log(Level.INFO, "Starting: requireThatMergeAndThrowCanBeIgnored");
setupPolicy("Custom", MyPolicy.newMergeAndThrow(dstSessName, new RuntimeException()));
assertSend("?[Custom]");
assertAcknowledge();
assertTrace("Ignoring errors in reply.");
- log.log(Level.INFO, "Finished: requireThatMergeAndThrowCanBeIgnored");
}
@Test
void requireThatAllocServiceAddressCanBeIgnored() {
- log.log(Level.INFO, "Starting: requireThatAllocServiceAddressCanBeIgnored");
assertSend("?dst/unknown");
assertTrace("Ignoring errors in reply.");
- log.log(Level.INFO, "Finished: requireThatAllocServiceAddressCanBeIgnored");
}
@Test
void requireThatDepthLimitCanBeIgnored() {
- log.log(Level.INFO, "Starting: requireThatDepthLimitCanBeIgnored");
setupPolicy("Custom", MyPolicy.newSelectAndMerge("[Custom]"));
assertSend("?[Custom]");
assertTrace("Ignoring errors in reply.");
- log.log(Level.INFO, "Finished: requireThatDepthLimitCanBeIgnored");
}
@Test
void requireThatRouteCanBeEmptyInDestination() {
- log.log(Level.INFO, "Starting: requireThatRouteCanBeEmptyInDestination");
assertTrue(srcSession.send(createMessage("msg"), Route.parse(dstSessName)).isAccepted());
Message msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60);
assertNotNull(msg);
@@ -862,103 +715,77 @@ public class RoutingTestCase {
dstSession.acknowledge(msg);
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
- System.out.println(reply.getTrace());
- log.log(Level.INFO, "Finished: requireThatRouteCanBeEmptyInDestination");
}
@Test
void requireThatOnlyActiveNodesAreAborted() {
- log.log(Level.INFO, "Starting: requireThatOnlyActiveNodesAreAborted");
SimpleProtocol protocol = new SimpleProtocol();
protocol.addPolicyFactory("Custom", new CustomPolicyFactory(false));
- protocol.addPolicyFactory("SetReply", new SimpleProtocol.PolicyFactory() {
-
- @Override
- public RoutingPolicy create(String param) {
- return new SetReplyPolicy(false,
- Arrays.asList(ErrorCode.APP_TRANSIENT_ERROR,
- ErrorCode.APP_TRANSIENT_ERROR,
- ErrorCode.APP_FATAL_ERROR),
- param);
- }
- });
+ protocol.addPolicyFactory("SetReply", param -> new SetReplyPolicy(false,
+ Arrays.asList(ErrorCode.APP_TRANSIENT_ERROR,
+ ErrorCode.APP_TRANSIENT_ERROR,
+ ErrorCode.APP_FATAL_ERROR),
+ param));
srcServer.mb.putProtocol(protocol);
assertTrue(srcSession.send(createMessage("msg"),
Route.parse("[Custom:[SetReply:foo],?bar," + dstSessName + "]")).isAccepted());
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
- System.out.println(reply.getTrace());
assertEquals(2, reply.getNumErrors());
assertEquals(ErrorCode.APP_FATAL_ERROR, reply.getError(0).getCode());
assertEquals(ErrorCode.SEND_ABORTED, reply.getError(1).getCode());
- log.log(Level.INFO, "Finished: requireThatOnlyActiveNodesAreAborted");
}
@Test
void requireThatTimeoutWorks() {
- log.log(Level.INFO, "Starting: requireThatTimeoutWorks");
retryPolicy.setBaseDelay(0.01);
srcSession.setTimeout(0.5);
assertTrue(srcSession.send(createMessage("msg"), Route.parse("dst/unknown")).isAccepted());
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
- System.out.println(reply.getTrace());
assertEquals(2, reply.getNumErrors());
assertEquals(ErrorCode.NO_ADDRESS_FOR_SERVICE, reply.getError(0).getCode());
assertEquals(ErrorCode.TIMEOUT, reply.getError(1).getCode());
- log.log(Level.INFO, "Finished: requireThatTimeoutWorks");
}
@Test
void requireThatUnknownPolicyIsCaught() {
- log.log(Level.INFO, "Starting: requireThatUnknownPolicyIsCaught");
assertTrue(srcSession.send(createMessage("msg"), Route.parse("[Unknown]")).isAccepted());
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
- System.out.println(reply.getTrace());
assertEquals(1, reply.getNumErrors());
assertEquals(ErrorCode.UNKNOWN_POLICY, reply.getError(0).getCode());
- log.log(Level.INFO, "Finished: requireThatUnknownPolicyIsCaught");
}
private SimpleProtocol.PolicyFactory exceptionOnSelectThrowingMockFactory() {
- return new SimpleProtocol.PolicyFactory() {
+ return param -> new RoutingPolicy() {
@Override
- public RoutingPolicy create(String param) {
- return new RoutingPolicy() {
-
- @Override
- public void select(RoutingContext context) {
- throw new RuntimeException("69");
- }
+ public void select(RoutingContext context) {
+ throw new RuntimeException("69");
+ }
- @Override
- public void merge(RoutingContext context) {
- }
+ @Override
+ public void merge(RoutingContext context) {
+ }
- @Override
- public void destroy() {
- }
- };
+ @Override
+ public void destroy() {
}
};
}
@Test
void requireThatSelectExceptionIsCaught() {
- log.log(Level.INFO, "Starting: requireThatSelectExceptionIsCaught");
SimpleProtocol protocol = new SimpleProtocol();
protocol.addPolicyFactory("Custom", exceptionOnSelectThrowingMockFactory());
srcServer.mb.putProtocol(protocol);
assertTrue(srcSession.send(createMessage("msg"), Route.parse("[Custom]")).isAccepted());
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
- System.out.println(reply.getTrace());
assertEquals(1, reply.getNumErrors());
assertEquals(ErrorCode.POLICY_ERROR, reply.getError(0).getCode());
assertTrue(reply.getError(0).getMessage().contains("69"));
- log.log(Level.INFO, "Finished: requireThatSelectExceptionIsCaught");
}
@Test
@@ -977,29 +804,22 @@ public class RoutingTestCase {
@Test
void requireThatMergeExceptionIsCaught() {
- log.log(Level.INFO, "Starting: requireThatMergeExceptionIsCaught");
SimpleProtocol protocol = new SimpleProtocol();
- protocol.addPolicyFactory("Custom", new SimpleProtocol.PolicyFactory() {
+ protocol.addPolicyFactory("Custom", param -> new RoutingPolicy() {
@Override
- public RoutingPolicy create(String param) {
- return new RoutingPolicy() {
-
- @Override
- public void select(RoutingContext context) {
- context.addChild(Route.parse(dstSessName));
- }
+ public void select(RoutingContext context) {
+ context.addChild(Route.parse(dstSessName));
+ }
- @Override
- public void merge(RoutingContext context) {
- throw new RuntimeException("69");
- }
+ @Override
+ public void merge(RoutingContext context) {
+ throw new RuntimeException("69");
+ }
- @Override
- public void destroy() {
+ @Override
+ public void destroy() {
- }
- };
}
});
srcServer.mb.putProtocol(protocol);
@@ -1009,11 +829,9 @@ public class RoutingTestCase {
dstSession.acknowledge(msg);
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
- System.out.println(reply.getTrace());
assertEquals(1, reply.getNumErrors());
assertEquals(ErrorCode.POLICY_ERROR, reply.getError(0).getCode());
assertTrue(reply.getError(0).getMessage().contains("69"));
- log.log(Level.INFO, "Finished: requireThatMergeExceptionIsCaught");
}
////////////////////////////////////////////////////////////////////////////////
@@ -1051,7 +869,6 @@ public class RoutingTestCase {
private void assertTrace(String... expectedTrace) {
Reply reply = ((Receptor)srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
- System.out.println(reply.getTrace());
assertFalse(reply.hasErrors());
assertTrace(Arrays.asList(expectedTrace), reply.getTrace());
}
diff --git a/messagebus/src/test/java/com/yahoo/messagebus/test/QueueAdapterTestCase.java b/messagebus/src/test/java/com/yahoo/messagebus/test/QueueAdapterTestCase.java
index f23a4325d79..d94bd3110e3 100644
--- a/messagebus/src/test/java/com/yahoo/messagebus/test/QueueAdapterTestCase.java
+++ b/messagebus/src/test/java/com/yahoo/messagebus/test/QueueAdapterTestCase.java
@@ -105,4 +105,5 @@ public class QueueAdapterTestCase {
return 0;
}
}
+
}
diff --git a/messagebus/src/test/java/com/yahoo/messagebus/test/ReceptorTestCase.java b/messagebus/src/test/java/com/yahoo/messagebus/test/ReceptorTestCase.java
index 59a93df17ed..e4e87a9321e 100644
--- a/messagebus/src/test/java/com/yahoo/messagebus/test/ReceptorTestCase.java
+++ b/messagebus/src/test/java/com/yahoo/messagebus/test/ReceptorTestCase.java
@@ -140,4 +140,5 @@ public class ReceptorTestCase {
return 0;
}
}
+
}
diff --git a/messagebus/src/test/java/com/yahoo/messagebus/test/SimpleMessageTestCase.java b/messagebus/src/test/java/com/yahoo/messagebus/test/SimpleMessageTestCase.java
index 7e3d9e926b9..10a6ae06556 100644
--- a/messagebus/src/test/java/com/yahoo/messagebus/test/SimpleMessageTestCase.java
+++ b/messagebus/src/test/java/com/yahoo/messagebus/test/SimpleMessageTestCase.java
@@ -20,4 +20,5 @@ public class SimpleMessageTestCase {
msg.setValue("bar");
assertEquals("bar", msg.getValue());
}
+
}
diff --git a/messagebus/src/test/java/com/yahoo/messagebus/test/SimpleProtocolTestCase.java b/messagebus/src/test/java/com/yahoo/messagebus/test/SimpleProtocolTestCase.java
index a8406cd5d1f..d004637f01b 100644
--- a/messagebus/src/test/java/com/yahoo/messagebus/test/SimpleProtocolTestCase.java
+++ b/messagebus/src/test/java/com/yahoo/messagebus/test/SimpleProtocolTestCase.java
@@ -58,4 +58,5 @@ public class SimpleProtocolTestCase {
void requireThatUnknownBufferIsNotDecoded() {
assertNull(PROTOCOL.decode(VERSION, new byte[]{'U'}));
}
+
}
diff --git a/messagebus/src/test/java/com/yahoo/messagebus/test/SimpleReplyTestCase.java b/messagebus/src/test/java/com/yahoo/messagebus/test/SimpleReplyTestCase.java
index bbb72a6b637..247fc2236ea 100644
--- a/messagebus/src/test/java/com/yahoo/messagebus/test/SimpleReplyTestCase.java
+++ b/messagebus/src/test/java/com/yahoo/messagebus/test/SimpleReplyTestCase.java
@@ -19,4 +19,5 @@ public class SimpleReplyTestCase {
reply.setValue("bar");
assertEquals("bar", reply.getValue());
}
+
}