Adjust test suite parser update to conform with API changes
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / stmt / yin / YinFileIncludeStmtTest.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.yin;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12
13 import java.io.IOException;
14 import java.net.URI;
15 import java.net.URISyntaxException;
16 import java.util.Iterator;
17 import org.junit.Before;
18 import org.junit.Test;
19 import org.opendaylight.yangtools.yang.model.api.Module;
20 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
22 import org.opendaylight.yangtools.yang.stmt.TestUtils;
23 import org.xml.sax.SAXException;
24
25 public class YinFileIncludeStmtTest {
26
27     private SchemaContext context;
28
29     @Before
30     public void init() throws URISyntaxException, ReactorException, SAXException, IOException {
31         context = TestUtils.loadYinModules(getClass().getResource(
32             "/semantic-statement-parser/yin/include-belongs-to-test").toURI());
33         assertEquals(1, context.getModules().size());
34     }
35
36     @Test
37     public void testInclude() throws URISyntaxException {
38         Module parentModule = TestUtils.findModule(context, "parent").get();
39         assertNotNull(parentModule);
40
41         assertEquals(1, parentModule.getSubmodules().size());
42         Iterator<Module> submodulesIterator = parentModule.getSubmodules().iterator();
43
44         Module childModule = submodulesIterator.next() ;
45         assertNotNull(childModule);
46         assertEquals("child", childModule.getName());
47         assertEquals(new URI("urn:opendaylight/parent"), childModule.getNamespace());
48     }
49 }