BUG-4328: TransactionChainManager state
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / karaf / AbstractKarafTest.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, 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
9 package org.opendaylight.openflowplugin.impl.karaf;
10
11 import com.google.common.base.Function;
12 import java.io.PrintStream;
13 import java.util.List;
14 import org.apache.felix.service.command.CommandSession;
15 import org.junit.Before;
16 import org.junit.runner.RunWith;
17 import org.mockito.Mock;
18 import org.mockito.Mockito;
19 import org.mockito.runners.MockitoJUnitRunner;
20
21 /**
22  * Created by mirehak on 7/29/15.
23  */
24 @RunWith(MockitoJUnitRunner.class)
25 public abstract class AbstractKarafTest {
26     @Mock
27     protected CommandSession cmdSession;
28     @Mock
29     protected PrintStream console;
30
31     @Before
32     public void setUp() {
33         Mockito.when(cmdSession.getConsole()).thenReturn(console);
34         doSetUp();
35     }
36
37     public abstract void doSetUp();
38
39     public static boolean checkNoActivity(List<String> allStatLines, Function<String, Boolean> checkFunction) {
40         boolean noActivity = true;
41         for (String statLine : allStatLines) {
42             noActivity &= checkFunction.apply(statLine);
43         }
44         return noActivity;
45     }
46 }