2 * Copyright (c) 2015 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
9 package org.opendaylight.yangtools.yang.stmt.test;
11 import static org.junit.Assert.assertNotNull;
13 import org.junit.Test;
14 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
15 import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
16 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
17 import org.opendaylight.yangtools.yang.parser.stmt.reactor.EffectiveModelContext;
18 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
19 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
21 public class ImportRevisionsTest {
23 private static final YangStatementSourceImpl ROOT_WITH_EQUAL_DATE = new YangStatementSourceImpl
24 ("/import-revision-date-test/root-with-equal-revision-date.yang", false);
25 private static final YangStatementSourceImpl IMPORTED_WITH_EQUAL_DATE = new YangStatementSourceImpl
26 ("/import-revision-date-test/imported-module-with-equal-revision-date.yang", false);
27 private static final YangStatementSourceImpl ROOT_WITH_UNEQUAL_DATE = new YangStatementSourceImpl
28 ("/import-revision-date-test/root-with-unequal-revision-date.yang", false);
29 private static final YangStatementSourceImpl IMPORTED_WITH_UNEQUAL_DATE = new YangStatementSourceImpl
30 ("/import-revision-date-test/imported-module-with-unequal-revision-date.yang", false);
31 private static final YangStatementSourceImpl ROOT_WITH_DATE = new YangStatementSourceImpl
32 ("/import-revision-date-test/root-with-revision-date.yang", false);
33 private static final YangStatementSourceImpl IMPORTED_WITHOUT_DATE = new YangStatementSourceImpl
34 ("/import-revision-date-test/imported-module-without-revision-date.yang", false);
35 private static final YangStatementSourceImpl ROOT_WITHOUT_DATE = new YangStatementSourceImpl
36 ("/import-revision-date-test/root-without-revision-date.yang", false);
37 private static final YangStatementSourceImpl IMPORTED_WITH_DATE = new YangStatementSourceImpl
38 ("/import-revision-date-test/imported-module-with-revision-date.yang", false);
39 private static final YangStatementSourceImpl ROOT_WITH_1970_DATE = new YangStatementSourceImpl
40 ("/import-revision-date-test/root-with-1970-revision-date.yang", false);
41 private static final YangStatementSourceImpl ROOT_WITH_NO_DATE = new YangStatementSourceImpl
42 ("/import-revision-date-test/root-with-no-revision-date.yang", false);
43 private static final YangStatementSourceImpl IMPORTED_WITH_NO_DATE = new YangStatementSourceImpl
44 ("/import-revision-date-test/imported-module-with-no-revision-date.yang", false);
47 public void equalRevisionDatesTest() throws ReactorException {
48 CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
49 StmtTestUtils.addSources(reactor, ROOT_WITH_EQUAL_DATE, IMPORTED_WITH_EQUAL_DATE);
51 EffectiveModelContext result = reactor.build();
52 assertNotNull(result);
55 @Test(expected = SomeModifiersUnresolvedException.class)
56 public void unequalRevisionDatesTest() throws ReactorException {
57 CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
58 StmtTestUtils.addSources(reactor, ROOT_WITH_UNEQUAL_DATE, IMPORTED_WITH_UNEQUAL_DATE);
60 EffectiveModelContext result = reactor.build();
61 assertNotNull(result);
65 @Test(expected = SomeModifiersUnresolvedException.class)
66 public void revisionDatesInRootOnlyTest() throws ReactorException {
67 CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
68 StmtTestUtils.addSources(reactor, ROOT_WITH_DATE, IMPORTED_WITHOUT_DATE);
70 EffectiveModelContext result = reactor.build();
71 assertNotNull(result);
75 public void revisionDatesInImportedOnlyTest() throws ReactorException {
76 CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
77 StmtTestUtils.addSources(reactor, ROOT_WITHOUT_DATE, IMPORTED_WITH_DATE);
79 EffectiveModelContext result = reactor.build();
80 assertNotNull(result);
84 public void revision1970InRootOnlyTest() throws ReactorException {
85 CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
86 StmtTestUtils.addSources(reactor, ROOT_WITH_1970_DATE, IMPORTED_WITHOUT_DATE);
88 EffectiveModelContext result = reactor.build();
89 assertNotNull(result);
93 public void noRevisionInRootAndImportedTest() throws ReactorException {
94 CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
95 StmtTestUtils.addSources(reactor, ROOT_WITH_NO_DATE, IMPORTED_WITH_NO_DATE);
97 EffectiveModelContext result = reactor.build();
98 assertNotNull(result);