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;
10 import static org.hamcrest.CoreMatchers.allOf;
11 import static org.hamcrest.CoreMatchers.containsString;
12 import static org.hamcrest.CoreMatchers.startsWith;
14 import org.junit.jupiter.api.Test;
16 class ImportResolutionBasicTest extends AbstractYangTest {
17 private static final String ROOT_WITHOUT_IMPORT = "/semantic-statement-parser/import-arg-parsing/nature.yang";
18 private static final String IMPORT_ROOT = "/semantic-statement-parser/import-arg-parsing/mammal.yang";
19 private static final String IMPORT_DERIVED = "/semantic-statement-parser/import-arg-parsing/human.yang";
22 void inImportOrderTest() {
23 assertEffectiveModel(ROOT_WITHOUT_IMPORT, IMPORT_ROOT, IMPORT_DERIVED);
27 void inInverseOfImportOrderTest() {
28 assertEffectiveModel(IMPORT_DERIVED, IMPORT_ROOT, ROOT_WITHOUT_IMPORT);
32 void missingImportedSourceTest() {
33 assertFailedPreLinkage("mammal", IMPORT_DERIVED, ROOT_WITHOUT_IMPORT);
37 void circularImportsTest() {
38 assertFailedPreLinkage("cycle-",
39 "/semantic-statement-parser/import-arg-parsing/cycle-yin.yang",
40 "/semantic-statement-parser/import-arg-parsing/cycle-yang.yang");
44 void selfImportTest() {
45 assertFailedPreLinkage("egocentric",
46 "/semantic-statement-parser/import-arg-parsing/egocentric.yang", IMPORT_ROOT, ROOT_WITHOUT_IMPORT);
52 "/semantic-statement-parser/bug2649/foo.yang",
53 "/semantic-statement-parser/bug2649/import-module.yang");
56 private static void assertFailedPreLinkage(final String name, final String... sources) {
57 assertInferenceException(allOf(
58 startsWith("Imported module [" + name),
59 containsString("] was not found. [at ")),