2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.md.sal.binding.test;
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;
16 public abstract class AbstractSchemaAwareTest {
18 protected Iterable<YangModuleInfo> getModuleInfos() throws Exception {
19 return BindingReflections.loadModuleInfos();
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();
30 public final void setup() throws Exception {
31 setupWithSchema(getSchemaContext());
35 * Setups test with Schema context.
36 * This method is called before {@link #setupWithSchemaService(SchemaService)}
38 protected abstract void setupWithSchema(SchemaContext context);