2 * Copyright (c) 2017 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 Bug6901Test {
23 public void ifFeature11EnumBitTest() throws Exception {
24 final SchemaContext schemaContext = StmtTestUtils.parseYangSource("/rfc7950/bug6901/foo.yang");
25 assertNotNull(schemaContext);
29 public void ifFeatureOnDefaultValueEnumTest() throws Exception {
31 StmtTestUtils.parseYangSource("/rfc7950/bug6901/invalid-foo-enum.yang");
32 fail("Test should fail due to invalid Yang 1.1");
33 } catch (final SomeModifiersUnresolvedException e) {
34 assertTrue(e.getCause().getMessage().startsWith(
35 "Leaf '(foo)enum-leaf' has default value 'two' marked with an if-feature statement."));
40 public void ifFeatureOnDefaultValueEnumTest2() throws Exception {
42 StmtTestUtils.parseYangSource("/rfc7950/bug6901/invalid-foo-enum-2.yang");
43 fail("Test should fail due to invalid Yang 1.1");
44 } catch (final SomeModifiersUnresolvedException e) {
45 assertTrue(e.getCause().getMessage().startsWith(
46 "Leaf '(foo)enum-leaf' has default value 'two' marked with an if-feature statement."));
51 public void ifFeatureOnDefaultValueEnumTest3() throws Exception {
53 StmtTestUtils.parseYangSource("/rfc7950/bug6901/invalid-foo-enum-3.yang");
54 fail("Test should fail due to invalid Yang 1.1");
55 } catch (final SomeModifiersUnresolvedException e) {
56 assertTrue(e.getCause().getMessage().startsWith(
57 "Leaf '(foo)enum-leaf' has default value 'two' marked with an if-feature statement."));
62 public void ifFeatureOnDefaultValueBitTest() throws Exception {
64 StmtTestUtils.parseYangSource("/rfc7950/bug6901/invalid-foo-bit.yang");
65 fail("Test should fail due to invalid Yang 1.1");
66 } catch (final SomeModifiersUnresolvedException e) {
67 assertTrue(e.getCause().getMessage().startsWith(
68 "Typedef '(foo)bits-typedef-2' has default value 'two' marked with an if-feature statement."));
73 public void ifFeatureOnDefaultValueUnionTest() throws Exception {
75 StmtTestUtils.parseYangSource("/rfc7950/bug6901/invalid-foo-union.yang");
76 fail("Test should fail due to invalid Yang 1.1");
77 } catch (final SomeModifiersUnresolvedException e) {
78 assertTrue(e.getCause().getMessage().startsWith(
79 "Leaf '(foo)union-leaf' has default value 'two' marked with an if-feature statement."));
84 public void unsupportedFeatureTest() throws Exception {
86 StmtTestUtils.parseYangSource("/rfc7950/bug6901/invalid-foo-enum.yang");
87 fail("Test should fail due to invalid Yang 1.1");
88 } catch (final SomeModifiersUnresolvedException e) {
90 e.getCause().getMessage().contains("has default value 'two' marked with an if-feature statement"));
95 public void ifFeature10EnumTest() throws Exception {
97 StmtTestUtils.parseYangSource("/rfc7950/bug6901/invalid-foo-10-enum.yang");
98 fail("Test should fail due to invalid Yang 1.0");
99 } catch (final SomeModifiersUnresolvedException e) {
100 assertTrue(e.getCause().getMessage().startsWith("IF_FEATURE is not valid for ENUM"));
105 public void ifFeature10BitTest() throws Exception {
107 StmtTestUtils.parseYangSource("/rfc7950/bug6901/invalid-foo-10-bit.yang");
108 fail("Test should fail due to invalid Yang 1.0");
109 } catch (final SomeModifiersUnresolvedException e) {
110 assertTrue(e.getCause().getMessage().startsWith("IF_FEATURE is not valid for BIT"));