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 org.junit.Test;
16 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
17 import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
18 import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
20 public class Bug6867BasicTest {
23 public void valid10Test() throws Exception {
24 final SchemaContext schemaContext = StmtTestUtils.parseYangSource("/rfc7950/basic-test/valid-10.yang");
25 assertNotNull(schemaContext);
29 public void valid11Test() throws Exception {
30 final SchemaContext schemaContext = StmtTestUtils.parseYangSource("/rfc7950/basic-test/valid-11.yang");
31 assertNotNull(schemaContext);
35 public void invalid10Test() throws Exception {
37 StmtTestUtils.parseYangSource("/rfc7950/basic-test/invalid-10.yang");
38 fail("Test should fail due to invalid Yang 1.0");
39 } catch (final SomeModifiersUnresolvedException e) {
40 assertTrue(e.getCause().getMessage().startsWith("NOTIFICATION is not valid for CONTAINER"));
45 public void invalid11Test() throws Exception {
47 StmtTestUtils.parseYangSource("/rfc7950/basic-test/invalid-11.yang");
48 fail("Test should fail due to invalid Yang 1.1");
49 } catch (final SomeModifiersUnresolvedException e) {
50 assertTrue(e.getCause().getMessage().startsWith("RPC is not valid for CONTAINER"));
55 public void anyData11Test() throws Exception {
56 final SchemaContext schemaContext = StmtTestUtils.parseYangSource("/rfc7950/basic-test/anydata-11.yang");
57 assertNotNull(schemaContext);
61 public void anyData10Test() throws Exception {
63 StmtTestUtils.parseYangSource("/rfc7950/basic-test/anydata-10.yang");
64 fail("Test should fail due to invalid Yang 1.0");
65 } catch (final SomeModifiersUnresolvedException e) {
66 assertTrue(e.getCause().getMessage().startsWith("anydata is not a YANG statement or use of extension"));
71 public void yangModelTest() throws Exception {
72 final SchemaContext schemaContext = StmtTestUtils.parseYangSources("/rfc7950/model");
73 assertNotNull(schemaContext);
77 public void unsupportedVersionTest() throws Exception {
79 StmtTestUtils.parseYangSource("/rfc7950/basic-test/unsupported-version.yang");
80 fail("Test should fail due to unsupported Yang version");
81 } catch (final SomeModifiersUnresolvedException e) {
82 final Throwable cause = e.getCause();
84 assertTrue(cause.getMessage().startsWith("Unsupported YANG version 2.3"));