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;
17 import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
18 import org.opendaylight.controller.config.api.ModuleIdentifier;
19 import org.opendaylight.controller.config.spi.Module;
20 import org.opendaylight.controller.config.threadpool.util.NamingThreadPoolFactory;
21 import org.opendaylight.controller.config.yang.threadpool.ThreadFactoryServiceInterface;
22 import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleMXBean;
24 public class TestingNamingThreadPoolFactoryModule implements Module, ThreadFactoryServiceInterface,
25 NamingThreadFactoryModuleMXBean {
27 private final NamingThreadPoolFactory fact;
29 public TestingNamingThreadPoolFactoryModule() throws IOException {
30 fact = mock(NamingThreadPoolFactory.class);
31 Thread thread = mock(Thread.class);
32 doNothing().when(thread).start();
33 doReturn(thread).when(fact).newThread(any(Runnable.class));
34 doNothing().when(fact).close();
37 public TestingNamingThreadPoolFactoryModule(DynamicMBeanWithInstance old) {
38 fact = (NamingThreadPoolFactory) old.getInstance();
42 public ModuleIdentifier getIdentifier() {
43 return new ModuleIdentifier(TestingNamingThreadPoolFactoryModule.class.getCanonicalName(), "mock");
47 public String getNamePrefix() {
52 public void setNamePrefix(String arg) {
53 throw new UnsupportedOperationException();
57 public void validate() {
61 public Closeable getInstance() {