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?revision=1970-01-01)enum-leaf' has default value 'two' marked with an if-feature "
41 public void ifFeatureOnDefaultValueEnumTest2() throws Exception {
43 StmtTestUtils.parseYangSource("/rfc7950/bug6901/invalid-foo-enum-2.yang");
44 fail("Test should fail due to invalid Yang 1.1");
45 } catch (final SomeModifiersUnresolvedException e) {
46 assertTrue(e.getCause().getMessage().startsWith(
47 "Leaf '(foo?revision=1970-01-01)enum-leaf' has default value 'two' marked with an if-feature "
53 public void ifFeatureOnDefaultValueEnumTest3() throws Exception {
55 StmtTestUtils.parseYangSource("/rfc7950/bug6901/invalid-foo-enum-3.yang");
56 fail("Test should fail due to invalid Yang 1.1");
57 } catch (final SomeModifiersUnresolvedException e) {
58 assertTrue(e.getCause().getMessage().startsWith(
59 "Leaf '(foo?revision=1970-01-01)enum-leaf' has default value 'two' marked with an if-feature "
65 public void ifFeatureOnDefaultValueBitTest() throws Exception {
67 StmtTestUtils.parseYangSource("/rfc7950/bug6901/invalid-foo-bit.yang");
68 fail("Test should fail due to invalid Yang 1.1");
69 } catch (final SomeModifiersUnresolvedException e) {
70 assertTrue(e.getCause().getMessage().startsWith(
71 "Typedef '(foo?revision=1970-01-01)bits-typedef-2' has default value 'two' marked with an "
72 + "if-feature statement."));
77 public void ifFeatureOnDefaultValueUnionTest() throws Exception {
79 StmtTestUtils.parseYangSource("/rfc7950/bug6901/invalid-foo-union.yang");
80 fail("Test should fail due to invalid Yang 1.1");
81 } catch (final SomeModifiersUnresolvedException e) {
82 assertTrue(e.getCause().getMessage().startsWith(
83 "Leaf '(foo?revision=1970-01-01)union-leaf' has default value 'two' marked with an if-feature "
89 public void unsupportedFeatureTest() throws Exception {
91 StmtTestUtils.parseYangSource("/rfc7950/bug6901/invalid-foo-enum.yang");
92 fail("Test should fail due to invalid Yang 1.1");
93 } catch (final SomeModifiersUnresolvedException e) {
95 e.getCause().getMessage().contains("has default value 'two' marked with an if-feature statement"));
100 public void ifFeature10EnumTest() throws Exception {
102 StmtTestUtils.parseYangSource("/rfc7950/bug6901/invalid-foo-10-enum.yang");
103 fail("Test should fail due to invalid Yang 1.0");
104 } catch (final SomeModifiersUnresolvedException e) {
105 assertTrue(e.getCause().getMessage().startsWith("IF_FEATURE is not valid for ENUM"));
110 public void ifFeature10BitTest() throws Exception {
112 StmtTestUtils.parseYangSource("/rfc7950/bug6901/invalid-foo-10-bit.yang");
113 fail("Test should fail due to invalid Yang 1.0");
114 } catch (final SomeModifiersUnresolvedException e) {
115 assertTrue(e.getCause().getMessage().startsWith("IF_FEATURE is not valid for BIT"));