BUG-2637: migration consequence - fix unit test
[controller.git] / opendaylight / md-sal / forwardingrules-manager / src / test / java / test / mock / util / 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 test.mock.util;
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     private Iterable<YangModuleInfo> moduleInfos;
19     private SchemaContext schemaContext;
20
21
22     protected Iterable<YangModuleInfo> getModuleInfos() {
23         return BindingReflections.loadModuleInfos();
24     }
25
26
27     @Before
28     public final void setup() {
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      * This method is called before {@link #setupWithSchemaService(SchemaService)}
39      *
40      * @param context
41      */
42     protected abstract void setupWithSchema(SchemaContext context);
43
44 }