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