Add LogCaptureRule to some component tests, to fail if any errors logged
[genius.git] / itm / itm-impl / src / test / java / org / opendaylight / genius / itm / tests / ItmTest.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.genius.itm.tests;
9
10 import org.junit.After;
11 import org.junit.Before;
12 import org.junit.Rule;
13 import org.junit.Test;
14 import org.junit.rules.MethodRule;
15 import org.opendaylight.genius.itm.impl.ItmTestUtils;
16 import org.opendaylight.genius.utils.cache.CacheTestUtil;
17 import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule;
18 import org.opendaylight.infrautils.testutils.LogCaptureRule;
19 import org.opendaylight.infrautils.testutils.LogRule;
20
21 /**
22  * Component tests for ITM.
23  */
24 public class ItmTest {
25
26     public @Rule LogRule logRule = new LogRule();
27     public @Rule LogCaptureRule logCaptureRule = new LogCaptureRule();
28     public @Rule MethodRule guice = new GuiceRule(ItmTestModule.class);
29
30     @Before
31     public void before() {
32         // so that any @Test methods here which do something real
33         // are isolated from any other test that run before this ItmTest
34         clearCaches();
35     }
36
37     @After
38     public void after() {
39         // so that any other *Test which will run after us has a clean slate again
40         clearCaches();
41     }
42
43     private void clearCaches() {
44         // Explicitly clear stupid static caches
45         // (TODO which really need to be de-static-ified instead of doing this..)
46         ItmTestUtils.clearAllItmCaches();
47         CacheTestUtil.clearAllCaches();
48     }
49
50     @Test
51     public void testWiring() {
52         // do nothing; still valuable to check that ItmTestModule works and everything comes up
53     }
54 }