Merge "Fixed for bug 1168 : Issue while update subnet"
[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.annotations.Beta;
15 import com.google.common.base.Preconditions;
16 import com.google.common.util.concurrent.ListeningExecutorService;
17 import com.google.common.util.concurrent.MoreExecutors;
18
19 @Beta
20 public class BindingBrokerTestFactory {
21
22     private static final ClassPool CLASS_POOL = ClassPool.getDefault();
23     private boolean startWithParsedSchema = true;
24     private ExecutorService executor;
25     private ClassPool classPool;
26
27
28     public boolean isStartWithParsedSchema() {
29         return startWithParsedSchema;
30     }
31
32     public void setStartWithParsedSchema(final boolean startWithParsedSchema) {
33         this.startWithParsedSchema = startWithParsedSchema;
34     }
35
36     public ExecutorService getExecutor() {
37         return executor;
38     }
39
40     public void setExecutor(final ExecutorService executor) {
41         this.executor = executor;
42     }
43
44
45     public BindingTestContext getTestContext() {
46         Preconditions.checkState(executor != null, "Executor is not set.");
47         ListeningExecutorService listenableExecutor = MoreExecutors.listeningDecorator(executor);
48         return new BindingTestContext(listenableExecutor, getClassPool(),startWithParsedSchema);
49     }
50
51     public ClassPool getClassPool() {
52         if(classPool == null) {
53             return CLASS_POOL;
54         }
55
56         return classPool;
57     }
58
59     public void setClassPool(final ClassPool classPool) {
60         this.classPool = classPool;
61     }
62
63 }