Add missing headers to config, netconf subsystems
[controller.git] / opendaylight / config / threadpool-config-impl / src / test / java / org / opendaylight / controller / config / threadpool / naming / TestingNamingThreadPoolFactoryModule.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.naming;\r
9 \r
10 import static org.mockito.Matchers.any;\r
11 import static org.mockito.Mockito.doNothing;\r
12 import static org.mockito.Mockito.doReturn;\r
13 import static org.mockito.Mockito.mock;\r
14 \r
15 import java.io.Closeable;\r
16 import java.io.IOException;\r
17 \r
18 import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;\r
19 import org.opendaylight.controller.config.api.ModuleIdentifier;\r
20 import org.opendaylight.controller.config.spi.Module;\r
21 import org.opendaylight.controller.config.threadpool.util.NamingThreadPoolFactory;\r
22 import org.opendaylight.controller.config.yang.threadpool.ThreadFactoryServiceInterface;\r
23 import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleMXBean;\r
24 \r
25 public class TestingNamingThreadPoolFactoryModule implements Module, ThreadFactoryServiceInterface,\r
26         NamingThreadFactoryModuleMXBean {\r
27 \r
28     private final NamingThreadPoolFactory fact;\r
29 \r
30     public TestingNamingThreadPoolFactoryModule() throws IOException {\r
31         fact = mock(NamingThreadPoolFactory.class);\r
32         Thread thread = mock(Thread.class);\r
33         doNothing().when(thread).start();\r
34         doReturn(thread).when(fact).newThread(any(Runnable.class));\r
35         doNothing().when(fact).close();\r
36     }\r
37 \r
38     public TestingNamingThreadPoolFactoryModule(DynamicMBeanWithInstance old) {\r
39         fact = (NamingThreadPoolFactory) old.getInstance();\r
40     }\r
41 \r
42     @Override\r
43     public ModuleIdentifier getIdentifier() {\r
44         return new ModuleIdentifier(TestingNamingThreadPoolFactoryModule.class.getCanonicalName(), "mock");\r
45     }\r
46 \r
47     @Override\r
48     public String getNamePrefix() {\r
49         return null;\r
50     }\r
51 \r
52     @Override\r
53     public void setNamePrefix(String arg) {\r
54         throw new UnsupportedOperationException();\r
55     }\r
56 \r
57     @Override\r
58     public void validate() {\r
59     }\r
60 \r
61     @Override\r
62     public Closeable getInstance() {\r
63         return fact;\r
64     }\r
65 \r
66 }\r