Migrate OSGI compendium reference
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / test / java / org / opendaylight / controller / md / sal / binding / test / tests / DataBrokerTestModuleTest.java
1 /*
2  * Copyright (c) 2016 Red Hat, Inc. and others. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.md.sal.binding.test.tests;
9
10 import static com.google.common.truth.Truth.assertThat;
11
12 import org.junit.Ignore;
13 import org.junit.Test;
14 import org.opendaylight.controller.md.sal.binding.test.DataBrokerTestModule;
15
16 /**
17  * Integration tests the DataBrokerTestModule.
18  *
19  * @author Michael Vorburger
20  */
21 @Deprecated
22 public class DataBrokerTestModuleTest {
23
24     @Test
25     public void ensureDataBrokerTestModuleWorksWithoutException() {
26         assertThat(DataBrokerTestModule.dataBroker()).isNotNull();
27     }
28
29     @Test
30     @Ignore // This test is flaky on build server VMs (although fine locally)
31     public void slowYangLoadingShouldOnlyHappenOnceAndNotDelayEachDataBroker() {
32         // TODO Write a lil' Timer utility class to make this kind of timing test code more readable
33         long startAtMs = System.currentTimeMillis();
34         DataBrokerTestModule.dataBroker();
35         long firstDataBrokerAtMs = System.currentTimeMillis();
36         long firstDataBrokerDurationMs = firstDataBrokerAtMs - startAtMs;
37         DataBrokerTestModule.dataBroker();
38         long secondDataBrokerDurationMs = System.currentTimeMillis() - firstDataBrokerAtMs;
39         assertThat(Math.abs(secondDataBrokerDurationMs - firstDataBrokerDurationMs))
40                 .isLessThan(firstDataBrokerDurationMs / 4);
41     }
42 }