Merge "Fix for Bug 3"
[controller.git] / opendaylight / config / threadpool-config-impl / src / test / java / org / opendaylight / controller / config / threadpool / fixed / TestingFixedThreadPoolModule.java
1 /*\r
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 package org.opendaylight.controller.config.threadpool.fixed;\r
9 \r
10 import static org.mockito.Mockito.doNothing;\r
11 import static org.mockito.Mockito.doReturn;\r
12 import static org.mockito.Mockito.mock;\r
13 \r
14 import java.util.concurrent.ExecutorService;\r
15 \r
16 import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;\r
17 import org.opendaylight.controller.config.api.ModuleIdentifier;\r
18 import org.opendaylight.controller.config.manager.impl.AbstractMockedModule;\r
19 import org.opendaylight.controller.config.spi.Module;\r
20 import org.opendaylight.controller.config.threadpool.util.FixedThreadPoolWrapper;\r
21 import org.opendaylight.controller.config.yang.threadpool.ThreadPoolServiceInterface;\r
22 \r
23 public class TestingFixedThreadPoolModule extends AbstractMockedModule implements ThreadPoolServiceInterface, Module {\r
24 \r
25     public TestingFixedThreadPoolModule(DynamicMBeanWithInstance old, ModuleIdentifier id) {\r
26         super(old, id);\r
27     }\r
28 \r
29     @Override\r
30     protected AutoCloseable prepareMockedInstance() throws Exception {\r
31         FixedThreadPoolWrapper pool = mock(FixedThreadPoolWrapper.class);\r
32         doNothing().when(pool).close();\r
33         doReturn(mock(ExecutorService.class)).when(pool).getExecutor();\r
34         return pool;\r
35     }\r
36 \r
37 }\r