From abc85404046ff4cce84b5e1854ab0b98dda45261 Mon Sep 17 00:00:00 2001 From: Alissa Bonas Date: Mon, 28 Oct 2013 16:58:44 +0200 Subject: [PATCH] Fix several tests to use correct junit methods Change-Id: I61c7eca9c448f50140fd206ee4665bd2d58c0b65 Signed-off-by: Alissa Bonas --- .../forwarding/staticrouting/StaticRouteTest.java | 12 +++++++----- .../internal/ForwardingRulesManagerIT.java | 3 ++- .../controller/topology/northbound/TopologyTest.java | 6 ++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/opendaylight/forwarding/staticrouting/src/test/java/org/opendaylight/controller/forwarding/staticrouting/StaticRouteTest.java b/opendaylight/forwarding/staticrouting/src/test/java/org/opendaylight/controller/forwarding/staticrouting/StaticRouteTest.java index 25b2dacde1..ee0e9dc878 100644 --- a/opendaylight/forwarding/staticrouting/src/test/java/org/opendaylight/controller/forwarding/staticrouting/StaticRouteTest.java +++ b/opendaylight/forwarding/staticrouting/src/test/java/org/opendaylight/controller/forwarding/staticrouting/StaticRouteTest.java @@ -22,6 +22,8 @@ import org.opendaylight.controller.sal.core.NodeConnector; import org.opendaylight.controller.sal.utils.NodeConnectorCreator; import org.opendaylight.controller.sal.utils.NodeCreator; +import static junit.framework.Assert.fail; + public class StaticRouteTest { @Test @@ -36,7 +38,7 @@ public class StaticRouteTest { nextHopAddress = InetAddress.getByName("200.0.0.1"); } catch (UnknownHostException e) { - Assert.assertTrue(false); + fail("Failed due to unknown host " + e.getMessage()); } staticRoute.setNetworkAddress(networkAddress); Assert.assertEquals(networkAddress.getHostAddress(), staticRoute.getNetworkAddress().getHostAddress()); @@ -57,12 +59,12 @@ public class StaticRouteTest { try { ip1 = InetAddress.getByName("192.1.1.1"); } catch (UnknownHostException e) { - Assert.assertTrue(false); + fail("Failed due to unknown host " + e.getMessage()); } try { h1 = new HostNodeConnector(ip1); } catch (ConstructionException e) { - Assert.assertTrue(false); + fail("Failed to construct host " + e.getMessage()); } staticRoute.setHost(h1); Assert.assertEquals(h1, staticRoute.getHost()); @@ -99,11 +101,11 @@ public class StaticRouteTest { ip1 = InetAddress.getByName("10.1.0.2"); ip2 = InetAddress.getByName("10.1.1.2"); } catch (UnknownHostException e) { - Assert.assertTrue(false); + fail("Test failed due to unknown host " + e.getMessage()); } InetAddress rxdIp1 = staticRoute1.longestPrefixMatch(ip1); InetAddress rxdIp2 = staticRoute1.longestPrefixMatch(ip2); - Assert.assertEquals(null, rxdIp1); + Assert.assertNull(rxdIp1); Assert.assertEquals("10.1.1.0", rxdIp2.getHostAddress()); } } diff --git a/opendaylight/forwardingrulesmanager/integrationtest/src/test/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManagerIT.java b/opendaylight/forwardingrulesmanager/integrationtest/src/test/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManagerIT.java index ef2e0fa01d..b35380b467 100644 --- a/opendaylight/forwardingrulesmanager/integrationtest/src/test/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManagerIT.java +++ b/opendaylight/forwardingrulesmanager/integrationtest/src/test/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManagerIT.java @@ -1,5 +1,6 @@ package org.opendaylight.controller.forwardingrulesmanager.internal; +import static junit.framework.Assert.fail; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.ops4j.pax.exam.CoreOptions.junitBundles; @@ -209,7 +210,7 @@ public class ForwardingRulesManagerIT { Assert.assertTrue(stat.getCode() == StatusCode.SUCCESS); } catch (ConstructionException e) { // Got a failure while allocating the node - Assert.assertTrue(false); + fail("Failed while allocating the node " + e.getMessage()); } } } diff --git a/opendaylight/northbound/topology/src/test/java/org/opendaylight/controller/topology/northbound/TopologyTest.java b/opendaylight/northbound/topology/src/test/java/org/opendaylight/controller/topology/northbound/TopologyTest.java index 1e5ea0f2c5..117b911f36 100644 --- a/opendaylight/northbound/topology/src/test/java/org/opendaylight/controller/topology/northbound/TopologyTest.java +++ b/opendaylight/northbound/topology/src/test/java/org/opendaylight/controller/topology/northbound/TopologyTest.java @@ -47,14 +47,12 @@ public class TopologyTest { try { e12 = new Edge(nc12, nc21); } catch (ConstructionException e) { - logger.error("",e); - assertTrue(false); + fail("Failed to construct edge " + e.getMessage()); } try { e23 = new Edge(nc23, nc32); } catch (ConstructionException e) { - logger.error("",e); - assertTrue(false); + fail("Failed to construct edge " + e.getMessage()); } Set props = new HashSet(); -- 2.36.6