Bug4231 - Yang tools failing to parse Augmentations under "uses" clause.
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / parser / impl / Bug4231Test.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.parser.impl;
9
10 import static org.junit.Assert.*;
11
12 import java.text.ParseException;
13
14 import java.net.URI;
15 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
16 import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
17 import org.opendaylight.yangtools.yang.common.QNameModule;
18 import org.opendaylight.yangtools.yang.common.QName;
19 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
20 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
21 import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
22 import java.io.IOException;
23 import java.net.URISyntaxException;
24 import org.junit.Test;
25
26 public class Bug4231Test {
27
28     @Test
29     public void test() throws IOException, URISyntaxException, ParseException {
30         SchemaContext context = TestUtils.loadSchemaContext(getClass()
31                 .getResource("/bugs/bug4231").toURI());
32
33         assertNotNull(context);
34
35         QNameModule foo = QNameModule.create(new URI("foo"),
36                 SimpleDateFormatUtil.getRevisionFormat().parse("2015-09-02"));
37
38         SchemaPath targetPath = SchemaPath
39                 .create(true, QName.create(foo, "augment-target"))
40                 .createChild(QName.create(foo, "my-container-in-grouping"))
41                 .createChild(QName.create(foo, "l2"));
42
43         SchemaNode targetNode = SchemaContextUtil.findNodeInSchemaContext(
44                 context, targetPath.getPathFromRoot());
45         assertNotNull(targetNode);
46     }
47
48 }