2 * Copyright (c) 2022 PANTHEON.tech, s.r.o. 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.mdsal.yanglib.rfc8525;
10 import java.util.ServiceLoader;
11 import org.junit.Before;
12 import org.junit.BeforeClass;
13 import org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTree;
14 import org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTreeFactory;
15 import org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeContext;
16 import org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeGenerator;
17 import org.opendaylight.mdsal.binding.runtime.spi.BindingRuntimeHelpers;
18 import org.opendaylight.yangtools.yang.parser.api.YangParserException;
19 import org.opendaylight.yangtools.yang.parser.api.YangParserFactory;
21 abstract class AbstractYangLibraryTest {
22 private static final BindingRuntimeGenerator BINDING_RUNTIME_GENERATOR =
23 ServiceLoader.load(BindingRuntimeGenerator.class).findFirst().orElseThrow();
24 private static final YangParserFactory YANG_PARSER_FACTORY = ServiceLoader.load(YangParserFactory.class).findFirst()
26 private static final BindingCodecTreeFactory CODEC_FACTORY = ServiceLoader.load(BindingCodecTreeFactory.class)
27 .findFirst().orElseThrow();
29 static BindingRuntimeContext runtimeContext;
30 static BindingCodecTree codecTree;
32 YangLibrarySupport yangLib;
35 public static void beforeClass() {
36 runtimeContext = BindingRuntimeHelpers.createRuntimeContext();
37 codecTree = CODEC_FACTORY.create(runtimeContext);
41 public void before() throws YangParserException {
42 yangLib = new YangLibrarySupport(YANG_PARSER_FACTORY, BINDING_RUNTIME_GENERATOR, CODEC_FACTORY);