Remove usage of deprecated yang parser classes
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / stmt / Bug4231Test.java
1 /*
2  * Copyright (c) 2016 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.stmt;
9
10 import static org.junit.Assert.assertNotNull;
11
12 import java.io.IOException;
13 import java.net.URI;
14 import java.net.URISyntaxException;
15 import java.text.ParseException;
16 import org.junit.Test;
17 import org.opendaylight.yangtools.yang.common.QName;
18 import org.opendaylight.yangtools.yang.common.QNameModule;
19 import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
20 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
21 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
22 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
23 import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
24 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
25
26 public class Bug4231Test {
27
28     @Test
29     public void test() throws IOException, URISyntaxException, ParseException, ReactorException {
30         SchemaContext context = TestUtils.parseYangSources("/bugs/bug4231");
31
32         assertNotNull(context);
33
34         QNameModule foo = QNameModule.create(new URI("foo"),
35                 SimpleDateFormatUtil.getRevisionFormat().parse("2015-09-02"));
36
37         SchemaPath targetPath = SchemaPath
38                 .create(true, QName.create(foo, "augment-target"))
39                 .createChild(QName.create(foo, "my-container-in-grouping"))
40                 .createChild(QName.create(foo, "l2"));
41
42         SchemaNode targetNode = SchemaContextUtil.findNodeInSchemaContext(
43                 context, targetPath.getPathFromRoot());
44         assertNotNull(targetNode);
45     }
46
47 }