Remove deprecated Yin/YangStatementSourceImpl
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / stmt / yin / YinFileFeatureStmtTest.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.hamcrest.CoreMatchers.anyOf;
11 import static org.hamcrest.core.Is.is;
12 import static org.junit.Assert.assertEquals;
13 import static org.junit.Assert.assertNotNull;
14 import static org.junit.Assert.assertThat;
15
16 import java.io.IOException;
17 import java.net.URISyntaxException;
18 import java.util.Iterator;
19 import java.util.Set;
20 import org.junit.Before;
21 import org.junit.Test;
22 import org.opendaylight.yangtools.yang.model.api.FeatureDefinition;
23 import org.opendaylight.yangtools.yang.model.api.Module;
24 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
25 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
26 import org.opendaylight.yangtools.yang.stmt.TestUtils;
27 import org.xml.sax.SAXException;
28
29 public class YinFileFeatureStmtTest {
30
31     private SchemaContext context;
32
33     @Before
34     public void init() throws ReactorException, SAXException, IOException, URISyntaxException {
35         context = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/feature-test/")
36             .toURI());
37         assertEquals(1, context.getModules().size());
38     }
39
40     @Test
41     public void testFeature() {
42         Module testModule = TestUtils.findModule(context, "yang-with-features").get();
43         assertNotNull(testModule);
44
45         Set<FeatureDefinition> features = testModule.getFeatures();
46         assertEquals(2, features.size());
47
48         Iterator<FeatureDefinition> featuresIterator = features.iterator();
49         FeatureDefinition feature = featuresIterator.next();
50
51         assertThat(feature.getQName().getLocalName(), anyOf(is("arbitrary-names"), is("pre-provisioning")));
52
53         feature = featuresIterator.next();
54
55         assertThat(feature.getQName().getLocalName(), anyOf(is("arbitrary-names"), is("pre-provisioning")));
56     }
57 }