Ray Milkey

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
...@@ -15,13 +15,17 @@ ...@@ -15,13 +15,17 @@
15 */ 15 */
16 package org.onlab.onos.net.intent; 16 package org.onlab.onos.net.intent;
17 17
18 -import org.junit.Ignore;
19 import org.junit.Test; 18 import org.junit.Test;
19 +import org.onlab.onos.TestApplicationId;
20 +import org.onlab.onos.core.ApplicationId;
20 import org.onlab.onos.net.HostId; 21 import org.onlab.onos.net.HostId;
21 import org.onlab.onos.net.flow.TrafficSelector; 22 import org.onlab.onos.net.flow.TrafficSelector;
22 23
23 import com.google.common.testing.EqualsTester; 24 import com.google.common.testing.EqualsTester;
24 25
26 +import static org.hamcrest.MatcherAssert.assertThat;
27 +import static org.hamcrest.Matchers.equalTo;
28 +import static org.hamcrest.Matchers.is;
25 import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; 29 import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
26 import static org.onlab.onos.net.NetTestTools.APP_ID; 30 import static org.onlab.onos.net.NetTestTools.APP_ID;
27 import static org.onlab.onos.net.NetTestTools.hid; 31 import static org.onlab.onos.net.NetTestTools.hid;
...@@ -36,6 +40,28 @@ public class HostToHostIntentTest extends IntentTest { ...@@ -36,6 +40,28 @@ public class HostToHostIntentTest extends IntentTest {
36 private final HostId id2 = hid("12:34:56:78:92:ab/1"); 40 private final HostId id2 = hid("12:34:56:78:92:ab/1");
37 private final HostId id3 = hid("12:34:56:78:93:ab/1"); 41 private final HostId id3 = hid("12:34:56:78:93:ab/1");
38 42
43 + private static final ApplicationId APPID = new TestApplicationId("foo");
44 +
45 + private HostToHostIntent makeHostToHost(HostId one, HostId two) {
46 + return new HostToHostIntent(APPID, one, two, selector, treatment);
47 + }
48 +
49 + /**
50 + * Tests the equals() method where two HostToHostIntents have references
51 + * to the same hosts. These should compare equal.
52 + */
53 + @Test
54 + public void testSameEquals() {
55 +
56 + HostId one = hid("00:00:00:00:00:01/-1");
57 + HostId two = hid("00:00:00:00:00:02/-1");
58 + HostToHostIntent i1 = makeHostToHost(one, two);
59 + HostToHostIntent i2 = makeHostToHost(one, two);
60 +
61 + assertThat(i1.one(), is(equalTo(i2.one())));
62 + assertThat(i1.two(), is(equalTo(i2.two())));
63 + }
64 +
39 /** 65 /**
40 * Checks that the HostToHostIntent class is immutable. 66 * Checks that the HostToHostIntent class is immutable.
41 */ 67 */
...@@ -47,18 +73,14 @@ public class HostToHostIntentTest extends IntentTest { ...@@ -47,18 +73,14 @@ public class HostToHostIntentTest extends IntentTest {
47 /** 73 /**
48 * Tests equals(), hashCode() and toString() methods. 74 * Tests equals(), hashCode() and toString() methods.
49 */ 75 */
50 - @Test @Ignore("Equality is based on ids, which will be different") 76 + @Test
51 public void testEquals() { 77 public void testEquals() {
52 final HostToHostIntent intent1 = new HostToHostIntent(APP_ID, 78 final HostToHostIntent intent1 = new HostToHostIntent(APP_ID,
53 id1, 79 id1,
54 id2, 80 id2,
55 selector, 81 selector,
56 treatment); 82 treatment);
57 - final HostToHostIntent sameAsIntent1 = new HostToHostIntent(APP_ID, 83 +
58 - id1,
59 - id2,
60 - selector,
61 - treatment);
62 final HostToHostIntent intent2 = new HostToHostIntent(APP_ID, 84 final HostToHostIntent intent2 = new HostToHostIntent(APP_ID,
63 id2, 85 id2,
64 id3, 86 id3,
...@@ -66,7 +88,7 @@ public class HostToHostIntentTest extends IntentTest { ...@@ -66,7 +88,7 @@ public class HostToHostIntentTest extends IntentTest {
66 treatment); 88 treatment);
67 89
68 new EqualsTester() 90 new EqualsTester()
69 - .addEqualityGroup(intent1, sameAsIntent1) 91 + .addEqualityGroup(intent1)
70 .addEqualityGroup(intent2) 92 .addEqualityGroup(intent2)
71 .testEquals(); 93 .testEquals();
72 } 94 }
......
...@@ -15,15 +15,10 @@ ...@@ -15,15 +15,10 @@
15 */ 15 */
16 package org.onlab.onos.net.intent; 16 package org.onlab.onos.net.intent;
17 17
18 -import org.junit.Ignore;
19 -import org.junit.Test;
20 -
21 import java.util.Arrays; 18 import java.util.Arrays;
22 import java.util.HashSet; 19 import java.util.HashSet;
23 import java.util.Set; 20 import java.util.Set;
24 21
25 -import static org.junit.Assert.*;
26 -
27 /** 22 /**
28 * Base facilities to test various intent tests. 23 * Base facilities to test various intent tests.
29 */ 24 */
...@@ -39,24 +34,6 @@ public abstract class IntentTest extends AbstractIntentTest { ...@@ -39,24 +34,6 @@ public abstract class IntentTest extends AbstractIntentTest {
39 return new HashSet<>(Arrays.asList(items)); 34 return new HashSet<>(Arrays.asList(items));
40 } 35 }
41 36
42 - @Test @Ignore("Equality is based on ids, which will be different")
43 - public void equalsAndHashCode() {
44 - Intent one = createOne();
45 - Intent like = createOne();
46 - Intent another = createAnother();
47 -
48 - assertTrue("should be equal", one.equals(like));
49 - assertEquals("incorrect hashCode", one.hashCode(), like.hashCode());
50 - assertFalse("should not be equal", one.equals(another));
51 - }
52 -
53 - //@Test FIXME
54 - public void testToString() {
55 - Intent one = createOne();
56 - Intent like = createOne();
57 - assertEquals("incorrect toString", one.toString(), like.toString());
58 - }
59 -
60 /** 37 /**
61 * Creates a new intent, but always a like intent, i.e. all instances will 38 * Creates a new intent, but always a like intent, i.e. all instances will
62 * be equal, but should not be the same. 39 * be equal, but should not be the same.
......
...@@ -20,7 +20,6 @@ import java.util.LinkedList; ...@@ -20,7 +20,6 @@ import java.util.LinkedList;
20 import java.util.List; 20 import java.util.List;
21 import java.util.Set; 21 import java.util.Set;
22 22
23 -import org.junit.Ignore;
24 import org.junit.Test; 23 import org.junit.Test;
25 import org.onlab.onos.net.ConnectPoint; 24 import org.onlab.onos.net.ConnectPoint;
26 import org.onlab.onos.net.Link; 25 import org.onlab.onos.net.Link;
...@@ -61,7 +60,7 @@ public class LinkCollectionIntentTest extends IntentTest { ...@@ -61,7 +60,7 @@ public class LinkCollectionIntentTest extends IntentTest {
61 /** 60 /**
62 * Tests equals(), hashCode() and toString() methods. 61 * Tests equals(), hashCode() and toString() methods.
63 */ 62 */
64 - @Test @Ignore("Equality is based on ids, which will be different") 63 + @Test
65 public void testEquals() { 64 public void testEquals() {
66 65
67 final HashSet<Link> links1 = new HashSet<>(); 66 final HashSet<Link> links1 = new HashSet<>();
...@@ -72,12 +71,6 @@ public class LinkCollectionIntentTest extends IntentTest { ...@@ -72,12 +71,6 @@ public class LinkCollectionIntentTest extends IntentTest {
72 treatment, 71 treatment,
73 links1, 72 links1,
74 egress); 73 egress);
75 - final LinkCollectionIntent sameAsCollectionIntent1 =
76 - new LinkCollectionIntent(APP_ID,
77 - selector,
78 - treatment,
79 - links1,
80 - egress);
81 74
82 final HashSet<Link> links2 = new HashSet<>(); 75 final HashSet<Link> links2 = new HashSet<>();
83 links2.add(link("src", 1, "dst", 3)); 76 links2.add(link("src", 1, "dst", 3));
...@@ -89,7 +82,7 @@ public class LinkCollectionIntentTest extends IntentTest { ...@@ -89,7 +82,7 @@ public class LinkCollectionIntentTest extends IntentTest {
89 egress); 82 egress);
90 83
91 new EqualsTester() 84 new EqualsTester()
92 - .addEqualityGroup(collectionIntent1, sameAsCollectionIntent1) 85 + .addEqualityGroup(collectionIntent1)
93 .addEqualityGroup(collectionIntent2) 86 .addEqualityGroup(collectionIntent2)
94 .testEquals(); 87 .testEquals();
95 } 88 }
......
...@@ -18,12 +18,21 @@ package org.onlab.onos.net.intent; ...@@ -18,12 +18,21 @@ package org.onlab.onos.net.intent;
18 import org.junit.Test; 18 import org.junit.Test;
19 19
20 import static org.junit.Assert.assertEquals; 20 import static org.junit.Assert.assertEquals;
21 +import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
21 22
22 /** 23 /**
23 * Suite of tests of the multi-to-single point intent descriptor. 24 * Suite of tests of the multi-to-single point intent descriptor.
24 */ 25 */
25 public class MultiPointToSinglePointIntentTest extends ConnectivityIntentTest { 26 public class MultiPointToSinglePointIntentTest extends ConnectivityIntentTest {
26 27
28 + /**
29 + * Checks that the MultiPointToSinglePointIntent class is immutable.
30 + */
31 + @Test
32 + public void checkImmutability() {
33 + assertThatClassIsImmutable(MultiPointToSinglePointIntent.class);
34 + }
35 +
27 @Test 36 @Test
28 public void basics() { 37 public void basics() {
29 MultiPointToSinglePointIntent intent = createOne(); 38 MultiPointToSinglePointIntent intent = createOne();
......
...@@ -18,12 +18,21 @@ package org.onlab.onos.net.intent; ...@@ -18,12 +18,21 @@ package org.onlab.onos.net.intent;
18 import org.junit.Test; 18 import org.junit.Test;
19 19
20 import static org.junit.Assert.assertEquals; 20 import static org.junit.Assert.assertEquals;
21 +import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutableBaseClass;
21 22
22 /** 23 /**
23 * Suite of tests of the point-to-point intent descriptor. 24 * Suite of tests of the point-to-point intent descriptor.
24 */ 25 */
25 public class PointToPointIntentTest extends ConnectivityIntentTest { 26 public class PointToPointIntentTest extends ConnectivityIntentTest {
26 27
28 + /**
29 + * Checks that the MultiPointToSinglePointIntent class is immutable.
30 + */
31 + @Test
32 + public void checkImmutability() {
33 + assertThatClassIsImmutableBaseClass(PointToPointIntent.class);
34 + }
35 +
27 @Test 36 @Test
28 public void basics() { 37 public void basics() {
29 PointToPointIntent intent = createOne(); 38 PointToPointIntent intent = createOne();
......
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onlab.onos.net.intent;
17 -
18 -import org.junit.Ignore;
19 -import org.junit.Test;
20 -import org.onlab.onos.core.ApplicationId;
21 -import org.onlab.onos.TestApplicationId;
22 -import org.onlab.onos.net.HostId;
23 -import org.onlab.onos.net.flow.TrafficSelector;
24 -import org.onlab.onos.net.flow.TrafficTreatment;
25 -
26 -import static org.hamcrest.MatcherAssert.assertThat;
27 -import static org.hamcrest.Matchers.equalTo;
28 -import static org.hamcrest.Matchers.is;
29 -import static org.hamcrest.Matchers.not;
30 -import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
31 -import static org.onlab.onos.net.NetTestTools.hid;
32 -
33 -/**
34 - * Unit tests for the HostToHostIntent class.
35 - */
36 -public class TestHostToHostIntent {
37 -
38 - private static final ApplicationId APPID = new TestApplicationId("foo");
39 -
40 - private TrafficSelector selector = new IntentTestsMocks.MockSelector();
41 - private TrafficTreatment treatment = new IntentTestsMocks.MockTreatment();
42 -
43 - private HostToHostIntent makeHostToHost(HostId one, HostId two) {
44 - return new HostToHostIntent(APPID, one, two, selector, treatment);
45 - }
46 -
47 - /**
48 - * Tests the equals() method where two HostToHostIntents have references
49 - * to the same hosts. These should compare equal.
50 - */
51 - @Test @Ignore("Needs to be merged with other API test")
52 - public void testSameEquals() {
53 -
54 - HostId one = hid("00:00:00:00:00:01/-1");
55 - HostId two = hid("00:00:00:00:00:02/-1");
56 - HostToHostIntent i1 = makeHostToHost(one, two);
57 - HostToHostIntent i2 = makeHostToHost(one, two);
58 -
59 - assertThat(i1, is(equalTo(i2)));
60 - }
61 -
62 - /**
63 - * Tests the equals() method where two HostToHostIntents have references
64 - * to different Hosts. These should compare not equal.
65 - */
66 - @Test @Ignore("Needs to be merged with other API test")
67 - public void testSameEquals2() {
68 - HostId one = hid("00:00:00:00:00:01/-1");
69 - HostId two = hid("00:00:00:00:00:02/-1");
70 - HostToHostIntent i1 = makeHostToHost(one, two);
71 - HostToHostIntent i2 = makeHostToHost(two, one);
72 -
73 - assertThat(i1, is(equalTo(i2)));
74 - }
75 -
76 - /**
77 - * Tests that the hashCode() values for two equivalent HostToHostIntent
78 - * objects are the same.
79 - */
80 - @Test @Ignore("Needs to be merged with other API test")
81 - public void testHashCodeEquals() {
82 - HostId one = hid("00:00:00:00:00:01/-1");
83 - HostId two = hid("00:00:00:00:00:02/-1");
84 - HostToHostIntent i1 = makeHostToHost(one, two);
85 - HostToHostIntent i2 = makeHostToHost(one, two);
86 -
87 - assertThat(i1.hashCode(), is(equalTo(i2.hashCode())));
88 - }
89 -
90 - /**
91 - * Tests that the hashCode() values for two distinct LinkCollectionIntent
92 - * objects are different.
93 - */
94 - @Test @Ignore("Needs to be merged with other API test")
95 - public void testHashCodeEquals2() {
96 - HostId one = hid("00:00:00:00:00:01/-1");
97 - HostId two = hid("00:00:00:00:00:02/-1");
98 - HostToHostIntent i1 = makeHostToHost(one, two);
99 - HostToHostIntent i2 = makeHostToHost(two, one);
100 -
101 - assertThat(i1.hashCode(), is(equalTo(i2.hashCode())));
102 - }
103 -
104 - /**
105 - * Tests that the hashCode() values for two distinct LinkCollectionIntent
106 - * objects are different.
107 - */
108 - @Test @Ignore("Needs to be merged with other API test")
109 - public void testHashCodeDifferent() {
110 - HostId one = hid("00:00:00:00:00:01/-1");
111 - HostId two = hid("00:00:00:00:00:02/-1");
112 - HostId three = hid("00:00:00:00:00:32/-1");
113 - HostToHostIntent i1 = makeHostToHost(one, two);
114 - HostToHostIntent i2 = makeHostToHost(one, three);
115 -
116 - assertThat(i1.hashCode(), is(not(equalTo(i2.hashCode()))));
117 - }
118 -
119 - /**
120 - * Checks that the HostToHostIntent class is immutable.
121 - */
122 - @Test
123 - public void checkImmutability() {
124 - assertThatClassIsImmutable(HostToHostIntent.class);
125 - }
126 -}
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onlab.onos.net.intent;
17 -
18 -import static org.hamcrest.CoreMatchers.not;
19 -import static org.hamcrest.MatcherAssert.assertThat;
20 -import static org.hamcrest.Matchers.equalTo;
21 -import static org.hamcrest.Matchers.is;
22 -import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
23 -import static org.onlab.onos.net.NetTestTools.link;
24 -
25 -import java.util.HashSet;
26 -import java.util.Set;
27 -
28 -import org.junit.Before;
29 -import org.junit.Ignore;
30 -import org.junit.Test;
31 -import org.onlab.onos.core.ApplicationId;
32 -import org.onlab.onos.TestApplicationId;
33 -import org.onlab.onos.net.ConnectPoint;
34 -import org.onlab.onos.net.DeviceId;
35 -import org.onlab.onos.net.Link;
36 -import org.onlab.onos.net.PortNumber;
37 -import org.onlab.onos.net.flow.TrafficSelector;
38 -import org.onlab.onos.net.flow.TrafficTreatment;
39 -
40 -/**
41 - * Unit tests for the LinkCollectionIntent class.
42 - */
43 -public class TestLinkCollectionIntent {
44 -
45 - private static final ApplicationId APPID = new TestApplicationId("foo");
46 -
47 - private Link link1 = link("dev1", 1, "dev2", 2);
48 - private Link link2 = link("dev1", 1, "dev3", 2);
49 - private Link link3 = link("dev2", 1, "dev3", 2);
50 -
51 - private Set<Link> links1;
52 - private Set<Link> links2;
53 -
54 - private ConnectPoint egress1 = new ConnectPoint(DeviceId.deviceId("dev1"),
55 - PortNumber.portNumber(3));
56 - private ConnectPoint egress2 = new ConnectPoint(DeviceId.deviceId("dev2"),
57 - PortNumber.portNumber(3));
58 -
59 - private TrafficSelector selector = new IntentTestsMocks.MockSelector();
60 - private TrafficTreatment treatment = new IntentTestsMocks.MockTreatment();
61 -
62 - private LinkCollectionIntent makeLinkCollection(Set<Link> links,
63 - ConnectPoint egress) {
64 - return new LinkCollectionIntent(APPID, selector, treatment, links, egress);
65 - }
66 -
67 - @Before
68 - public void setup() {
69 - links1 = new HashSet<>();
70 - links2 = new HashSet<>();
71 - }
72 -
73 - /**
74 - * Tests the equals() method where two LinkCollectionIntents have references
75 - * to the same Links in different orders. These should compare equal.
76 - */
77 - @Test @Ignore("Needs to be merged with other API test")
78 - public void testSameEquals() {
79 - links1.add(link1);
80 - links1.add(link2);
81 - links1.add(link3);
82 -
83 - links2.add(link3);
84 - links2.add(link2);
85 - links2.add(link1);
86 -
87 - LinkCollectionIntent i1 = makeLinkCollection(links1, egress1);
88 - LinkCollectionIntent i2 = makeLinkCollection(links2, egress1);
89 -
90 - assertThat(i1, is(equalTo(i2)));
91 - }
92 -
93 - /**
94 - * Tests the equals() method where two LinkCollectionIntents have references
95 - * to different Links. These should compare not equal.
96 - */
97 - @Test @Ignore("Needs to be merged with other API test")
98 - public void testLinksDifferentEquals() {
99 - links1.add(link1);
100 - links1.add(link2);
101 -
102 - links2.add(link3);
103 - links2.add(link1);
104 -
105 - LinkCollectionIntent i1 = makeLinkCollection(links1, egress1);
106 - LinkCollectionIntent i2 = makeLinkCollection(links2, egress1);
107 -
108 - assertThat(i1, is(not(equalTo(i2))));
109 - }
110 -
111 - /**
112 - * Tests the equals() method where two LinkCollectionIntents have references
113 - * to the same Links but different egress points. These should compare not equal.
114 - */
115 - @Test @Ignore("Needs to be merged with other API test")
116 - public void testEgressDifferentEquals() {
117 - links1.add(link1);
118 - links1.add(link2);
119 - links1.add(link3);
120 -
121 - links2.add(link3);
122 - links2.add(link2);
123 - links2.add(link1);
124 -
125 - LinkCollectionIntent i1 = makeLinkCollection(links1, egress1);
126 - LinkCollectionIntent i2 = makeLinkCollection(links2, egress2);
127 -
128 - assertThat(i1, is(not(equalTo(i2))));
129 - }
130 -
131 - /**
132 - * Tests that the hashCode() values for two equivalent LinkCollectionIntent
133 - * objects are the same.
134 - */
135 - @Test @Ignore("Needs to be merged with other API test")
136 - public void testHashCodeEquals() {
137 - links1.add(link1);
138 - links1.add(link2);
139 - links1.add(link3);
140 -
141 - links2.add(link3);
142 - links2.add(link2);
143 - links2.add(link1);
144 -
145 - LinkCollectionIntent i1 = makeLinkCollection(links1, egress1);
146 - LinkCollectionIntent i2 = makeLinkCollection(links2, egress1);
147 -
148 - assertThat(i1.hashCode(), is(equalTo(i2.hashCode())));
149 - }
150 -
151 - /**
152 - * Tests that the hashCode() values for two distinct LinkCollectionIntent
153 - * objects are different.
154 - */
155 - @Test @Ignore("Needs to be merged with other API test")
156 - public void testHashCodeDifferent() {
157 - links1.add(link1);
158 - links1.add(link2);
159 -
160 - links2.add(link1);
161 - links2.add(link3);
162 -
163 - LinkCollectionIntent i1 = makeLinkCollection(links1, egress1);
164 - LinkCollectionIntent i2 = makeLinkCollection(links2, egress2);
165 -
166 - assertThat(i1.hashCode(), is(not(equalTo(i2.hashCode()))));
167 - }
168 -
169 - /**
170 - * Checks that the HostToHostIntent class is immutable.
171 - */
172 - @Test
173 - public void checkImmutability() {
174 - assertThatClassIsImmutable(LinkCollectionIntent.class);
175 - }
176 -}
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onlab.onos.net.intent;
17 -
18 -import org.junit.Before;
19 -import org.junit.Ignore;
20 -import org.junit.Test;
21 -import org.onlab.onos.core.ApplicationId;
22 -import org.onlab.onos.TestApplicationId;
23 -import org.onlab.onos.net.ConnectPoint;
24 -import org.onlab.onos.net.flow.TrafficSelector;
25 -import org.onlab.onos.net.flow.TrafficTreatment;
26 -
27 -import java.util.HashSet;
28 -import java.util.Set;
29 -
30 -import static org.hamcrest.CoreMatchers.not;
31 -import static org.hamcrest.MatcherAssert.assertThat;
32 -import static org.hamcrest.Matchers.equalTo;
33 -import static org.hamcrest.Matchers.is;
34 -import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
35 -import static org.onlab.onos.net.NetTestTools.connectPoint;
36 -
37 -/**
38 - * Unit tests for the MultiPointToSinglePointIntent class.
39 - */
40 -public class TestMultiPointToSinglePointIntent {
41 -
42 - private static final ApplicationId APPID = new TestApplicationId("foo");
43 -
44 - private ConnectPoint point1 = connectPoint("dev1", 1);
45 - private ConnectPoint point2 = connectPoint("dev2", 1);
46 - private ConnectPoint point3 = connectPoint("dev3", 1);
47 -
48 - private TrafficSelector selector = new IntentTestsMocks.MockSelector();
49 - private TrafficTreatment treatment = new IntentTestsMocks.MockTreatment();
50 -
51 - Set<ConnectPoint> ingress1;
52 - Set<ConnectPoint> ingress2;
53 -
54 - /**
55 - * Creates a MultiPointToSinglePointIntent object.
56 - *
57 - * @param ingress set of ingress points
58 - * @param egress egress point
59 - * @return MultiPointToSinglePoint intent
60 - */
61 - private MultiPointToSinglePointIntent makeIntent(Set<ConnectPoint> ingress,
62 - ConnectPoint egress) {
63 - return new MultiPointToSinglePointIntent(APPID, selector, treatment,
64 - ingress, egress);
65 - }
66 -
67 - /**
68 - * Initializes the ingress sets.
69 - */
70 - @Before
71 - public void setup() {
72 - ingress1 = new HashSet<>();
73 - ingress2 = new HashSet<>();
74 - }
75 -
76 - /**
77 - * Tests the equals() method where two MultiPointToSinglePoint have references
78 - * to the same Links in different orders. These should compare equal.
79 - */
80 - @Test @Ignore("Needs to be merged with other API test")
81 - public void testSameEquals() {
82 -
83 - Set<ConnectPoint> ingress1 = new HashSet<>();
84 - ingress1.add(point2);
85 - ingress1.add(point3);
86 -
87 - Set<ConnectPoint> ingress2 = new HashSet<>();
88 - ingress2.add(point3);
89 - ingress2.add(point2);
90 -
91 - Intent i1 = makeIntent(ingress1, point1);
92 - Intent i2 = makeIntent(ingress2, point1);
93 -
94 - assertThat(i1, is(equalTo(i2)));
95 - }
96 -
97 - /**
98 - * Tests the equals() method where two MultiPointToSinglePoint have references
99 - * to different Links. These should compare not equal.
100 - */
101 - @Test @Ignore("Needs to be merged with other API test")
102 - public void testLinksDifferentEquals() {
103 - ingress1.add(point3);
104 -
105 - ingress2.add(point3);
106 - ingress2.add(point2);
107 -
108 - Intent i1 = makeIntent(ingress1, point1);
109 - Intent i2 = makeIntent(ingress2, point1);
110 -
111 - assertThat(i1, is(not(equalTo(i2))));
112 - }
113 -
114 - /**
115 - * Tests that the hashCode() values for two equivalent MultiPointToSinglePoint
116 - * objects are the same.
117 - */
118 - @Test @Ignore("Needs to be merged with other API test")
119 - public void testHashCodeEquals() {
120 - ingress1.add(point2);
121 - ingress1.add(point3);
122 -
123 - ingress2.add(point3);
124 - ingress2.add(point2);
125 -
126 - Intent i1 = makeIntent(ingress1, point1);
127 - Intent i2 = makeIntent(ingress2, point1);
128 -
129 - assertThat(i1.hashCode(), is(equalTo(i2.hashCode())));
130 - }
131 -
132 - /**
133 - * Tests that the hashCode() values for two distinct MultiPointToSinglePoint
134 - * objects are different.
135 - */
136 - @Test @Ignore("Needs to be merged with other API test")
137 - public void testHashCodeDifferent() {
138 - ingress1.add(point2);
139 -
140 - ingress2.add(point3);
141 - ingress2.add(point2);
142 -
143 - Intent i1 = makeIntent(ingress1, point1);
144 - Intent i2 = makeIntent(ingress2, point1);
145 -
146 -
147 - assertThat(i1.hashCode(), is(not(equalTo(i2.hashCode()))));
148 - }
149 -
150 - /**
151 - * Checks that the MultiPointToSinglePointIntent class is immutable.
152 - */
153 - @Test
154 - public void checkImmutability() {
155 - assertThatClassIsImmutable(MultiPointToSinglePointIntent.class);
156 - }
157 -}
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onlab.onos.net.intent;
17 -
18 -import org.junit.Ignore;
19 -import org.junit.Test;
20 -import org.onlab.onos.core.ApplicationId;
21 -import org.onlab.onos.TestApplicationId;
22 -import org.onlab.onos.net.ConnectPoint;
23 -import org.onlab.onos.net.flow.TrafficSelector;
24 -import org.onlab.onos.net.flow.TrafficTreatment;
25 -
26 -import static org.hamcrest.MatcherAssert.assertThat;
27 -import static org.hamcrest.Matchers.*;
28 -import static org.onlab.onos.net.NetTestTools.connectPoint;
29 -
30 -/**
31 - * Unit tests for the HostToHostIntent class.
32 - */
33 -public class TestPointToPointIntent {
34 -
35 - private static final ApplicationId APPID = new TestApplicationId("foo");
36 -
37 - private TrafficSelector selector = new IntentTestsMocks.MockSelector();
38 - private TrafficTreatment treatment = new IntentTestsMocks.MockTreatment();
39 -
40 - private ConnectPoint point1 = connectPoint("dev1", 1);
41 - private ConnectPoint point2 = connectPoint("dev2", 1);
42 -
43 - private PointToPointIntent makePointToPoint(ConnectPoint ingress,
44 - ConnectPoint egress) {
45 - return new PointToPointIntent(APPID, selector, treatment, ingress, egress);
46 - }
47 -
48 - /**
49 - * Tests the equals() method where two PointToPointIntents have references
50 - * to the same ingress and egress points. These should compare equal.
51 - */
52 - @Test @Ignore("Needs to be merged with other API test")
53 - public void testSameEquals() {
54 - PointToPointIntent i1 = makePointToPoint(point1, point2);
55 - PointToPointIntent i2 = makePointToPoint(point1, point2);
56 -
57 - assertThat(i1, is(equalTo(i2)));
58 - }
59 -
60 - /**
61 - * Tests the equals() method where two HostToHostIntents have references
62 - * to different Hosts. These should compare not equal.
63 - */
64 - @Test @Ignore("Needs to be merged with other API test")
65 - public void testLinksDifferentEquals() {
66 - PointToPointIntent i1 = makePointToPoint(point1, point2);
67 - PointToPointIntent i2 = makePointToPoint(point2, point1);
68 -
69 - assertThat(i1, is(not(equalTo(i2))));
70 - }
71 -
72 - /**
73 - * Tests that the hashCode() values for two equivalent HostToHostIntent
74 - * objects are the same.
75 - */
76 - @Test @Ignore("Needs to be merged with other API test")
77 - public void testHashCodeEquals() {
78 - PointToPointIntent i1 = makePointToPoint(point1, point2);
79 - PointToPointIntent i2 = makePointToPoint(point1, point2);
80 -
81 - assertThat(i1.hashCode(), is(equalTo(i2.hashCode())));
82 - }
83 -
84 - /**
85 - * Tests that the hashCode() values for two distinct LinkCollectionIntent
86 - * objects are different.
87 - */
88 - @Test @Ignore("Needs to be merged with other API test")
89 - public void testHashCodeDifferent() {
90 - PointToPointIntent i1 = makePointToPoint(point1, point2);
91 - PointToPointIntent i2 = makePointToPoint(point2, point1);
92 -
93 - assertThat(i1.hashCode(), is(not(equalTo(i2.hashCode()))));
94 - }
95 -}
...@@ -46,7 +46,7 @@ import static org.onlab.onos.net.intent.LinksHaveEntryWithSourceDestinationPairM ...@@ -46,7 +46,7 @@ import static org.onlab.onos.net.intent.LinksHaveEntryWithSourceDestinationPairM
46 /** 46 /**
47 * Unit tests for the HostToHost intent compiler. 47 * Unit tests for the HostToHost intent compiler.
48 */ 48 */
49 -public class TestHostToHostIntentCompiler extends AbstractIntentTest { 49 +public class HostToHostIntentCompilerTest extends AbstractIntentTest {
50 private static final String HOST_ONE_MAC = "00:00:00:00:00:01"; 50 private static final String HOST_ONE_MAC = "00:00:00:00:00:01";
51 private static final String HOST_TWO_MAC = "00:00:00:00:00:02"; 51 private static final String HOST_TWO_MAC = "00:00:00:00:00:02";
52 private static final String HOST_ONE_VLAN = "-1"; 52 private static final String HOST_ONE_VLAN = "-1";
......
...@@ -47,7 +47,7 @@ import static org.onlab.onos.net.intent.LinksHaveEntryWithSourceDestinationPairM ...@@ -47,7 +47,7 @@ import static org.onlab.onos.net.intent.LinksHaveEntryWithSourceDestinationPairM
47 /** 47 /**
48 * Unit tests for the MultiPointToSinglePoint intent compiler. 48 * Unit tests for the MultiPointToSinglePoint intent compiler.
49 */ 49 */
50 -public class TestMultiPointToSinglePointIntentCompiler extends AbstractIntentTest { 50 +public class MultiPointToSinglePointIntentCompilerTest extends AbstractIntentTest {
51 51
52 private static final ApplicationId APPID = new TestApplicationId("foo"); 52 private static final ApplicationId APPID = new TestApplicationId("foo");
53 53
......
...@@ -47,7 +47,7 @@ import static org.onlab.onos.net.intent.LinksHaveEntryWithSourceDestinationPairM ...@@ -47,7 +47,7 @@ import static org.onlab.onos.net.intent.LinksHaveEntryWithSourceDestinationPairM
47 /** 47 /**
48 * Unit tests for the HostToHost intent compiler. 48 * Unit tests for the HostToHost intent compiler.
49 */ 49 */
50 -public class TestPointToPointIntentCompiler extends AbstractIntentTest { 50 +public class PointToPointIntentCompilerTest extends AbstractIntentTest {
51 51
52 private static final ApplicationId APPID = new TestApplicationId("foo"); 52 private static final ApplicationId APPID = new TestApplicationId("foo");
53 53
......
...@@ -15,18 +15,18 @@ ...@@ -15,18 +15,18 @@
15 */ 15 */
16 package org.onlab.packet; 16 package org.onlab.packet;
17 17
18 -import com.google.common.net.InetAddresses; 18 +import java.net.InetAddress;
19 -import com.google.common.testing.EqualsTester; 19 +
20 -import org.junit.Ignore;
21 import org.junit.Test; 20 import org.junit.Test;
22 21
23 -import java.net.InetAddress; 22 +import com.google.common.net.InetAddresses;
23 +import com.google.common.testing.EqualsTester;
24 24
25 import static org.hamcrest.Matchers.is; 25 import static org.hamcrest.Matchers.is;
26 import static org.junit.Assert.assertNull; 26 import static org.junit.Assert.assertNull;
27 import static org.junit.Assert.assertThat; 27 import static org.junit.Assert.assertThat;
28 import static org.junit.Assert.assertTrue; 28 import static org.junit.Assert.assertTrue;
29 -import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; 29 +import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutableBaseClass;
30 30
31 /** 31 /**
32 * Tests for class {@link IpAddress}. 32 * Tests for class {@link IpAddress}.
...@@ -35,10 +35,9 @@ public class IpAddressTest { ...@@ -35,10 +35,9 @@ public class IpAddressTest {
35 /** 35 /**
36 * Tests the immutability of {@link IpAddress}. 36 * Tests the immutability of {@link IpAddress}.
37 */ 37 */
38 - @Ignore("The class is not pure immutable, because it is not 'final'")
39 @Test 38 @Test
40 public void testImmutable() { 39 public void testImmutable() {
41 - assertThatClassIsImmutable(IpAddress.class); 40 + assertThatClassIsImmutableBaseClass(IpAddress.class);
42 } 41 }
43 42
44 /** 43 /**
......
...@@ -15,17 +15,17 @@ ...@@ -15,17 +15,17 @@
15 */ 15 */
16 package org.onlab.packet; 16 package org.onlab.packet;
17 17
18 -import com.google.common.testing.EqualsTester;
19 -import org.junit.Ignore;
20 import org.junit.Test; 18 import org.junit.Test;
21 19
20 +import com.google.common.testing.EqualsTester;
21 +
22 import static org.hamcrest.Matchers.equalTo; 22 import static org.hamcrest.Matchers.equalTo;
23 import static org.hamcrest.Matchers.is; 23 import static org.hamcrest.Matchers.is;
24 import static org.junit.Assert.assertFalse; 24 import static org.junit.Assert.assertFalse;
25 import static org.junit.Assert.assertNull; 25 import static org.junit.Assert.assertNull;
26 import static org.junit.Assert.assertThat; 26 import static org.junit.Assert.assertThat;
27 import static org.junit.Assert.assertTrue; 27 import static org.junit.Assert.assertTrue;
28 -import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; 28 +import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutableBaseClass;
29 29
30 /** 30 /**
31 * Tests for class {@link IpPrefix}. 31 * Tests for class {@link IpPrefix}.
...@@ -34,10 +34,9 @@ public class IpPrefixTest { ...@@ -34,10 +34,9 @@ public class IpPrefixTest {
34 /** 34 /**
35 * Tests the immutability of {@link IpPrefix}. 35 * Tests the immutability of {@link IpPrefix}.
36 */ 36 */
37 - @Ignore("The class is not pure immutable, because it is not 'final'")
38 @Test 37 @Test
39 public void testImmutable() { 38 public void testImmutable() {
40 - assertThatClassIsImmutable(IpPrefix.class); 39 + assertThatClassIsImmutableBaseClass(IpPrefix.class);
41 } 40 }
42 41
43 /** 42 /**
......