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 java.util.concurrent.ExecutorService;
13 import com.google.common.util.concurrent.ForwardingExecutorService;
14 import com.google.common.util.concurrent.MoreExecutors;
17 * A forwarding Executor used by unit tests for DataChangeListener notifications
19 * @author Thomas Pantelis
21 public class TestDCLExecutorService extends ForwardingExecutorService {
23 // Start with a same thread executor to avoid timing issues during test setup.
24 private volatile ExecutorService currentExecutor = MoreExecutors.sameThreadExecutor();
26 // The real executor to use when test setup is complete.
27 private final ExecutorService postSetupExecutor;
30 public TestDCLExecutorService( ExecutorService postSetupExecutor ) {
31 this.postSetupExecutor = postSetupExecutor;
35 protected ExecutorService delegate() {
36 return currentExecutor;
39 public void afterTestSetup() {
40 // Test setup complete - switch to the real executor.
41 currentExecutor = postSetupExecutor;