diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2021-07-01 15:07:40 +0200 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2021-07-01 15:07:40 +0200 |
commit | 3138bdecb6450cc3536ca6b148de257f07644a54 (patch) | |
tree | b23b42edbbbb3acfd7cfe0c14fd97b2e2a1f79ad /container-messagebus/src/test | |
parent | 9ceacdab281de851c841d395b1e1fd42c25d4f18 (diff) |
Use injected config in SessionCache
Diffstat (limited to 'container-messagebus/src/test')
6 files changed, 37 insertions, 25 deletions
diff --git a/container-messagebus/src/test/java/com/yahoo/container/jdisc/messagebus/MbusClientProviderTest.java b/container-messagebus/src/test/java/com/yahoo/container/jdisc/messagebus/MbusClientProviderTest.java index 6335cf01d8c..9512c1a4873 100644 --- a/container-messagebus/src/test/java/com/yahoo/container/jdisc/messagebus/MbusClientProviderTest.java +++ b/container-messagebus/src/test/java/com/yahoo/container/jdisc/messagebus/MbusClientProviderTest.java @@ -1,9 +1,16 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.container.jdisc.messagebus; +import com.yahoo.cloud.config.SlobroksConfig; +import com.yahoo.container.jdisc.ContainerMbusConfig; import com.yahoo.container.jdisc.config.SessionConfig; import com.yahoo.container.jdisc.messagebus.MbusClientProvider; import com.yahoo.container.jdisc.messagebus.SessionCache; +import com.yahoo.document.config.DocumentmanagerConfig; +import com.yahoo.documentapi.messagebus.protocol.DocumentProtocolPoliciesConfig; +import com.yahoo.messagebus.MessagebusConfig; +import com.yahoo.vespa.config.content.DistributionConfig; +import com.yahoo.vespa.config.content.LoadTypeConfig; import org.junit.Test; import static org.junit.Assert.assertNotNull; @@ -30,7 +37,15 @@ public class MbusClientProviderTest { } private void testClient(SessionConfig config) { - MbusClientProvider p = new MbusClientProvider(new SessionCache("dir:src/test/resources/config/clientprovider"), config); + SessionCache cache = new SessionCache(new ContainerMbusConfig.Builder().build(), + new DocumentmanagerConfig.Builder().build(), + new LoadTypeConfig.Builder().build(), + new SlobroksConfig.Builder().build(), + new MessagebusConfig.Builder().build(), + new DocumentProtocolPoliciesConfig.Builder().build(), + new DistributionConfig.Builder().build(), + "test"); + MbusClientProvider p = new MbusClientProvider(cache, config); assertNotNull(p.get()); p.deconstruct(); } diff --git a/container-messagebus/src/test/java/com/yahoo/messagebus/jdisc/test/ClientTestDriverTestCase.java b/container-messagebus/src/test/java/com/yahoo/messagebus/jdisc/test/ClientTestDriverTestCase.java index ef290a070cb..d24acb9d0d8 100644 --- a/container-messagebus/src/test/java/com/yahoo/messagebus/jdisc/test/ClientTestDriverTestCase.java +++ b/container-messagebus/src/test/java/com/yahoo/messagebus/jdisc/test/ClientTestDriverTestCase.java @@ -23,10 +23,6 @@ public class ClientTestDriverTestCase { driver = ClientTestDriver.newInstanceWithProtocol(new SimpleProtocol()); assertNotNull(driver); assertTrue(driver.close()); - - Slobrok slobrok = new Slobrok(); - driver = ClientTestDriver.newInstanceWithExternSlobrok(slobrok.configId()); - assertNotNull(driver); - assertTrue(driver.close()); } + } diff --git a/container-messagebus/src/test/java/com/yahoo/messagebus/jdisc/test/ServerTestDriverTestCase.java b/container-messagebus/src/test/java/com/yahoo/messagebus/jdisc/test/ServerTestDriverTestCase.java index f6ae2335d12..7b2c1b68549 100644 --- a/container-messagebus/src/test/java/com/yahoo/messagebus/jdisc/test/ServerTestDriverTestCase.java +++ b/container-messagebus/src/test/java/com/yahoo/messagebus/jdisc/test/ServerTestDriverTestCase.java @@ -24,11 +24,6 @@ public class ServerTestDriverTestCase { driver = ServerTestDriver.newInstanceWithProtocol(new SimpleProtocol(), new NonWorkingRequestHandler(), false); assertNotNull(driver); assertTrue(driver.close()); - - Slobrok slobrok = new Slobrok(); - driver = ServerTestDriver.newInstanceWithExternSlobrok(slobrok.configId(), new NonWorkingRequestHandler(), false); - assertNotNull(driver); - assertTrue(driver.close()); } } diff --git a/container-messagebus/src/test/java/com/yahoo/messagebus/shared/SharedDestinationSessionTestCase.java b/container-messagebus/src/test/java/com/yahoo/messagebus/shared/SharedDestinationSessionTestCase.java index 78e79da4b9f..759509946ce 100644 --- a/container-messagebus/src/test/java/com/yahoo/messagebus/shared/SharedDestinationSessionTestCase.java +++ b/container-messagebus/src/test/java/com/yahoo/messagebus/shared/SharedDestinationSessionTestCase.java @@ -1,12 +1,14 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.messagebus.shared; +import com.yahoo.cloud.config.SlobroksConfig; import com.yahoo.jrt.ListenFailedException; import com.yahoo.jrt.slobrok.server.Slobrok; import com.yahoo.messagebus.*; import com.yahoo.messagebus.jdisc.test.MessageQueue; import com.yahoo.messagebus.jdisc.test.RemoteClient; import com.yahoo.messagebus.jdisc.test.ReplyQueue; +import com.yahoo.messagebus.jdisc.test.TestUtils; import com.yahoo.messagebus.network.rpc.RPCNetworkParams; import com.yahoo.messagebus.routing.Route; import com.yahoo.messagebus.test.SimpleMessage; @@ -98,7 +100,7 @@ public class SharedDestinationSessionTestCase { RemoteClient client = RemoteClient.newInstanceWithInternSlobrok(true); MessageQueue queue = new MessageQueue(); DestinationSessionParams params = new DestinationSessionParams().setMessageHandler(queue); - SharedDestinationSession session = newDestinationSession(client.slobrokId(), params); + SharedDestinationSession session = newDestinationSession(client.slobroksConfig(), params); Route route = Route.parse(session.connectionSpec()); assertTrue(client.sendMessage(new SimpleMessage("foo").setRoute(route)).isAccepted()); @@ -120,11 +122,11 @@ public class SharedDestinationSessionTestCase { } catch (ListenFailedException e) { fail(); } - return newDestinationSession(slobrok.configId(), new DestinationSessionParams()); + return newDestinationSession(TestUtils.configFor(slobrok), new DestinationSessionParams()); } - private static SharedDestinationSession newDestinationSession(String slobrokId, DestinationSessionParams params) { - RPCNetworkParams netParams = new RPCNetworkParams().setSlobrokConfigId(slobrokId); + private static SharedDestinationSession newDestinationSession(SlobroksConfig slobroksConfig, DestinationSessionParams params) { + RPCNetworkParams netParams = new RPCNetworkParams().setSlobroksConfig(slobroksConfig); MessageBusParams mbusParams = new MessageBusParams().addProtocol(new SimpleProtocol()); SharedMessageBus mbus = SharedMessageBus.newInstance(mbusParams, netParams); SharedDestinationSession session = mbus.newDestinationSession(params); diff --git a/container-messagebus/src/test/java/com/yahoo/messagebus/shared/SharedIntermediateSessionTestCase.java b/container-messagebus/src/test/java/com/yahoo/messagebus/shared/SharedIntermediateSessionTestCase.java index 87958415149..ca8301d1ea9 100644 --- a/container-messagebus/src/test/java/com/yahoo/messagebus/shared/SharedIntermediateSessionTestCase.java +++ b/container-messagebus/src/test/java/com/yahoo/messagebus/shared/SharedIntermediateSessionTestCase.java @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.messagebus.shared; +import com.yahoo.cloud.config.SlobroksConfig; import com.yahoo.jrt.ListenFailedException; import com.yahoo.jrt.slobrok.server.Slobrok; import com.yahoo.messagebus.*; @@ -8,6 +9,7 @@ import com.yahoo.messagebus.jdisc.test.MessageQueue; import com.yahoo.messagebus.jdisc.test.RemoteClient; import com.yahoo.messagebus.jdisc.test.RemoteServer; import com.yahoo.messagebus.jdisc.test.ReplyQueue; +import com.yahoo.messagebus.jdisc.test.TestUtils; import com.yahoo.messagebus.network.local.LocalNetwork; import com.yahoo.messagebus.network.local.LocalWire; import com.yahoo.messagebus.network.rpc.RPCNetworkParams; @@ -77,7 +79,7 @@ public class SharedIntermediateSessionTestCase { public void requireThatReplyHandlerCanNotBeSet() throws ListenFailedException { Slobrok slobrok = new Slobrok(); try { - newIntermediateSession(slobrok.configId(), + newIntermediateSession(TestUtils.configFor(slobrok), new IntermediateSessionParams().setReplyHandler(new ReplyQueue()), false); fail(); @@ -111,7 +113,7 @@ public class SharedIntermediateSessionTestCase { @Test public void requireThatSessionCanSendMessage() throws InterruptedException { RemoteServer server = RemoteServer.newInstanceWithInternSlobrok(); - SharedIntermediateSession session = newIntermediateSession(server.slobrokId(), + SharedIntermediateSession session = newIntermediateSession(server.slobroksConfig(), new IntermediateSessionParams(), true); ReplyQueue queue = new ReplyQueue(); @@ -134,7 +136,7 @@ public class SharedIntermediateSessionTestCase { RemoteClient client = RemoteClient.newInstanceWithInternSlobrok(true); MessageQueue queue = new MessageQueue(); IntermediateSessionParams params = new IntermediateSessionParams().setMessageHandler(queue); - SharedIntermediateSession session = newIntermediateSession(client.slobrokId(), params, true); + SharedIntermediateSession session = newIntermediateSession(client.slobroksConfig(), params, true); Route route = Route.parse(session.connectionSpec()); assertTrue(client.sendMessage(new SimpleMessage("foo").setRoute(route)).isAccepted()); @@ -156,13 +158,13 @@ public class SharedIntermediateSessionTestCase { } catch (ListenFailedException e) { fail(); } - return newIntermediateSession(slobrok.configId(), new IntermediateSessionParams(), network); + return newIntermediateSession(TestUtils.configFor(slobrok), new IntermediateSessionParams(), network); } - private static SharedIntermediateSession newIntermediateSession(String slobrokId, + private static SharedIntermediateSession newIntermediateSession(SlobroksConfig slobroksConfig, IntermediateSessionParams params, boolean network) { - RPCNetworkParams netParams = new RPCNetworkParams().setSlobrokConfigId(slobrokId); + RPCNetworkParams netParams = new RPCNetworkParams().setSlobroksConfig(slobroksConfig); MessageBusParams mbusParams = new MessageBusParams().addProtocol(new SimpleProtocol()); SharedMessageBus mbus = network ? SharedMessageBus.newInstance(mbusParams, netParams) diff --git a/container-messagebus/src/test/java/com/yahoo/messagebus/shared/SharedSourceSessionTestCase.java b/container-messagebus/src/test/java/com/yahoo/messagebus/shared/SharedSourceSessionTestCase.java index 1f0966fc961..7a4a3d17170 100644 --- a/container-messagebus/src/test/java/com/yahoo/messagebus/shared/SharedSourceSessionTestCase.java +++ b/container-messagebus/src/test/java/com/yahoo/messagebus/shared/SharedSourceSessionTestCase.java @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.messagebus.shared; +import com.yahoo.cloud.config.SlobroksConfig; import com.yahoo.jrt.ListenFailedException; import com.yahoo.jrt.slobrok.server.Slobrok; import com.yahoo.messagebus.Message; @@ -8,6 +9,7 @@ import com.yahoo.messagebus.MessageBusParams; import com.yahoo.messagebus.SourceSessionParams; import com.yahoo.messagebus.jdisc.test.RemoteServer; import com.yahoo.messagebus.jdisc.test.ReplyQueue; +import com.yahoo.messagebus.jdisc.test.TestUtils; import com.yahoo.messagebus.network.rpc.RPCNetworkParams; import com.yahoo.messagebus.routing.Route; import com.yahoo.messagebus.test.SimpleMessage; @@ -59,7 +61,7 @@ public class SharedSourceSessionTestCase { @Test public void requireThatSessionCanSendMessage() throws InterruptedException { RemoteServer server = RemoteServer.newInstanceWithInternSlobrok(); - SharedSourceSession session = newSourceSession(server.slobrokId(), + SharedSourceSession session = newSourceSession(server.slobroksConfig(), new SourceSessionParams()); ReplyQueue queue = new ReplyQueue(); Message msg = new SimpleMessage("foo").setRoute(Route.parse(server.connectionSpec())); @@ -80,11 +82,11 @@ public class SharedSourceSessionTestCase { } catch (ListenFailedException e) { fail(); } - return newSourceSession(slobrok.configId(), params); + return newSourceSession(TestUtils.configFor(slobrok), params); } - private static SharedSourceSession newSourceSession(String slobrokId, SourceSessionParams params) { - RPCNetworkParams netParams = new RPCNetworkParams().setSlobrokConfigId(slobrokId); + private static SharedSourceSession newSourceSession(SlobroksConfig slobroksConfig, SourceSessionParams params) { + RPCNetworkParams netParams = new RPCNetworkParams().setSlobroksConfig(slobroksConfig); MessageBusParams mbusParams = new MessageBusParams().addProtocol(new SimpleProtocol()); SharedMessageBus mbus = SharedMessageBus.newInstance(mbusParams, netParams); SharedSourceSession session = mbus.newSourceSession(params); |