8e6624f8d3b23b0625d346713527fabf7c3e9895
[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.net.URI;
14 import java.net.URISyntaxException;
15 import java.util.Iterator;
16 import java.util.Set;
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.parser.spi.meta.ReactorException;
21 import org.opendaylight.yangtools.yang.stmt.TestUtils;
22
23 public class YinFileIncludeStmtTest {
24
25     private Set<Module> modules;
26
27     @Before
28     public void init() throws URISyntaxException, ReactorException {
29         modules = TestUtils.loadYinModules(getClass().getResource
30                 ("/semantic-statement-parser/yin/include-belongs-to-test").toURI());
31         assertEquals(1, modules.size());
32     }
33
34     @Test
35     public void testInclude() throws URISyntaxException {
36         Module parentModule = TestUtils.findModule(modules, "parent");
37         assertNotNull(parentModule);
38
39         assertEquals(1, parentModule.getSubmodules().size());
40         Iterator<Module> submodulesIterator = parentModule.getSubmodules().iterator();
41
42         Module childModule = submodulesIterator.next() ;
43         assertNotNull(childModule);
44         assertEquals("child", childModule.getName());
45         assertEquals(new URI("urn:opendaylight/parent"), childModule.getNamespace());
46     }
47 }