blob: 39a4d05758f29e0eb95af9e32737dcafa9b4616e [file] [log] [blame]
Toshio Koided46b66d2014-07-21 10:27:27 -07001package net.onrc.onos.core.flowmanager;
2
3import static org.junit.Assert.assertEquals;
4import net.onrc.onos.api.flowmanager.ConflictDetectionPolicy;
Toshio Koide84648822014-08-21 02:07:56 -07005import net.onrc.onos.core.registry.StandaloneRegistry;
6import net.onrc.onos.core.util.IdBlockAllocator;
Toshio Koided46b66d2014-07-21 10:27:27 -07007
8import org.junit.After;
9import org.junit.Before;
10import org.junit.Rule;
11import org.junit.Test;
12import org.junit.rules.ExpectedException;
13
14public class FlowManagerModuleTest {
Toshio Koide84648822014-08-21 02:07:56 -070015 IdBlockAllocator idBlockAllocator;
16
Toshio Koided46b66d2014-07-21 10:27:27 -070017 @Rule
18 public ExpectedException thrown = ExpectedException.none();
19
20 @Before
21 public void setUp() throws Exception {
Toshio Koide84648822014-08-21 02:07:56 -070022 idBlockAllocator = new StandaloneRegistry();
Toshio Koided46b66d2014-07-21 10:27:27 -070023 }
24
25 @After
26 public void tearDown() throws Exception {
27 }
28
29 /**
Toshio Koide84648822014-08-21 02:07:56 -070030 * Checks the default conflict detection policy is the FREE policy, and the
31 * other policies are not supported.
Toshio Koided46b66d2014-07-21 10:27:27 -070032 */
33 @Test
34 public void testConflictDetectionPolicy() {
Toshio Koide84648822014-08-21 02:07:56 -070035 FlowManagerModule flowManager = new FlowManagerModule(idBlockAllocator);
Toshio Koided46b66d2014-07-21 10:27:27 -070036 assertEquals(ConflictDetectionPolicy.FREE,
37 flowManager.getConflictDetectionPolicy());
38
39 flowManager.setConflictDetectionPolicy(ConflictDetectionPolicy.FREE);
40 assertEquals(ConflictDetectionPolicy.FREE,
41 flowManager.getConflictDetectionPolicy());
42
43 thrown.expect(UnsupportedOperationException.class);
44 thrown.expectMessage("LOOSE is not supported.");
45 flowManager.setConflictDetectionPolicy(ConflictDetectionPolicy.LOOSE);
46 assertEquals(ConflictDetectionPolicy.FREE,
47 flowManager.getConflictDetectionPolicy());
48
49 thrown.expect(UnsupportedOperationException.class);
50 thrown.expectMessage("STRICT is not supported.");
51 flowManager.setConflictDetectionPolicy(ConflictDetectionPolicy.STRICT);
52 assertEquals(ConflictDetectionPolicy.FREE,
53 flowManager.getConflictDetectionPolicy());
54 }
55
56}