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;
12 import static org.junit.Assert.assertTrue;
13 import static org.junit.Assert.fail;
15 import org.junit.Test;
16 import org.opendaylight.yangtools.concepts.SemVer;
17 import org.opendaylight.yangtools.yang.common.XMLNamespace;
18 import org.opendaylight.yangtools.yang.model.api.Module;
19 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
20 import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
22 import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
24 public class OpenconfigVersionImportTest {
27 public void importValidTest() throws Exception {
28 SchemaContext context = StmtTestUtils.parseYangSources("/openconfig-version/import/import-valid",
29 StatementParserMode.SEMVER_MODE);
30 assertNotNull(context);
32 Module semVer = context.findModules(XMLNamespace.of("http://openconfig.net/yang/openconfig-ext"))
35 assertEquals(SemVer.valueOf("1.0.0"), semVer.getSemanticVersion().get());
39 public void importInvalidDeprecatedTest1() throws Exception {
41 StmtTestUtils.parseYangSources("/openconfig-version/import/import-invalid-deprecated-1",
42 StatementParserMode.SEMVER_MODE);
43 fail("Test should fail due to invalid import of openconfig-version module");
44 } catch (ReactorException e) {
45 assertTrue(e.getCause().getCause().getMessage().startsWith(
46 "Unable to find module compatible with requested import [openconfig-extensions(1.0.0)]."));
51 public void importInvalidDeprecatedTest2() throws Exception {
53 StmtTestUtils.parseYangSources("/openconfig-version/import/import-invalid-deprecated-2",
54 StatementParserMode.SEMVER_MODE);
55 fail("Test should fail due to invalid import of openconfig-version module");
56 } catch (ReactorException e) {
57 assertTrue(e.getCause().getCause().getMessage().startsWith(
58 "Unable to find module compatible with requested import [openconfig-extensions(0.9.9)]."));
63 public void importInvalidNotsufficientTest1() throws Exception {
65 StmtTestUtils.parseYangSources("/openconfig-version/import/import-invalid-notsufficient-1",
66 StatementParserMode.SEMVER_MODE);
67 fail("Test should fail due to invalid import of openconfig-version module");
68 } catch (ReactorException e) {
69 assertTrue(e.getCause().getCause().getMessage().startsWith(
70 "Unable to find module compatible with requested import [openconfig-extensions(2.0.0)]."));
75 public void importInvalidNotsufficientTest2() throws Exception {
77 StmtTestUtils.parseYangSources("/openconfig-version/import/import-invalid-notsufficient-2",
78 StatementParserMode.SEMVER_MODE);
79 fail("Test should fail due to invalid import of openconfig-version module");
80 } catch (ReactorException e) {
81 assertTrue(e.getCause().getCause().getMessage().startsWith(
82 "Unable to find module compatible with requested import [openconfig-extensions(2.0.5)]."));