Bug 6859 #3 Binding generator v1 refactoring
[mdsal.git] / binding / mdsal-binding-dom-adapter / src / test / java / org / opendaylight / mdsal / binding / dom / adapter / 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.mdsal.binding.dom.adapter.test;
9
10 import org.junit.Before;
11 import org.opendaylight.mdsal.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     private Iterable<YangModuleInfo> moduleInfos;
19     private SchemaContext schemaContext;
20
21
22     protected Iterable<YangModuleInfo> getModuleInfos() throws Exception {
23         return BindingReflections.loadModuleInfos();
24     }
25
26
27     @Before
28     public final void setup() throws Exception {
29         moduleInfos = getModuleInfos();
30         ModuleInfoBackedContext moduleContext = ModuleInfoBackedContext.create();
31         moduleContext.addModuleInfos(moduleInfos);
32         schemaContext = moduleContext.tryToCreateSchemaContext().get();
33         setupWithSchema(schemaContext);
34     }
35
36     /**
37      * Setups test with Schema context.
38      *
39      * @param context schema context
40      */
41     protected abstract void setupWithSchema(SchemaContext context);
42
43 }