509bb38151df35e3343652d5b4f568a6ffd0abaf
[yangtools.git] / yang / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / Bug5693Test.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.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12
13 import java.io.IOException;
14 import java.net.URISyntaxException;
15 import org.junit.Before;
16 import org.junit.Test;
17 import org.opendaylight.yangtools.yang.model.api.Module;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
19 import org.xml.sax.SAXException;
20
21 public class Bug5693Test {
22
23     private Module foo;
24
25     /**
26      * Use input stream to load Yin module.
27      */
28     @Before
29     public void initTest() throws ReactorException, SAXException, IOException, URISyntaxException {
30         foo = StmtTestUtils.parseYinSources("/bugs/bug5693").getModules().iterator().next();
31     }
32
33     /**
34      * Test presence of testing feature (parsed in the last phase), if it is present then parsing was successful.
35      * Meaning that stream was not closed after the first parsing phase.
36      */
37     @Test
38     public void bug5693Test() {
39         assertNotNull(foo.getFeatures());
40         assertEquals("Module should has exactly one feature", 1, foo.getFeatures().size());
41         assertEquals("Present feature should has expected local name", "test-input-stream-not-closed",
42                 foo.getFeatures().iterator().next().getQName().getLocalName());
43     }
44 }