Cleanup imports/whitespace in MD-SAL
[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 java.util.concurrent.ExecutorService;
11
12 import javassist.ClassPool;
13
14 import com.google.common.base.Preconditions;
15 import com.google.common.util.concurrent.ListeningExecutorService;
16 import com.google.common.util.concurrent.MoreExecutors;
17
18 public class BindingBrokerTestFactory {
19
20     private static final ClassPool CLASS_POOL = new ClassPool();
21     private boolean startWithParsedSchema = true;
22     private ExecutorService executor;
23     private ClassPool classPool;
24
25
26     public boolean isStartWithParsedSchema() {
27         return startWithParsedSchema;
28     }
29
30     public void setStartWithParsedSchema(boolean startWithParsedSchema) {
31         this.startWithParsedSchema = startWithParsedSchema;
32     }
33
34     public ExecutorService getExecutor() {
35         return executor;
36     }
37
38     public void setExecutor(ExecutorService executor) {
39         this.executor = executor;
40     }
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, getClassPool(),startWithParsedSchema);
47     }
48
49     public ClassPool getClassPool() {
50         if(classPool == null) {
51             return CLASS_POOL;
52         }
53
54         return classPool;
55     }
56
57     public void setClassPool(ClassPool classPool) {
58         this.classPool = classPool;
59     }
60
61 }