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.MatcherAssert.assertThat;
12 import static org.hamcrest.core.Is.is;
13 import static org.junit.Assert.assertEquals;
14 import static org.junit.Assert.assertNotNull;
16 import java.util.Collection;
17 import java.util.Iterator;
18 import org.junit.Before;
19 import org.junit.Test;
20 import org.opendaylight.yangtools.yang.model.api.FeatureDefinition;
21 import org.opendaylight.yangtools.yang.model.api.Module;
22 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
23 import org.opendaylight.yangtools.yang.stmt.TestUtils;
25 public class YinFileFeatureStmtTest {
26 private SchemaContext context;
29 public void init() throws Exception {
30 context = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/feature-test/")
32 assertEquals(1, context.getModules().size());
36 public void testFeature() {
37 Module testModule = context.findModules("yang-with-features").iterator().next();
38 assertNotNull(testModule);
40 Collection<? extends FeatureDefinition> features = testModule.getFeatures();
41 assertEquals(2, features.size());
43 Iterator<? extends FeatureDefinition> featuresIterator = features.iterator();
44 FeatureDefinition feature = featuresIterator.next();
46 assertThat(feature.getQName().getLocalName(), anyOf(is("arbitrary-names"), is("pre-provisioning")));
48 feature = featuresIterator.next();
50 assertThat(feature.getQName().getLocalName(), anyOf(is("arbitrary-names"), is("pre-provisioning")));