Fix checkstyle violations in sal-binding-broker
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / test / java / org / opendaylight / controller / md / sal / binding / test / tests / DataBrokerTestModuleTest.java
index 20160131bcc2949b5e5d2c1a9119083c515af447..4fbb8510110bfa8ace307b7f1ae8f18c428d8d55 100644 (file)
@@ -9,13 +9,33 @@ package org.opendaylight.controller.md.sal.binding.test.tests;
 
 import static com.google.common.truth.Truth.assertThat;
 
+import org.junit.Ignore;
 import org.junit.Test;
 import org.opendaylight.controller.md.sal.binding.test.DataBrokerTestModule;
 
+/**
+ * Integration tests the DataBrokerTestModule.
+ *
+ * @author Michael Vorburger
+ */
 public class DataBrokerTestModuleTest {
 
     @Test
     public void ensureDataBrokerTestModuleWorksWithoutException() {
         assertThat(DataBrokerTestModule.dataBroker()).isNotNull();
     }
+
+    @Test
+    @Ignore // This test is flaky on build server VMs (although fine locally)
+    public void slowYangLoadingShouldOnlyHappenOnceAndNotDelayEachDataBroker() {
+        // TODO Write a lil' Timer utility class to make this kind of timing test code more readable
+        long startAtMs = System.currentTimeMillis();
+        DataBrokerTestModule.dataBroker();
+        long firstDataBrokerAtMs = System.currentTimeMillis();
+        long firstDataBrokerDurationMs = firstDataBrokerAtMs - startAtMs;
+        DataBrokerTestModule.dataBroker();
+        long secondDataBrokerDurationMs = System.currentTimeMillis() - firstDataBrokerAtMs;
+        assertThat(Math.abs(secondDataBrokerDurationMs - firstDataBrokerDurationMs))
+                .isLessThan(firstDataBrokerDurationMs / 4);
+    }
 }