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.model.repo.api.StatementParserMode;
19 import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
21 public class OpenconfigVersionIgnoringRevisionTest {
24 public void ignoringRevisionTest() throws Exception {
25 SchemaContext context = StmtTestUtils.parseYangSources("/openconfig-version/ignoring-revision",
26 StatementParserMode.SEMVER_MODE);
27 assertNotNull(context);
29 Module foo = context.findModules(XMLNamespace.of("foo")).iterator().next();
30 Module bar = context.findModules(XMLNamespace.of("bar")).iterator().next();
31 Module semVer = context.findModules(XMLNamespace.of("http://openconfig.net/yang/openconfig-ext"))
34 assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion().get());
35 assertEquals(SemVer.valueOf("0.1.1"), foo.getSemanticVersion().get());
36 assertEquals(SemVer.valueOf("0.1.2"), bar.getSemanticVersion().get());
40 public void ignoringRevision2Test() throws Exception {
41 SchemaContext context = StmtTestUtils.parseYangSources("/openconfig-version/ignoring-revision-2",
42 StatementParserMode.SEMVER_MODE);
43 assertNotNull(context);
45 Module foo = context.findModules(XMLNamespace.of("foo")).iterator().next();
46 Module semVer = context.findModules(XMLNamespace.of("http://openconfig.net/yang/openconfig-ext"))
48 Module bar = StmtTestUtils.findImportedModule(context, foo, "bar");
50 assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion().get());
51 assertEquals(SemVer.valueOf("0.1.1"), foo.getSemanticVersion().get());
52 assertEquals(SemVer.valueOf("0.1.2"), bar.getSemanticVersion().get());