diff options
author | Jon Bratseth <bratseth@oath.com> | 2018-05-02 13:45:41 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@oath.com> | 2018-05-02 13:45:41 +0200 |
commit | e3bc9cc0aebd5dcdf36a347892cad044e1545dda (patch) | |
tree | 91a431e1aba779370ca31d6d5038e67f7c5f83dc /messagebus | |
parent | 2bd49571b52fd4502d6976fb4b5f82c31c2d24ef (diff) | |
parent | 5807a4cd298a2a09793f66096acdc9c7c62deebf (diff) |
Merge with master
Diffstat (limited to 'messagebus')
5 files changed, 50 insertions, 44 deletions
diff --git a/messagebus/src/test/java/com/yahoo/messagebus/SendProxyTestCase.java b/messagebus/src/test/java/com/yahoo/messagebus/SendProxyTestCase.java index fe9611b0a37..3e6d95c6c54 100644 --- a/messagebus/src/test/java/com/yahoo/messagebus/SendProxyTestCase.java +++ b/messagebus/src/test/java/com/yahoo/messagebus/SendProxyTestCase.java @@ -13,7 +13,6 @@ import com.yahoo.messagebus.test.Receptor; import com.yahoo.messagebus.test.SimpleMessage; import com.yahoo.messagebus.test.SimpleProtocol; import com.yahoo.messagebus.test.SimpleReply; -import junit.framework.TestCase; import org.junit.After; import org.junit.Before; import org.junit.Test; 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 a78b667a530..41cd0897f9e 100644 --- a/messagebus/src/test/java/com/yahoo/messagebus/routing/RetryPolicyTestCase.java +++ b/messagebus/src/test/java/com/yahoo/messagebus/routing/RetryPolicyTestCase.java @@ -2,13 +2,18 @@ package com.yahoo.messagebus.routing; import com.yahoo.messagebus.ErrorCode; -import junit.framework.TestCase; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; /** - * @author <a href="mailto:simon@yahoo-inc.com">Simon Thoresen</a> + * @author Simon Thoresen */ -public class RetryPolicyTestCase extends TestCase { +public class RetryPolicyTestCase { + @Test public void testSimpleRetryPolicy() { RetryTransientErrorsPolicy policy = new RetryTransientErrorsPolicy(); for (int i = 0; i < 5; ++i) { @@ -29,4 +34,5 @@ public class RetryPolicyTestCase extends TestCase { } } } + } 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 fde72ded150..c2e4aee1bd8 100755 --- a/messagebus/src/test/java/com/yahoo/messagebus/routing/RouteParserTestCase.java +++ b/messagebus/src/test/java/com/yahoo/messagebus/routing/RouteParserTestCase.java @@ -1,11 +1,18 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.messagebus.routing; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + /** - * @author <a href="mailto:simon@yahoo-inc.com">Simon Thoresen</a> + * @author Simon Thoresen */ -public class RouteParserTestCase extends junit.framework.TestCase { +public class RouteParserTestCase { + @Test public void testHopParser() { Hop hop = Hop.parse("foo"); assertNotNull(hop); @@ -64,6 +71,7 @@ public class RouteParserTestCase extends junit.framework.TestCase { "route[0].feed \"myfeed\""); } + @Test public void testHopParserErrors() { assertError(Hop.parse(""), "Failed to parse empty string."); assertError(Hop.parse("[foo"), "Unterminated '[' in '[foo'"); @@ -71,6 +79,7 @@ public class RouteParserTestCase extends junit.framework.TestCase { assertError(Hop.parse("foo bar"), "Failed to completely parse 'foo bar'."); } + @Test public void testShortRoute() { Route shortRoute = Route.parse("c"); assertNotNull(shortRoute); @@ -81,6 +90,7 @@ public class RouteParserTestCase extends junit.framework.TestCase { assertVerbatimDirective(hop.getDirective(0), "c"); } + @Test public void testShortHops() { Route shortRoute = Route.parse("a b c"); assertNotNull(shortRoute); @@ -91,6 +101,7 @@ public class RouteParserTestCase extends junit.framework.TestCase { assertVerbatimDirective(hop.getDirective(0), "a"); } + @Test public void testRouteParser() { Route route = Route.parse("foo bar/baz"); assertNotNull(route); @@ -114,6 +125,7 @@ public class RouteParserTestCase extends junit.framework.TestCase { assertVerbatimDirective(hop.getDirective(0), "default"); } + @Test public void testRouteParserErrors() { assertError(Route.parse(""), "Failed to parse empty string."); assertError(Route.parse("foo [bar"), "Unterminated '[' in '[bar'"); @@ -165,4 +177,5 @@ public class RouteParserTestCase extends junit.framework.TestCase { assertTrue(dir instanceof VerbatimDirective); assertEquals(image, ((VerbatimDirective)dir).getImage()); } + } 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 0c738db4242..527896e2b44 100755 --- a/messagebus/src/test/java/com/yahoo/messagebus/routing/RoutingContextTestCase.java +++ b/messagebus/src/test/java/com/yahoo/messagebus/routing/RoutingContextTestCase.java @@ -11,30 +11,27 @@ import com.yahoo.messagebus.network.rpc.test.TestServer; import com.yahoo.messagebus.test.Receptor; import com.yahoo.messagebus.test.SimpleMessage; import com.yahoo.messagebus.test.SimpleProtocol; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; -import java.net.UnknownHostException; import java.util.Arrays; import java.util.List; /** - * @author <a href="mailto:simon@yahoo-inc.com">Simon Thoresen</a> + * @author Simon Thoresen */ public class RoutingContextTestCase extends junit.framework.TestCase { - public static final int TIMEOUT_SECS = 120; - //////////////////////////////////////////////////////////////////////////////// - // - // Setup - // - //////////////////////////////////////////////////////////////////////////////// + public static final int TIMEOUT_SECS = 120; Slobrok slobrok; TestServer srcServer, dstServer; SourceSession srcSession; DestinationSession dstSession; - @Override - public void setUp() throws ListenFailedException, UnknownHostException { + @Before + public void setUp() throws ListenFailedException { slobrok = new Slobrok(); dstServer = new TestServer(new MessageBusParams().addProtocol(new SimpleProtocol()), new RPCNetworkParams().setIdentity(new Identity("dst")).setSlobrokConfigId(TestServer.getSlobrokConfig(slobrok))); @@ -46,7 +43,7 @@ public class RoutingContextTestCase extends junit.framework.TestCase { assertTrue(srcServer.waitSlobrok("dst/session", 1)); } - @Override + @After public void tearDown() { slobrok.stop(); dstSession.destroy(); @@ -55,12 +52,7 @@ public class RoutingContextTestCase extends junit.framework.TestCase { srcServer.destroy(); } - //////////////////////////////////////////////////////////////////////////////// - // - // Tests - // - //////////////////////////////////////////////////////////////////////////////// - + @Test public void testSingleDirective() { SimpleProtocol protocol = new SimpleProtocol(); protocol.addPolicyFactory("Custom", new CustomPolicyFactory( @@ -81,6 +73,7 @@ public class RoutingContextTestCase extends junit.framework.TestCase { } } + @Test public void testMoreDirectives() { SimpleProtocol protocol = new SimpleProtocol(); protocol.addPolicyFactory("Custom", new CustomPolicyFactory( @@ -103,6 +96,7 @@ public class RoutingContextTestCase extends junit.framework.TestCase { } } + @Test public void testRecipientsRemain() { SimpleProtocol protocol = new SimpleProtocol(); protocol.addPolicyFactory("First", new CustomPolicyFactory(true, Arrays.asList("foo/bar"), Arrays.asList("foo/[Second]"))); @@ -121,10 +115,12 @@ public class RoutingContextTestCase extends junit.framework.TestCase { } } + @Test public void testToString() { assertEquals("node : null, directive: 1, errors: [], selectOnRetry: true context: null", new RoutingContext(null, 1).toString()); } + @Test public void testConstRoute() { SimpleProtocol protocol = new SimpleProtocol(); protocol.addPolicyFactory("DocumentRouteSelector", @@ -146,12 +142,6 @@ public class RoutingContextTestCase extends junit.framework.TestCase { } } - //////////////////////////////////////////////////////////////////////////////// - // - // Utilities - // - //////////////////////////////////////////////////////////////////////////////// - private Message createMessage(String msg) { Message ret = new SimpleMessage(msg); ret.getTrace().setLevel(9); 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 8ebbe664d8d..e7ea6346999 100755 --- a/messagebus/src/test/java/com/yahoo/messagebus/routing/RoutingSpecTestCase.java +++ b/messagebus/src/test/java/com/yahoo/messagebus/routing/RoutingSpecTestCase.java @@ -3,24 +3,23 @@ package com.yahoo.messagebus.routing; import com.yahoo.messagebus.ConfigAgent; import com.yahoo.messagebus.ConfigHandler; -import junit.framework.TestCase; +import org.junit.Test; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + /** - * @author <a href="mailto:simon@yahoo-inc.com">Simon Thoresen</a> + * @author Simon Thoresen */ -public class RoutingSpecTestCase extends TestCase { - - //////////////////////////////////////////////////////////////////////////////// - // - // Tests - // - //////////////////////////////////////////////////////////////////////////////// +public class RoutingSpecTestCase { + @Test public void testConfig() { assertConfig(new RoutingSpec()); assertConfig(new RoutingSpec().addTable(new RoutingTableSpec("mytable1"))); @@ -71,6 +70,7 @@ public class RoutingSpecTestCase extends TestCase { .addRoute(new RouteSpec("myroute1").addHop("myhop1"))).toString()); } + @Test public void testApplicationSpec() { assertApplicationSpec(Arrays.asList("foo"), Arrays.asList("foo", @@ -101,6 +101,7 @@ public class RoutingSpecTestCase extends TestCase { "*/*/*")); } + @Test public void testVeriyfOk() { assertVerifyOk(new RoutingSpec().addTable(new RoutingTableSpec("mytable") .addHop(new HopSpec("hop1", "myservice1"))), @@ -125,6 +126,7 @@ public class RoutingSpecTestCase extends TestCase { .addService("mytable", "foo/1/baz")); } + @Test public void testVerifyToggle() { assertVerifyOk(new RoutingSpec(false) .addTable(new RoutingTableSpec("mytable")) @@ -142,6 +144,7 @@ public class RoutingSpecTestCase extends TestCase { new ApplicationSpec()); } + @Test public void testVerifyFail() { // Duplicate table. assertVerifyFail(new RoutingSpec() @@ -274,12 +277,6 @@ public class RoutingSpecTestCase extends TestCase { "Selector 'bar/[baz]/cox' does not match recipient 'cox/0/bar' in hop 'hop5' in routing table 'mytable'.")); } - //////////////////////////////////////////////////////////////////////////////// - // - // Utilities - // - //////////////////////////////////////////////////////////////////////////////// - private static void assertVerifyOk(RoutingSpec routing, ApplicationSpec app) { assertVerifyFail(routing, app, new ArrayList<String>()); } @@ -333,4 +330,5 @@ public class RoutingSpecTestCase extends TestCase { this.routing = routing; } } + } |