3a0fff17c6aeed44aeb3fc45f1a0f25a9a272993
[mdsal.git] / yanglib / mdsal-yanglib-rfc8525 / src / test / java / org / opendaylight / mdsal / yanglib / rfc8525 / AbstractYangLibraryTest.java
1 /*
2  * Copyright (c) 2022 PANTHEON.tech, s.r.o. 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.yanglib.rfc8525;
9
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;
20
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()
25         .orElseThrow();
26     private static final BindingCodecTreeFactory CODEC_FACTORY = ServiceLoader.load(BindingCodecTreeFactory.class)
27         .findFirst().orElseThrow();
28
29     static BindingRuntimeContext runtimeContext;
30     static BindingCodecTree codecTree;
31
32     YangLibrarySupport yangLib;
33
34     @BeforeClass
35     public static void beforeClass() {
36         runtimeContext = BindingRuntimeHelpers.createRuntimeContext();
37         codecTree = CODEC_FACTORY.create(runtimeContext);
38     }
39
40     @Before
41     public void before() throws YangParserException {
42         yangLib = new YangLibrarySupport(YANG_PARSER_FACTORY, BINDING_RUNTIME_GENERATOR, CODEC_FACTORY);
43     }
44 }