X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fcds-access-api%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Faccess%2FABIVersionTest.java;h=1513f363969aa54331d7469c4b5ce228136139de;hb=HEAD;hp=6866136496d8764edc37472280a14b1ed77ea0a4;hpb=b19f8de136ff795078b3515af22fe5634d61d82c;p=controller.git diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/ABIVersionTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/ABIVersionTest.java index 6866136496..1513f36396 100644 --- a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/ABIVersionTest.java +++ b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/ABIVersionTest.java @@ -8,10 +8,12 @@ package org.opendaylight.controller.cluster.access; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; -import static org.opendaylight.controller.cluster.access.ABIVersion.BORON; +import static org.opendaylight.controller.cluster.access.ABIVersion.POTASSIUM; import static org.opendaylight.controller.cluster.access.ABIVersion.TEST_FUTURE_VERSION; import static org.opendaylight.controller.cluster.access.ABIVersion.TEST_PAST_VERSION; + import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteStreams; import java.io.IOException; @@ -21,25 +23,25 @@ public class ABIVersionTest { @Test public void testInvalidVersions() { assertTrue(TEST_PAST_VERSION.compareTo(TEST_FUTURE_VERSION) < 0); - assertTrue(TEST_PAST_VERSION.compareTo(BORON) < 0); - assertTrue(TEST_FUTURE_VERSION.compareTo(BORON) > 0); + assertTrue(TEST_PAST_VERSION.compareTo(POTASSIUM) < 0); + assertTrue(TEST_FUTURE_VERSION.compareTo(POTASSIUM) > 0); } @Test - public void testBoronVersion() throws Exception { - assertEquals((short)5, BORON.shortValue()); - assertEquals(BORON, ABIVersion.valueOf(BORON.shortValue())); - assertEquals(BORON, ABIVersion.readFrom(ByteStreams.newDataInput(writeVersion(BORON)))); + public void testMagnesiumVersion() throws Exception { + assertEquals((short)10, POTASSIUM.shortValue()); + assertEquals(POTASSIUM, ABIVersion.valueOf(POTASSIUM.shortValue())); + assertEquals(POTASSIUM, ABIVersion.readFrom(ByteStreams.newDataInput(writeVersion(POTASSIUM)))); } - @Test(expected=PastVersionException.class) - public void testInvalidPastVersion() throws Exception { - ABIVersion.valueOf(TEST_PAST_VERSION.shortValue()); + @Test + public void testInvalidPastVersion() { + assertThrows(PastVersionException.class, () -> ABIVersion.valueOf(TEST_PAST_VERSION.shortValue())); } - @Test(expected=FutureVersionException.class) - public void testInvalidFutureVersion() throws Exception { - ABIVersion.valueOf(TEST_FUTURE_VERSION.shortValue()); + @Test + public void testInvalidFutureVersion() { + assertThrows(FutureVersionException.class, () -> ABIVersion.valueOf(TEST_FUTURE_VERSION.shortValue())); } private static byte[] writeVersion(final ABIVersion version) { @@ -48,8 +50,9 @@ public class ABIVersionTest { return bado.toByteArray(); } - @Test(expected=IOException.class) - public void testBadRead() throws IOException { - ABIVersion.readFrom(ByteStreams.newDataInput(writeVersion(TEST_PAST_VERSION))); + @Test + public void testBadRead() { + final var in = ByteStreams.newDataInput(writeVersion(TEST_PAST_VERSION)); + assertThrows(IOException.class, () -> ABIVersion.readFrom(in)); } }