2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang.stmt.yin;
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;
16 import java.io.IOException;
17 import java.net.URISyntaxException;
18 import java.util.Iterator;
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;
29 public class YinFileFeatureStmtTest {
31 private SchemaContext context;
34 public void init() throws ReactorException, SAXException, IOException, URISyntaxException {
35 context = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/feature-test/")
37 assertEquals(1, context.getModules().size());
41 public void testFeature() {
42 Module testModule = TestUtils.findModule(context, "yang-with-features").get();
43 assertNotNull(testModule);
45 Set<FeatureDefinition> features = testModule.getFeatures();
46 assertEquals(2, features.size());
48 Iterator<FeatureDefinition> featuresIterator = features.iterator();
49 FeatureDefinition feature = featuresIterator.next();
51 assertThat(feature.getQName().getLocalName(), anyOf(is("arbitrary-names"), is("pre-provisioning")));
53 feature = featuresIterator.next();
55 assertThat(feature.getQName().getLocalName(), anyOf(is("arbitrary-names"), is("pre-provisioning")));