2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.config.threadpool.naming;
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;
15 import java.io.Closeable;
16 import java.io.IOException;
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;
25 public class TestingNamingThreadPoolFactoryModule implements Module, ThreadFactoryServiceInterface,
26 NamingThreadFactoryModuleMXBean {
28 private final NamingThreadPoolFactory fact;
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();
38 public TestingNamingThreadPoolFactoryModule(DynamicMBeanWithInstance old) {
39 fact = (NamingThreadPoolFactory) old.getInstance();
43 public ModuleIdentifier getIdentifier() {
44 return new ModuleIdentifier(TestingNamingThreadPoolFactoryModule.class.getCanonicalName(), "mock");
48 public String getNamePrefix() {
53 public void setNamePrefix(String arg) {
54 throw new UnsupportedOperationException();
58 public void validate() {
62 public Closeable getInstance() {