2b0865ae46e0f01045bf4037a06988a77a057158
[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 org.opendaylight.controller.sal.core.api.data.DataStore;
15 import org.opendaylight.controller.sal.dom.broker.impl.DataStoreStatsWrapper;
16 import org.opendaylight.controller.sal.dom.broker.impl.HashMapDataStore;
17 import org.opendaylight.controller.sal.dom.broker.impl.SchemaAwareDataStoreAdapter;
18
19 import com.google.common.base.Preconditions;
20 import com.google.common.util.concurrent.ListeningExecutorService;
21 import com.google.common.util.concurrent.MoreExecutors;
22
23 public class BindingBrokerTestFactory {
24
25     private static final ClassPool CLASS_POOL = new ClassPool();
26     private boolean startWithParsedSchema = true;
27     private ExecutorService executor;
28     private ClassPool classPool;
29
30     
31     public boolean isStartWithParsedSchema() {
32         return startWithParsedSchema;
33     }
34
35     public void setStartWithParsedSchema(boolean startWithParsedSchema) {
36         this.startWithParsedSchema = startWithParsedSchema;
37     }
38
39     public ExecutorService getExecutor() {
40         return executor;
41     }
42
43     public void setExecutor(ExecutorService executor) {
44         this.executor = executor;
45     }
46
47
48     public BindingTestContext getTestContext() {
49         Preconditions.checkState(executor != null, "Executor is not set.");
50         ListeningExecutorService listenableExecutor = MoreExecutors.listeningDecorator(executor);
51         return new BindingTestContext(listenableExecutor, getClassPool(),startWithParsedSchema);
52     }
53
54     public ClassPool getClassPool() {
55         if(classPool == null) {
56             return CLASS_POOL;
57         }
58         
59         return classPool;
60     }
61
62     public void setClassPool(ClassPool classPool) {
63         this.classPool = classPool;
64     }
65
66 }