Jonathan Hart

Fixed SDN-IP tests after ONOS-874 merge.

Change-Id: Ie14f64ecf7f9bc72120f837ef9cd2b8904cc4bd2
...@@ -17,7 +17,6 @@ package org.onosproject.sdnip; ...@@ -17,7 +17,6 @@ package org.onosproject.sdnip;
17 17
18 import com.google.common.collect.Sets; 18 import com.google.common.collect.Sets;
19 import org.junit.Before; 19 import org.junit.Before;
20 -import org.junit.Ignore;
21 import org.junit.Test; 20 import org.junit.Test;
22 import org.onlab.junit.TestUtils; 21 import org.onlab.junit.TestUtils;
23 import org.onlab.junit.TestUtils.TestUtilsException; 22 import org.onlab.junit.TestUtils.TestUtilsException;
...@@ -59,13 +58,16 @@ import java.util.concurrent.ConcurrentHashMap; ...@@ -59,13 +58,16 @@ import java.util.concurrent.ConcurrentHashMap;
59 58
60 import static org.easymock.EasyMock.*; 59 import static org.easymock.EasyMock.*;
61 import static org.hamcrest.Matchers.is; 60 import static org.hamcrest.Matchers.is;
62 -import static org.junit.Assert.*; 61 +import static org.junit.Assert.assertEquals;
62 +import static org.junit.Assert.assertFalse;
63 +import static org.junit.Assert.assertThat;
64 +import static org.junit.Assert.assertTrue;
65 +import static org.onosproject.sdnip.TestIntentServiceHelper.eqExceptId;
63 66
64 /** 67 /**
65 * This class tests the intent synchronization function in the 68 * This class tests the intent synchronization function in the
66 * IntentSynchronizer class. 69 * IntentSynchronizer class.
67 */ 70 */
68 -@Ignore //FIXME
69 public class IntentSyncTest extends AbstractIntentTest { 71 public class IntentSyncTest extends AbstractIntentTest {
70 72
71 private SdnIpConfigurationService sdnIpConfigService; 73 private SdnIpConfigurationService sdnIpConfigService;
...@@ -237,11 +239,7 @@ public class IntentSyncTest extends AbstractIntentTest { ...@@ -237,11 +239,7 @@ public class IntentSyncTest extends AbstractIntentTest {
237 ingressPoints, SW1_ETH1); 239 ingressPoints, SW1_ETH1);
238 240
239 // Setup the expected intents 241 // Setup the expected intents
240 -// FIXME Jono needs to refactor 242 + intentService.submit(eqExceptId(intent));
241 -// IntentOperations.Builder builder = IntentOperations.builder(APPID);
242 -// builder.addSubmitOperation(intent);
243 -// intentService.execute(TestIntentServiceHelper.eqExceptId(
244 -// builder.build()));
245 replay(intentService); 243 replay(intentService);
246 244
247 intentSynchronizer.leaderChanged(true); 245 intentSynchronizer.leaderChanged(true);
...@@ -299,11 +297,8 @@ public class IntentSyncTest extends AbstractIntentTest { ...@@ -299,11 +297,8 @@ public class IntentSyncTest extends AbstractIntentTest {
299 ingressPoints, SW4_ETH1); 297 ingressPoints, SW4_ETH1);
300 298
301 // Setup the expected intents 299 // Setup the expected intents
302 -// FIXME Jono needs to refactor 300 + intentService.submit(eqExceptId(intent));
303 -// IntentOperations.Builder builder = IntentOperations.builder(APPID); 301 +
304 -// builder.addSubmitOperation(intent);
305 -// intentService.execute(
306 -// TestIntentServiceHelper.eqExceptId(builder.build()));
307 replay(intentService); 302 replay(intentService);
308 303
309 // Run the test 304 // Run the test
...@@ -371,15 +366,8 @@ public class IntentSyncTest extends AbstractIntentTest { ...@@ -371,15 +366,8 @@ public class IntentSyncTest extends AbstractIntentTest {
371 // Set up test expectation 366 // Set up test expectation
372 reset(intentService); 367 reset(intentService);
373 // Setup the expected intents 368 // Setup the expected intents
374 -// FIXME Jono needs to refactor 369 + intentService.withdraw(eqExceptId(addedIntent));
375 -// IntentOperations.Builder builder = IntentOperations.builder(APPID); 370 + intentService.submit(eqExceptId(intentNew));
376 -// builder.addWithdrawOperation(addedIntent.id());
377 -// intentService.execute(TestIntentServiceHelper.eqExceptId(
378 -// builder.build()));
379 -// builder = IntentOperations.builder(APPID);
380 -// builder.addSubmitOperation(intentNew);
381 -// intentService.execute(TestIntentServiceHelper.eqExceptId(
382 -// builder.build()));
383 replay(intentService); 371 replay(intentService);
384 372
385 // Call the update() method in IntentSynchronizer class 373 // Call the update() method in IntentSynchronizer class
...@@ -423,11 +411,7 @@ public class IntentSyncTest extends AbstractIntentTest { ...@@ -423,11 +411,7 @@ public class IntentSyncTest extends AbstractIntentTest {
423 // Set up expectation 411 // Set up expectation
424 reset(intentService); 412 reset(intentService);
425 // Setup the expected intents 413 // Setup the expected intents
426 -// FIXME Jono needs to refactor 414 + intentService.withdraw(eqExceptId(addedIntent));
427 -// IntentOperations.Builder builder = IntentOperations.builder(APPID);
428 -// builder.addWithdrawOperation(addedIntent.id());
429 -// intentService.execute(TestIntentServiceHelper.eqExceptId(
430 -// builder.build()));
431 replay(intentService); 415 replay(intentService);
432 416
433 // Call the update() method in IntentSynchronizer class 417 // Call the update() method in IntentSynchronizer class
......
...@@ -54,11 +54,11 @@ import java.util.List; ...@@ -54,11 +54,11 @@ import java.util.List;
54 import java.util.Map; 54 import java.util.Map;
55 55
56 import static org.easymock.EasyMock.*; 56 import static org.easymock.EasyMock.*;
57 +import static org.onosproject.sdnip.TestIntentServiceHelper.eqExceptId;
57 58
58 /** 59 /**
59 * Unit tests for PeerConnectivityManager. 60 * Unit tests for PeerConnectivityManager.
60 */ 61 */
61 -@Ignore
62 public class PeerConnectivityManagerTest extends AbstractIntentTest { 62 public class PeerConnectivityManagerTest extends AbstractIntentTest {
63 63
64 private static final ApplicationId APPID = new ApplicationId() { 64 private static final ApplicationId APPID = new ApplicationId() {
...@@ -571,7 +571,7 @@ public class PeerConnectivityManagerTest extends AbstractIntentTest { ...@@ -571,7 +571,7 @@ public class PeerConnectivityManagerTest extends AbstractIntentTest {
571 571
572 // Setup the expected intents 572 // Setup the expected intents
573 for (Intent intent : intentList) { 573 for (Intent intent : intentList) {
574 - intentService.submit(intent); 574 + intentService.submit(eqExceptId(intent));
575 } 575 }
576 replay(intentService); 576 replay(intentService);
577 577
......
...@@ -43,20 +43,6 @@ public final class TestIntentServiceHelper { ...@@ -43,20 +43,6 @@ public final class TestIntentServiceHelper {
43 return intent; 43 return intent;
44 } 44 }
45 45
46 - /**
47 - * Matcher method to set the expected intent operations to match against
48 - * (ignoring the intent ID for each intent).
49 - *
50 - * param intentOperations the expected Intent Operations
51 - * @return the submitted Intent Operations
52 - */
53 - /*
54 - static IntentOperations eqExceptId(IntentOperations intentOperations) {
55 - reportMatcher(new IdAgnosticIntentOperationsMatcher(intentOperations));
56 - return intentOperations;
57 - }
58 - */
59 -
60 /* 46 /*
61 * EasyMock matcher that matches {@link Intent} but 47 * EasyMock matcher that matches {@link Intent} but
62 * ignores the {@link IntentId} when matching. 48 * ignores the {@link IntentId} when matching.
...@@ -67,6 +53,8 @@ public final class TestIntentServiceHelper { ...@@ -67,6 +53,8 @@ public final class TestIntentServiceHelper {
67 * the solution is to use an EasyMock matcher that verifies that all the 53 * the solution is to use an EasyMock matcher that verifies that all the
68 * value properties of the provided intent match the expected values, but 54 * value properties of the provided intent match the expected values, but
69 * ignores the intent ID when testing equality. 55 * ignores the intent ID when testing equality.
56 + *
57 + * FIXME this currently does not take key into account
70 */ 58 */
71 private static final class IdAgnosticIntentMatcher implements 59 private static final class IdAgnosticIntentMatcher implements
72 IArgumentMatcher { 60 IArgumentMatcher {
...@@ -104,109 +92,4 @@ public final class TestIntentServiceHelper { ...@@ -104,109 +92,4 @@ public final class TestIntentServiceHelper {
104 } 92 }
105 } 93 }
106 94
107 - /*
108 - * EasyMock matcher that matches {@link IntenOperations} but
109 - * ignores the {@link IntentId} when matching.
110 - * <p/>
111 - * The normal intent equals method tests that the intent IDs are equal,
112 - * however in these tests we can't know what the intent IDs will be in
113 - * advance, so we can't set up expected intents with the correct IDs. Thus,
114 - * the solution is to use an EasyMock matcher that verifies that all the
115 - * value properties of the provided intent match the expected values, but
116 - * ignores the intent ID when testing equality.
117 - */
118 - /*
119 - private static final class IdAgnosticIntentOperationsMatcher implements
120 - IArgumentMatcher {
121 -
122 - //private final IntentOperations intentOperations;
123 - private String providedString;
124 -
125 - @Override
126 - public void appendTo(StringBuffer strBuffer) {
127 - strBuffer.append("IntentOperationsMatcher unable to match: "
128 - + providedString);
129 - }
130 -
131 - @Override
132 - public boolean matches(Object object) {
133 - if (!(object instanceof IntentOperations)) {
134 - return false;
135 - }
136 -
137 - IntentOperations providedIntentOperations =
138 - (IntentOperations) object;
139 - providedString = providedIntentOperations.toString();
140 -
141 - List<IntentKey> thisSubmitIntents = new LinkedList<>();
142 - List<IntentId> thisWithdrawIntentIds = new LinkedList<>();
143 - List<IntentKey> thisReplaceIntents = new LinkedList<>();
144 - List<IntentKey> thisUpdateIntents = new LinkedList<>();
145 - List<IntentKey> providedSubmitIntents = new LinkedList<>();
146 - List<IntentId> providedWithdrawIntentIds = new LinkedList<>();
147 - List<IntentKey> providedReplaceIntents = new LinkedList<>();
148 - List<IntentKey> providedUpdateIntents = new LinkedList<>();
149 -
150 - extractIntents(intentOperations, thisSubmitIntents,
151 - thisWithdrawIntentIds, thisReplaceIntents,
152 - thisUpdateIntents);
153 - extractIntents(providedIntentOperations, providedSubmitIntents,
154 - providedWithdrawIntentIds, providedReplaceIntents,
155 - providedUpdateIntents);
156 -
157 - return CollectionUtils.isEqualCollection(thisSubmitIntents,
158 - providedSubmitIntents) &&
159 - CollectionUtils.isEqualCollection(thisWithdrawIntentIds,
160 - providedWithdrawIntentIds) &&
161 - CollectionUtils.isEqualCollection(thisUpdateIntents,
162 - providedUpdateIntents) &&
163 - CollectionUtils.isEqualCollection(thisReplaceIntents,
164 - providedReplaceIntents);
165 - }
166 -
167 -
168 - /**
169 - * Extracts the intents per operation type. Each intent is encapsulated
170 - * in IntentKey so it can be compared by excluding the Intent ID.
171 - *
172 - * @param intentOperations the container with the intent operations
173 - * to extract the intents from
174 - * @param submitIntents the SUBMIT intents
175 - * @param withdrawIntentIds the WITHDRAW intents IDs
176 - * @param replaceIntents the REPLACE intents
177 - * @param updateIntents the UPDATE intents
178 - */
179 - /*
180 - private void extractIntents(IntentOperations intentOperations,
181 - List<IntentKey> submitIntents,
182 - List<IntentId> withdrawIntentIds,
183 - List<IntentKey> replaceIntents,
184 - List<IntentKey> updateIntents) {
185 - for (IntentOperation oper : intentOperations.operations()) {
186 - IntentId intentId;
187 - IntentKey intentKey;
188 - switch (oper.type()) {
189 - case SUBMIT:
190 - intentKey = new IntentKey(oper.intent());
191 - submitIntents.add(intentKey);
192 - break;
193 - case WITHDRAW:
194 - intentId = oper.intentId();
195 - withdrawIntentIds.add(intentId);
196 - break;
197 - case REPLACE:
198 - intentKey = new IntentKey(oper.intent());
199 - replaceIntents.add(intentKey);
200 - break;
201 - case UPDATE:
202 - intentKey = new IntentKey(oper.intent());
203 - updateIntents.add(intentKey);
204 - break;
205 - default:
206 - break;
207 - }
208 - }
209 - }
210 - }
211 - */
212 } 95 }
......