aebe05dd038f891c83d5a766b5be09f89eef9946
[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.mdsal.binding.generator.impl.ModuleInfoBackedContext;
12 import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
13 import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
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         final Iterable<YangModuleInfo> moduleInfos = getModuleInfos();
24         final 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 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.