Unit test refactoring
- removed tests no longer useful now that all Intent objects are unique
- fixed intent object equality tests
- enabled several immutable base class tests
- renamed several Test....java classes to ...Test.Java to
match project best practices
Change-Id: Ic829d6d39556d2f63323f5e82f3807dba86c62ec
diff --git a/core/net/src/test/java/org/onlab/onos/net/intent/TestHostToHostIntent.java b/core/net/src/test/java/org/onlab/onos/net/intent/TestHostToHostIntent.java
deleted file mode 100644
index 11311a7f..0000000
--- a/core/net/src/test/java/org/onlab/onos/net/intent/TestHostToHostIntent.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright 2014 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onlab.onos.net.intent;
-
-import org.junit.Ignore;
-import org.junit.Test;
-import org.onlab.onos.core.ApplicationId;
-import org.onlab.onos.TestApplicationId;
-import org.onlab.onos.net.HostId;
-import org.onlab.onos.net.flow.TrafficSelector;
-import org.onlab.onos.net.flow.TrafficTreatment;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.not;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-import static org.onlab.onos.net.NetTestTools.hid;
-
-/**
- * Unit tests for the HostToHostIntent class.
- */
-public class TestHostToHostIntent {
-
- private static final ApplicationId APPID = new TestApplicationId("foo");
-
- private TrafficSelector selector = new IntentTestsMocks.MockSelector();
- private TrafficTreatment treatment = new IntentTestsMocks.MockTreatment();
-
- private HostToHostIntent makeHostToHost(HostId one, HostId two) {
- return new HostToHostIntent(APPID, one, two, selector, treatment);
- }
-
- /**
- * Tests the equals() method where two HostToHostIntents have references
- * to the same hosts. These should compare equal.
- */
- @Test @Ignore("Needs to be merged with other API test")
- public void testSameEquals() {
-
- HostId one = hid("00:00:00:00:00:01/-1");
- HostId two = hid("00:00:00:00:00:02/-1");
- HostToHostIntent i1 = makeHostToHost(one, two);
- HostToHostIntent i2 = makeHostToHost(one, two);
-
- assertThat(i1, is(equalTo(i2)));
- }
-
- /**
- * Tests the equals() method where two HostToHostIntents have references
- * to different Hosts. These should compare not equal.
- */
- @Test @Ignore("Needs to be merged with other API test")
- public void testSameEquals2() {
- HostId one = hid("00:00:00:00:00:01/-1");
- HostId two = hid("00:00:00:00:00:02/-1");
- HostToHostIntent i1 = makeHostToHost(one, two);
- HostToHostIntent i2 = makeHostToHost(two, one);
-
- assertThat(i1, is(equalTo(i2)));
- }
-
- /**
- * Tests that the hashCode() values for two equivalent HostToHostIntent
- * objects are the same.
- */
- @Test @Ignore("Needs to be merged with other API test")
- public void testHashCodeEquals() {
- HostId one = hid("00:00:00:00:00:01/-1");
- HostId two = hid("00:00:00:00:00:02/-1");
- HostToHostIntent i1 = makeHostToHost(one, two);
- HostToHostIntent i2 = makeHostToHost(one, two);
-
- assertThat(i1.hashCode(), is(equalTo(i2.hashCode())));
- }
-
- /**
- * Tests that the hashCode() values for two distinct LinkCollectionIntent
- * objects are different.
- */
- @Test @Ignore("Needs to be merged with other API test")
- public void testHashCodeEquals2() {
- HostId one = hid("00:00:00:00:00:01/-1");
- HostId two = hid("00:00:00:00:00:02/-1");
- HostToHostIntent i1 = makeHostToHost(one, two);
- HostToHostIntent i2 = makeHostToHost(two, one);
-
- assertThat(i1.hashCode(), is(equalTo(i2.hashCode())));
- }
-
- /**
- * Tests that the hashCode() values for two distinct LinkCollectionIntent
- * objects are different.
- */
- @Test @Ignore("Needs to be merged with other API test")
- public void testHashCodeDifferent() {
- HostId one = hid("00:00:00:00:00:01/-1");
- HostId two = hid("00:00:00:00:00:02/-1");
- HostId three = hid("00:00:00:00:00:32/-1");
- HostToHostIntent i1 = makeHostToHost(one, two);
- HostToHostIntent i2 = makeHostToHost(one, three);
-
- assertThat(i1.hashCode(), is(not(equalTo(i2.hashCode()))));
- }
-
- /**
- * Checks that the HostToHostIntent class is immutable.
- */
- @Test
- public void checkImmutability() {
- assertThatClassIsImmutable(HostToHostIntent.class);
- }
-}
diff --git a/core/net/src/test/java/org/onlab/onos/net/intent/TestLinkCollectionIntent.java b/core/net/src/test/java/org/onlab/onos/net/intent/TestLinkCollectionIntent.java
deleted file mode 100644
index d1a8a8d..0000000
--- a/core/net/src/test/java/org/onlab/onos/net/intent/TestLinkCollectionIntent.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright 2014 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onlab.onos.net.intent;
-
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.is;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-import static org.onlab.onos.net.NetTestTools.link;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.onlab.onos.core.ApplicationId;
-import org.onlab.onos.TestApplicationId;
-import org.onlab.onos.net.ConnectPoint;
-import org.onlab.onos.net.DeviceId;
-import org.onlab.onos.net.Link;
-import org.onlab.onos.net.PortNumber;
-import org.onlab.onos.net.flow.TrafficSelector;
-import org.onlab.onos.net.flow.TrafficTreatment;
-
-/**
- * Unit tests for the LinkCollectionIntent class.
- */
-public class TestLinkCollectionIntent {
-
- private static final ApplicationId APPID = new TestApplicationId("foo");
-
- private Link link1 = link("dev1", 1, "dev2", 2);
- private Link link2 = link("dev1", 1, "dev3", 2);
- private Link link3 = link("dev2", 1, "dev3", 2);
-
- private Set<Link> links1;
- private Set<Link> links2;
-
- private ConnectPoint egress1 = new ConnectPoint(DeviceId.deviceId("dev1"),
- PortNumber.portNumber(3));
- private ConnectPoint egress2 = new ConnectPoint(DeviceId.deviceId("dev2"),
- PortNumber.portNumber(3));
-
- private TrafficSelector selector = new IntentTestsMocks.MockSelector();
- private TrafficTreatment treatment = new IntentTestsMocks.MockTreatment();
-
- private LinkCollectionIntent makeLinkCollection(Set<Link> links,
- ConnectPoint egress) {
- return new LinkCollectionIntent(APPID, selector, treatment, links, egress);
- }
-
- @Before
- public void setup() {
- links1 = new HashSet<>();
- links2 = new HashSet<>();
- }
-
- /**
- * Tests the equals() method where two LinkCollectionIntents have references
- * to the same Links in different orders. These should compare equal.
- */
- @Test @Ignore("Needs to be merged with other API test")
- public void testSameEquals() {
- links1.add(link1);
- links1.add(link2);
- links1.add(link3);
-
- links2.add(link3);
- links2.add(link2);
- links2.add(link1);
-
- LinkCollectionIntent i1 = makeLinkCollection(links1, egress1);
- LinkCollectionIntent i2 = makeLinkCollection(links2, egress1);
-
- assertThat(i1, is(equalTo(i2)));
- }
-
- /**
- * Tests the equals() method where two LinkCollectionIntents have references
- * to different Links. These should compare not equal.
- */
- @Test @Ignore("Needs to be merged with other API test")
- public void testLinksDifferentEquals() {
- links1.add(link1);
- links1.add(link2);
-
- links2.add(link3);
- links2.add(link1);
-
- LinkCollectionIntent i1 = makeLinkCollection(links1, egress1);
- LinkCollectionIntent i2 = makeLinkCollection(links2, egress1);
-
- assertThat(i1, is(not(equalTo(i2))));
- }
-
- /**
- * Tests the equals() method where two LinkCollectionIntents have references
- * to the same Links but different egress points. These should compare not equal.
- */
- @Test @Ignore("Needs to be merged with other API test")
- public void testEgressDifferentEquals() {
- links1.add(link1);
- links1.add(link2);
- links1.add(link3);
-
- links2.add(link3);
- links2.add(link2);
- links2.add(link1);
-
- LinkCollectionIntent i1 = makeLinkCollection(links1, egress1);
- LinkCollectionIntent i2 = makeLinkCollection(links2, egress2);
-
- assertThat(i1, is(not(equalTo(i2))));
- }
-
- /**
- * Tests that the hashCode() values for two equivalent LinkCollectionIntent
- * objects are the same.
- */
- @Test @Ignore("Needs to be merged with other API test")
- public void testHashCodeEquals() {
- links1.add(link1);
- links1.add(link2);
- links1.add(link3);
-
- links2.add(link3);
- links2.add(link2);
- links2.add(link1);
-
- LinkCollectionIntent i1 = makeLinkCollection(links1, egress1);
- LinkCollectionIntent i2 = makeLinkCollection(links2, egress1);
-
- assertThat(i1.hashCode(), is(equalTo(i2.hashCode())));
- }
-
- /**
- * Tests that the hashCode() values for two distinct LinkCollectionIntent
- * objects are different.
- */
- @Test @Ignore("Needs to be merged with other API test")
- public void testHashCodeDifferent() {
- links1.add(link1);
- links1.add(link2);
-
- links2.add(link1);
- links2.add(link3);
-
- LinkCollectionIntent i1 = makeLinkCollection(links1, egress1);
- LinkCollectionIntent i2 = makeLinkCollection(links2, egress2);
-
- assertThat(i1.hashCode(), is(not(equalTo(i2.hashCode()))));
- }
-
- /**
- * Checks that the HostToHostIntent class is immutable.
- */
- @Test
- public void checkImmutability() {
- assertThatClassIsImmutable(LinkCollectionIntent.class);
- }
-}
diff --git a/core/net/src/test/java/org/onlab/onos/net/intent/TestMultiPointToSinglePointIntent.java b/core/net/src/test/java/org/onlab/onos/net/intent/TestMultiPointToSinglePointIntent.java
deleted file mode 100644
index b0c244b..0000000
--- a/core/net/src/test/java/org/onlab/onos/net/intent/TestMultiPointToSinglePointIntent.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright 2014 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onlab.onos.net.intent;
-
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.onlab.onos.core.ApplicationId;
-import org.onlab.onos.TestApplicationId;
-import org.onlab.onos.net.ConnectPoint;
-import org.onlab.onos.net.flow.TrafficSelector;
-import org.onlab.onos.net.flow.TrafficTreatment;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.is;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-import static org.onlab.onos.net.NetTestTools.connectPoint;
-
-/**
- * Unit tests for the MultiPointToSinglePointIntent class.
- */
-public class TestMultiPointToSinglePointIntent {
-
- private static final ApplicationId APPID = new TestApplicationId("foo");
-
- private ConnectPoint point1 = connectPoint("dev1", 1);
- private ConnectPoint point2 = connectPoint("dev2", 1);
- private ConnectPoint point3 = connectPoint("dev3", 1);
-
- private TrafficSelector selector = new IntentTestsMocks.MockSelector();
- private TrafficTreatment treatment = new IntentTestsMocks.MockTreatment();
-
- Set<ConnectPoint> ingress1;
- Set<ConnectPoint> ingress2;
-
- /**
- * Creates a MultiPointToSinglePointIntent object.
- *
- * @param ingress set of ingress points
- * @param egress egress point
- * @return MultiPointToSinglePoint intent
- */
- private MultiPointToSinglePointIntent makeIntent(Set<ConnectPoint> ingress,
- ConnectPoint egress) {
- return new MultiPointToSinglePointIntent(APPID, selector, treatment,
- ingress, egress);
- }
-
- /**
- * Initializes the ingress sets.
- */
- @Before
- public void setup() {
- ingress1 = new HashSet<>();
- ingress2 = new HashSet<>();
- }
-
- /**
- * Tests the equals() method where two MultiPointToSinglePoint have references
- * to the same Links in different orders. These should compare equal.
- */
- @Test @Ignore("Needs to be merged with other API test")
- public void testSameEquals() {
-
- Set<ConnectPoint> ingress1 = new HashSet<>();
- ingress1.add(point2);
- ingress1.add(point3);
-
- Set<ConnectPoint> ingress2 = new HashSet<>();
- ingress2.add(point3);
- ingress2.add(point2);
-
- Intent i1 = makeIntent(ingress1, point1);
- Intent i2 = makeIntent(ingress2, point1);
-
- assertThat(i1, is(equalTo(i2)));
- }
-
- /**
- * Tests the equals() method where two MultiPointToSinglePoint have references
- * to different Links. These should compare not equal.
- */
- @Test @Ignore("Needs to be merged with other API test")
- public void testLinksDifferentEquals() {
- ingress1.add(point3);
-
- ingress2.add(point3);
- ingress2.add(point2);
-
- Intent i1 = makeIntent(ingress1, point1);
- Intent i2 = makeIntent(ingress2, point1);
-
- assertThat(i1, is(not(equalTo(i2))));
- }
-
- /**
- * Tests that the hashCode() values for two equivalent MultiPointToSinglePoint
- * objects are the same.
- */
- @Test @Ignore("Needs to be merged with other API test")
- public void testHashCodeEquals() {
- ingress1.add(point2);
- ingress1.add(point3);
-
- ingress2.add(point3);
- ingress2.add(point2);
-
- Intent i1 = makeIntent(ingress1, point1);
- Intent i2 = makeIntent(ingress2, point1);
-
- assertThat(i1.hashCode(), is(equalTo(i2.hashCode())));
- }
-
- /**
- * Tests that the hashCode() values for two distinct MultiPointToSinglePoint
- * objects are different.
- */
- @Test @Ignore("Needs to be merged with other API test")
- public void testHashCodeDifferent() {
- ingress1.add(point2);
-
- ingress2.add(point3);
- ingress2.add(point2);
-
- Intent i1 = makeIntent(ingress1, point1);
- Intent i2 = makeIntent(ingress2, point1);
-
-
- assertThat(i1.hashCode(), is(not(equalTo(i2.hashCode()))));
- }
-
- /**
- * Checks that the MultiPointToSinglePointIntent class is immutable.
- */
- @Test
- public void checkImmutability() {
- assertThatClassIsImmutable(MultiPointToSinglePointIntent.class);
- }
-}
diff --git a/core/net/src/test/java/org/onlab/onos/net/intent/TestPointToPointIntent.java b/core/net/src/test/java/org/onlab/onos/net/intent/TestPointToPointIntent.java
deleted file mode 100644
index b1c30bd..0000000
--- a/core/net/src/test/java/org/onlab/onos/net/intent/TestPointToPointIntent.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright 2014 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onlab.onos.net.intent;
-
-import org.junit.Ignore;
-import org.junit.Test;
-import org.onlab.onos.core.ApplicationId;
-import org.onlab.onos.TestApplicationId;
-import org.onlab.onos.net.ConnectPoint;
-import org.onlab.onos.net.flow.TrafficSelector;
-import org.onlab.onos.net.flow.TrafficTreatment;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.*;
-import static org.onlab.onos.net.NetTestTools.connectPoint;
-
-/**
- * Unit tests for the HostToHostIntent class.
- */
-public class TestPointToPointIntent {
-
- private static final ApplicationId APPID = new TestApplicationId("foo");
-
- private TrafficSelector selector = new IntentTestsMocks.MockSelector();
- private TrafficTreatment treatment = new IntentTestsMocks.MockTreatment();
-
- private ConnectPoint point1 = connectPoint("dev1", 1);
- private ConnectPoint point2 = connectPoint("dev2", 1);
-
- private PointToPointIntent makePointToPoint(ConnectPoint ingress,
- ConnectPoint egress) {
- return new PointToPointIntent(APPID, selector, treatment, ingress, egress);
- }
-
- /**
- * Tests the equals() method where two PointToPointIntents have references
- * to the same ingress and egress points. These should compare equal.
- */
- @Test @Ignore("Needs to be merged with other API test")
- public void testSameEquals() {
- PointToPointIntent i1 = makePointToPoint(point1, point2);
- PointToPointIntent i2 = makePointToPoint(point1, point2);
-
- assertThat(i1, is(equalTo(i2)));
- }
-
- /**
- * Tests the equals() method where two HostToHostIntents have references
- * to different Hosts. These should compare not equal.
- */
- @Test @Ignore("Needs to be merged with other API test")
- public void testLinksDifferentEquals() {
- PointToPointIntent i1 = makePointToPoint(point1, point2);
- PointToPointIntent i2 = makePointToPoint(point2, point1);
-
- assertThat(i1, is(not(equalTo(i2))));
- }
-
- /**
- * Tests that the hashCode() values for two equivalent HostToHostIntent
- * objects are the same.
- */
- @Test @Ignore("Needs to be merged with other API test")
- public void testHashCodeEquals() {
- PointToPointIntent i1 = makePointToPoint(point1, point2);
- PointToPointIntent i2 = makePointToPoint(point1, point2);
-
- assertThat(i1.hashCode(), is(equalTo(i2.hashCode())));
- }
-
- /**
- * Tests that the hashCode() values for two distinct LinkCollectionIntent
- * objects are different.
- */
- @Test @Ignore("Needs to be merged with other API test")
- public void testHashCodeDifferent() {
- PointToPointIntent i1 = makePointToPoint(point1, point2);
- PointToPointIntent i2 = makePointToPoint(point2, point1);
-
- assertThat(i1.hashCode(), is(not(equalTo(i2.hashCode()))));
- }
-}
diff --git a/core/net/src/test/java/org/onlab/onos/net/intent/impl/TestHostToHostIntentCompiler.java b/core/net/src/test/java/org/onlab/onos/net/intent/impl/HostToHostIntentCompilerTest.java
similarity index 98%
rename from core/net/src/test/java/org/onlab/onos/net/intent/impl/TestHostToHostIntentCompiler.java
rename to core/net/src/test/java/org/onlab/onos/net/intent/impl/HostToHostIntentCompilerTest.java
index 1ed6032..07cf731 100644
--- a/core/net/src/test/java/org/onlab/onos/net/intent/impl/TestHostToHostIntentCompiler.java
+++ b/core/net/src/test/java/org/onlab/onos/net/intent/impl/HostToHostIntentCompilerTest.java
@@ -46,7 +46,7 @@
/**
* Unit tests for the HostToHost intent compiler.
*/
-public class TestHostToHostIntentCompiler extends AbstractIntentTest {
+public class HostToHostIntentCompilerTest extends AbstractIntentTest {
private static final String HOST_ONE_MAC = "00:00:00:00:00:01";
private static final String HOST_TWO_MAC = "00:00:00:00:00:02";
private static final String HOST_ONE_VLAN = "-1";
diff --git a/core/net/src/test/java/org/onlab/onos/net/intent/impl/TestMultiPointToSinglePointIntentCompiler.java b/core/net/src/test/java/org/onlab/onos/net/intent/impl/MultiPointToSinglePointIntentCompilerTest.java
similarity index 98%
rename from core/net/src/test/java/org/onlab/onos/net/intent/impl/TestMultiPointToSinglePointIntentCompiler.java
rename to core/net/src/test/java/org/onlab/onos/net/intent/impl/MultiPointToSinglePointIntentCompilerTest.java
index 3871de7..3727572 100644
--- a/core/net/src/test/java/org/onlab/onos/net/intent/impl/TestMultiPointToSinglePointIntentCompiler.java
+++ b/core/net/src/test/java/org/onlab/onos/net/intent/impl/MultiPointToSinglePointIntentCompilerTest.java
@@ -47,7 +47,7 @@
/**
* Unit tests for the MultiPointToSinglePoint intent compiler.
*/
-public class TestMultiPointToSinglePointIntentCompiler extends AbstractIntentTest {
+public class MultiPointToSinglePointIntentCompilerTest extends AbstractIntentTest {
private static final ApplicationId APPID = new TestApplicationId("foo");
diff --git a/core/net/src/test/java/org/onlab/onos/net/intent/impl/TestPointToPointIntentCompiler.java b/core/net/src/test/java/org/onlab/onos/net/intent/impl/PointToPointIntentCompilerTest.java
similarity index 98%
rename from core/net/src/test/java/org/onlab/onos/net/intent/impl/TestPointToPointIntentCompiler.java
rename to core/net/src/test/java/org/onlab/onos/net/intent/impl/PointToPointIntentCompilerTest.java
index 3070664..6d76820 100644
--- a/core/net/src/test/java/org/onlab/onos/net/intent/impl/TestPointToPointIntentCompiler.java
+++ b/core/net/src/test/java/org/onlab/onos/net/intent/impl/PointToPointIntentCompilerTest.java
@@ -47,7 +47,7 @@
/**
* Unit tests for the HostToHost intent compiler.
*/
-public class TestPointToPointIntentCompiler extends AbstractIntentTest {
+public class PointToPointIntentCompilerTest extends AbstractIntentTest {
private static final ApplicationId APPID = new TestApplicationId("foo");