2 * Copyright (c) 2014 Brocade Communications 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
9 package org.opendaylight.controller.md.sal.dom.store.impl;
11 import com.google.common.util.concurrent.ForwardingExecutorService;
12 import com.google.common.util.concurrent.MoreExecutors;
13 import java.util.concurrent.ExecutorService;
16 * A forwarding Executor used by unit tests for DataChangeListener notifications.
18 * @author Thomas Pantelis
20 public class TestDCLExecutorService extends ForwardingExecutorService {
22 // Start with a same thread executor to avoid timing issues during test setup.
23 private volatile ExecutorService currentExecutor = MoreExecutors.newDirectExecutorService();
25 // The real executor to use when test setup is complete.
26 private final ExecutorService postSetupExecutor;
29 public TestDCLExecutorService(final ExecutorService postSetupExecutor) {
30 this.postSetupExecutor = postSetupExecutor;
34 protected ExecutorService delegate() {
35 return currentExecutor;
38 public void afterTestSetup() {
39 // Test setup complete - switch to the real executor.
40 currentExecutor = postSetupExecutor;