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
8 package org.opendaylight.yangtools.yang.stmt;
10 import static org.junit.Assert.assertNotNull;
11 import static org.junit.Assert.assertNull;
12 import static org.junit.Assert.assertTrue;
14 import org.junit.Test;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
17 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
18 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
19 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
20 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
21 import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
23 public class Bug6669Test {
24 private static final String REV = "2016-09-08";
25 private static final String FOO_NS = "foo";
26 private static final String BAR_NS = "bar";
27 private static final QName ROOT = QName.create(FOO_NS, REV, "root");
28 private static final QName BAR = QName.create(BAR_NS, REV, "bar");
29 private static final QName BAR_1 = QName.create(BAR_NS, REV, "bar1");
30 private static final QName BAR_2 = QName.create(BAR_NS, REV, "bar2");
31 private static final QName M = QName.create(BAR_NS, REV, "m");
32 private static final QName L = QName.create(BAR_NS, REV, "l");
35 public void testInvalidAugment() throws Exception {
36 final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug6669/invalid/test1");
37 assertNotNull(context);
39 final SchemaNode findDataSchemaNode = SchemaContextUtil.findDataSchemaNode(context,
40 SchemaPath.create(true, ROOT, BAR, BAR_1, M));
41 assertNull(findDataSchemaNode);
45 public void testInvalidAugment2() throws Exception {
46 final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug6669/invalid/test2");
47 assertNotNull(context);
49 final SchemaNode findDataSchemaNode = SchemaContextUtil.findDataSchemaNode(context,
50 SchemaPath.create(true, ROOT, BAR, BAR_1, BAR_2, M));
51 assertNull(findDataSchemaNode);
55 public void testInvalidAugment3() throws Exception {
56 final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug6669/invalid/test3");
57 assertNotNull(context);
59 final SchemaNode findDataSchemaNode = SchemaContextUtil.findDataSchemaNode(context,
60 SchemaPath.create(true, ROOT, BAR, BAR_1, BAR_2, L));
61 assertNull(findDataSchemaNode);
65 public void testValidAugment() throws Exception {
66 final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug6669/valid/test1");
67 assertNotNull(context);
69 final SchemaNode findDataSchemaNode = SchemaContextUtil.findDataSchemaNode(context,
70 SchemaPath.create(true, ROOT, BAR, BAR_1, M));
71 assertTrue(findDataSchemaNode instanceof LeafSchemaNode);
75 public void testValidAugment2() throws Exception {
76 final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug6669/valid/test2");
77 assertNotNull(context);
79 final SchemaNode findDataSchemaNode = SchemaContextUtil.findDataSchemaNode(context,
80 SchemaPath.create(true, ROOT, BAR, BAR_1, BAR_2, M));
81 assertTrue(findDataSchemaNode instanceof LeafSchemaNode);
85 public void testValidAugment3() throws Exception {
86 final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug6669/valid/test3");
87 assertNotNull(context);
89 final SchemaNode findDataSchemaNode = SchemaContextUtil.findDataSchemaNode(context,
90 SchemaPath.create(true, ROOT, BAR, BAR_1, BAR_2, L));
91 assertTrue(findDataSchemaNode instanceof ListSchemaNode);