Unit test fix - timeout is not correctly set in parallel execution environment

Change-Id: Id3089c45ad217113f9c01c93e2047114b7fbccb4
diff --git a/core/net/src/main/java/org/onosproject/net/flowobjective/impl/InOrderFlowObjectiveManager.java b/core/net/src/main/java/org/onosproject/net/flowobjective/impl/InOrderFlowObjectiveManager.java
index a050e07..48a4d35 100644
--- a/core/net/src/main/java/org/onosproject/net/flowobjective/impl/InOrderFlowObjectiveManager.java
+++ b/core/net/src/main/java/org/onosproject/net/flowobjective/impl/InOrderFlowObjectiveManager.java
@@ -64,7 +64,8 @@
     private final Logger log = LoggerFactory.getLogger(getClass());
 
     // TODO Make queue timeout configurable
-    static int objTimeoutMs = 15000;
+    static final int DEFAULT_OBJ_TIMEOUT = 15000;
+    int objTimeoutMs = DEFAULT_OBJ_TIMEOUT;
 
     private Cache<FilteringObjQueueKey, Objective> filtObjQueueHead;
     private Cache<ForwardingObjQueueKey, Objective> fwdObjQueueHead;
diff --git a/core/net/src/test/java/org/onosproject/net/flowobjective/impl/InOrderFlowObjectiveManagerTest.java b/core/net/src/test/java/org/onosproject/net/flowobjective/impl/InOrderFlowObjectiveManagerTest.java
index 94096b5..44cd39f 100644
--- a/core/net/src/test/java/org/onosproject/net/flowobjective/impl/InOrderFlowObjectiveManagerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/flowobjective/impl/InOrderFlowObjectiveManagerTest.java
@@ -98,7 +98,7 @@
     // Delay flow objectives OFFSET + rand(0, BOUND) millis
     private static final int DEFAULT_OFFSET = 10; // ms
     private static final int DEFAULT_BOUND = 40; // ms
-    private static final int TIMEOUT_THRESH = 100; // ms
+    private static final int TIMEOUT_THRESH = 500; // ms
     private static int offset = DEFAULT_OFFSET;
     private static int bound = DEFAULT_BOUND;
 
@@ -184,7 +184,12 @@
 
     @Before
     public void setUp() {
+        internalSetup(InOrderFlowObjectiveManager.DEFAULT_OBJ_TIMEOUT);
+    }
+
+    private void internalSetup(int objTimeoutMs) {
         mgr = new InOrderFlowObjectiveManager();
+        mgr.objTimeoutMs = objTimeoutMs;
         mgr.pipeliners.put(DEV1, pipeliner);
         mgr.executorService = newFixedThreadPool(4, groupedThreads("foo", "bar"));
         mgr.cfgService = createMock(ComponentConfigService.class);
@@ -249,15 +254,14 @@
                 Lists.newArrayList(fwdTimeout, FWD1, FWD2));
 
         // Reduce timeout so the unit test doesn't have to wait many seconds
-        InOrderFlowObjectiveManager.objTimeoutMs = TIMEOUT_THRESH;
-        setUp();
+        internalSetup(TIMEOUT_THRESH);
 
         expect(mgr.flowObjectiveStore.getNextGroup(NID1)).andReturn(NGRP1).times(1);
         expect(mgr.flowObjectiveStore.getNextGroup(NID2)).andReturn(NGRP2).times(2);
         replay(mgr.flowObjectiveStore);
 
         // Force this objective to time out
-        offset = InOrderFlowObjectiveManager.objTimeoutMs * 2;
+        offset = mgr.objTimeoutMs * 2;
 
         expectFwdObjsTimeout.forEach(fwdObj -> mgr.forward(DEV1, fwdObj));
 
@@ -265,7 +269,7 @@
         int expectedTime = (bound + offset) * 3;
         assertAfter(expectedTime, expectedTime * 5, () -> assertEquals(expectFwdObjsTimeout.size(), actualObjs.size()));
 
-        assertTrue(counter.get() != 0);
+        assertAfter(expectedTime, expectedTime * 5, () -> assertTrue(counter.get() != 0));
         assertTrue(actualObjs.indexOf(fwdTimeout) < actualObjs.indexOf(FWD1));
 
         verify(mgr.flowObjectiveStore);