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
8 package org.opendaylight.mdsal.dom.store.inmemory;
10 import com.google.common.util.concurrent.ForwardingExecutorService;
11 import com.google.common.util.concurrent.MoreExecutors;
12 import java.util.concurrent.ExecutorService;
15 * A forwarding Executor used by unit tests for DataChangeListener notifications.
17 * @author Thomas Pantelis
19 public class TestDCLExecutorService extends ForwardingExecutorService {
21 // Start with a same thread executor to avoid timing issues during test setup.
22 private volatile ExecutorService currentExecutor = MoreExecutors.newDirectExecutorService();
24 // The real executor to use when test setup is complete.
25 private final ExecutorService postSetupExecutor;
28 public TestDCLExecutorService(final ExecutorService postSetupExecutor) {
29 this.postSetupExecutor = postSetupExecutor;
33 protected ExecutorService delegate() {
34 return currentExecutor;
37 public void afterTestSetup() {
38 // Test setup complete - switch to the real executor.
39 currentExecutor = postSetupExecutor;