2 * Copyright (c) 2016 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.yangtools.yang.stmt.openconfigver;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
13 import org.junit.Test;
14 import org.opendaylight.yangtools.concepts.SemVer;
15 import org.opendaylight.yangtools.yang.common.XMLNamespace;
16 import org.opendaylight.yangtools.yang.model.api.Module;
17 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
18 import org.opendaylight.yangtools.yang.parser.api.ImportResolutionMode;
19 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
20 import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
22 @Deprecated(since = "8.0.4", forRemoval = true)
23 public class OpenconfigVersionIgnoringRevisionTest {
24 private static final YangParserConfiguration SEMVER = YangParserConfiguration.builder()
25 .importResolutionMode(ImportResolutionMode.OPENCONFIG_SEMVER)
29 public void ignoringRevisionTest() throws Exception {
30 SchemaContext context = StmtTestUtils.parseYangSources("/openconfig-version/ignoring-revision", SEMVER);
31 assertNotNull(context);
33 Module foo = context.findModules(XMLNamespace.of("foo")).iterator().next();
34 Module bar = context.findModules(XMLNamespace.of("bar")).iterator().next();
35 Module semVer = context.findModules(XMLNamespace.of("http://openconfig.net/yang/openconfig-ext"))
38 assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion().get());
39 assertEquals(SemVer.valueOf("0.1.1"), foo.getSemanticVersion().get());
40 assertEquals(SemVer.valueOf("0.1.2"), bar.getSemanticVersion().get());
44 public void ignoringRevision2Test() throws Exception {
45 SchemaContext context = StmtTestUtils.parseYangSources("/openconfig-version/ignoring-revision-2", SEMVER);
46 assertNotNull(context);
48 Module foo = context.findModules(XMLNamespace.of("foo")).iterator().next();
49 Module semVer = context.findModules(XMLNamespace.of("http://openconfig.net/yang/openconfig-ext"))
51 Module bar = StmtTestUtils.findImportedModule(context, foo, "bar");
53 assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion().get());
54 assertEquals(SemVer.valueOf("0.1.1"), foo.getSemanticVersion().get());
55 assertEquals(SemVer.valueOf("0.1.2"), bar.getSemanticVersion().get());