e0a332f593f06d6d147cf6446e818f7e9f55e958
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / test / java / org / opendaylight / controller / sal / binding / test / util / BindingBrokerTestFactory.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.sal.binding.test.util;
9
10 import com.google.common.annotations.Beta;
11 import com.google.common.base.Preconditions;
12 import com.google.common.util.concurrent.ListeningExecutorService;
13 import com.google.common.util.concurrent.MoreExecutors;
14 import java.util.concurrent.ExecutorService;
15 import javassist.ClassPool;
16
17 @Beta
18 @Deprecated
19 public class BindingBrokerTestFactory {
20
21     private static final ClassPool CLASS_POOL = ClassPool.getDefault();
22     private boolean startWithParsedSchema = true;
23     private ExecutorService executor;
24     private ClassPool classPool;
25
26
27     public boolean isStartWithParsedSchema() {
28         return startWithParsedSchema;
29     }
30
31     public void setStartWithParsedSchema(final boolean startWithParsedSchema) {
32         this.startWithParsedSchema = startWithParsedSchema;
33     }
34
35     public ExecutorService getExecutor() {
36         return executor;
37     }
38
39     public void setExecutor(final ExecutorService executor) {
40         this.executor = executor;
41     }
42
43     public BindingTestContext getTestContext() {
44         Preconditions.checkState(executor != null, "Executor is not set.");
45         ListeningExecutorService listenableExecutor = MoreExecutors.listeningDecorator(executor);
46         return new BindingTestContext(listenableExecutor, startWithParsedSchema);
47     }
48
49     @Deprecated
50     public ClassPool getClassPool() {
51         if (classPool == null) {
52             return CLASS_POOL;
53         }
54
55         return classPool;
56     }
57
58     @Deprecated
59     public void setClassPool(final ClassPool classPool) {
60         this.classPool = classPool;
61     }
62 }