Committed by
Gerrit Code Review
Unbind the ID generator when the test is complete
This was causing intermittent failures in some intent tests because the id generator was not unbound and subsequent tests would fail trying to assign a new one. Change-Id: Id10caf69c32383b27d246426c29972b7654b40bb
Showing
1 changed file
with
22 additions
and
14 deletions
... | @@ -15,9 +15,15 @@ | ... | @@ -15,9 +15,15 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.vpls; | 16 | package org.onosproject.vpls; |
17 | 17 | ||
18 | -import com.google.common.collect.Sets; | 18 | +import java.util.ArrayList; |
19 | +import java.util.Collections; | ||
20 | +import java.util.List; | ||
21 | +import java.util.Set; | ||
22 | +import java.util.concurrent.atomic.AtomicLong; | ||
23 | +import java.util.stream.Collectors; | ||
24 | + | ||
25 | +import org.junit.After; | ||
19 | import org.junit.Before; | 26 | import org.junit.Before; |
20 | -import org.junit.BeforeClass; | ||
21 | import org.junit.Test; | 27 | import org.junit.Test; |
22 | import org.onlab.packet.Ip4Address; | 28 | import org.onlab.packet.Ip4Address; |
23 | import org.onlab.packet.MacAddress; | 29 | import org.onlab.packet.MacAddress; |
... | @@ -56,16 +62,14 @@ import org.onosproject.net.provider.ProviderId; | ... | @@ -56,16 +62,14 @@ import org.onosproject.net.provider.ProviderId; |
56 | import org.onosproject.routing.IntentSynchronizationAdminService; | 62 | import org.onosproject.routing.IntentSynchronizationAdminService; |
57 | import org.onosproject.routing.IntentSynchronizationService; | 63 | import org.onosproject.routing.IntentSynchronizationService; |
58 | 64 | ||
59 | -import java.util.ArrayList; | 65 | +import com.google.common.collect.Sets; |
60 | -import java.util.Collections; | ||
61 | -import java.util.List; | ||
62 | -import java.util.Set; | ||
63 | -import java.util.concurrent.atomic.AtomicLong; | ||
64 | -import java.util.stream.Collectors; | ||
65 | 66 | ||
66 | import static java.lang.String.format; | 67 | import static java.lang.String.format; |
67 | -import static org.easymock.EasyMock.*; | 68 | +import static org.easymock.EasyMock.anyObject; |
69 | +import static org.easymock.EasyMock.createMock; | ||
70 | +import static org.easymock.EasyMock.expect; | ||
68 | import static org.easymock.EasyMock.expectLastCall; | 71 | import static org.easymock.EasyMock.expectLastCall; |
72 | +import static org.easymock.EasyMock.replay; | ||
69 | import static org.junit.Assert.assertEquals; | 73 | import static org.junit.Assert.assertEquals; |
70 | import static org.junit.Assert.assertTrue; | 74 | import static org.junit.Assert.assertTrue; |
71 | 75 | ||
... | @@ -132,14 +136,13 @@ public class VplsTest { | ... | @@ -132,14 +136,13 @@ public class VplsTest { |
132 | 136 | ||
133 | private static final ProviderId PID = new ProviderId("of", "foo"); | 137 | private static final ProviderId PID = new ProviderId("of", "foo"); |
134 | 138 | ||
135 | - @BeforeClass | 139 | + private static IdGenerator idGenerator; |
136 | - public static void setUpClass() { | ||
137 | - IdGenerator idGenerator = new TestIdGenerator(); | ||
138 | - Intent.bindIdGenerator(idGenerator); | ||
139 | - } | ||
140 | 140 | ||
141 | @Before | 141 | @Before |
142 | public void setUp() throws Exception { | 142 | public void setUp() throws Exception { |
143 | + idGenerator = new TestIdGenerator(); | ||
144 | + Intent.bindIdGenerator(idGenerator); | ||
145 | + | ||
143 | applicationService = createMock(ApplicationService.class); | 146 | applicationService = createMock(ApplicationService.class); |
144 | 147 | ||
145 | coreService = createMock(CoreService.class); | 148 | coreService = createMock(CoreService.class); |
... | @@ -170,6 +173,11 @@ public class VplsTest { | ... | @@ -170,6 +173,11 @@ public class VplsTest { |
170 | vpls.intentSynchronizerAdmin = intentSynchronizer; | 173 | vpls.intentSynchronizerAdmin = intentSynchronizer; |
171 | } | 174 | } |
172 | 175 | ||
176 | + @After | ||
177 | + public void tearDown() { | ||
178 | + Intent.unbindIdGenerator(idGenerator); | ||
179 | + } | ||
180 | + | ||
173 | /** | 181 | /** |
174 | * Creates the interface configuration. On devices 1, 2 and 3 is configured | 182 | * Creates the interface configuration. On devices 1, 2 and 3 is configured |
175 | * an interface on port 1 with vlan 1. On devices 4, 5 and 6 is configured | 183 | * an interface on port 1 with vlan 1. On devices 4, 5 and 6 is configured | ... | ... |
-
Please register or login to post a comment