ConstantSchemaAbstractDataBrokerTest, faster than AbstractDataBrokerTest
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / test / java / org / opendaylight / controller / md / sal / binding / test / AbstractSchemaAwareTest.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.md.sal.binding.test;
9
10 import org.junit.Before;
11 import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext;
12 import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
13 import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
14 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
15
16 public abstract class AbstractSchemaAwareTest  {
17
18     protected Iterable<YangModuleInfo> getModuleInfos() throws Exception {
19         return BindingReflections.loadModuleInfos();
20     }
21
22     protected SchemaContext getSchemaContext() throws Exception {
23         Iterable<YangModuleInfo> moduleInfos = getModuleInfos();
24         ModuleInfoBackedContext moduleContext = ModuleInfoBackedContext.create();
25         moduleContext.addModuleInfos(moduleInfos);
26         return moduleContext.tryToCreateSchemaContext().get();
27     }
28
29     @Before
30     public final void setup() throws Exception {
31         setupWithSchema(getSchemaContext());
32     }
33
34     /**
35      * Setups test with Schema context.
36      * This method is called before {@link #setupWithSchemaService(SchemaService)}
37      */
38     protected abstract void setupWithSchema(SchemaContext context);
39
40 }