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
9 package org.opendaylight.yangtools.yang.parser.stmt.rfc7950;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertTrue;
13 import static org.junit.Assert.fail;
15 import java.io.FileNotFoundException;
16 import java.net.URISyntaxException;
17 import org.junit.Test;
18 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
19 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
21 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
22 import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
24 public class Bug6867BasicTest {
27 public void valid10Test() throws ReactorException, SourceException, FileNotFoundException, URISyntaxException {
28 final SchemaContext schemaContext = StmtTestUtils.parseYangSource("/rfc7950/basic-test/valid-10.yang");
29 assertNotNull(schemaContext);
33 public void valid11Test() throws ReactorException, SourceException, FileNotFoundException, URISyntaxException {
34 final SchemaContext schemaContext = StmtTestUtils.parseYangSource("/rfc7950/basic-test/valid-11.yang");
35 assertNotNull(schemaContext);
39 public void invalid10Test() throws ReactorException, SourceException, FileNotFoundException, URISyntaxException {
41 StmtTestUtils.parseYangSource("/rfc7950/basic-test/invalid-10.yang");
42 fail("Test should fail due to invalid Yang 1.0");
43 } catch (final SomeModifiersUnresolvedException e) {
44 assertTrue(e.getCause().getMessage().startsWith("NOTIFICATION is not valid for CONTAINER"));
49 public void invalid11Test() throws ReactorException, SourceException, FileNotFoundException, URISyntaxException {
51 StmtTestUtils.parseYangSource("/rfc7950/basic-test/invalid-11.yang");
52 fail("Test should fail due to invalid Yang 1.1");
53 } catch (final SomeModifiersUnresolvedException e) {
54 assertTrue(e.getCause().getMessage().startsWith("RPC is not valid for CONTAINER"));
59 public void anyData11Test() throws ReactorException, SourceException, FileNotFoundException, URISyntaxException {
60 final SchemaContext schemaContext = StmtTestUtils.parseYangSource("/rfc7950/basic-test/anydata-11.yang");
61 assertNotNull(schemaContext);
65 public void anyData10Test() throws ReactorException, SourceException, FileNotFoundException, URISyntaxException {
67 StmtTestUtils.parseYangSource("/rfc7950/basic-test/anydata-10.yang");
68 fail("Test should fail due to invalid Yang 1.0");
69 } catch (final SomeModifiersUnresolvedException e) {
70 assertTrue(e.getCause().getMessage().startsWith("anydata is not a YANG statement or use of extension"));
75 public void yangModelTest() throws ReactorException, SourceException, FileNotFoundException, URISyntaxException {
76 final SchemaContext schemaContext = StmtTestUtils.parseYangSources("/rfc7950/model");
77 assertNotNull(schemaContext);
81 public void unsupportedVersionTest() throws ReactorException, SourceException, FileNotFoundException,
84 StmtTestUtils.parseYangSource("/rfc7950/basic-test/unsupported-version.yang");
85 fail("Test should fail due to unsupported Yang version");
86 } catch (final SomeModifiersUnresolvedException e) {
87 final Throwable cause = e.getCause();
89 assertTrue(cause.getMessage().startsWith("Unsupported YANG version 2.3"));