2 * Copyright (c) 2015 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.test;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertTrue;
14 import java.io.IOException;
15 import java.net.URISyntaxException;
16 import java.util.List;
17 import org.junit.Test;
18 import org.opendaylight.yangtools.yang.common.QName;
19 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
20 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
21 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
22 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
23 import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;
24 import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair;
25 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
26 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
28 public class Bug4459Test {
31 public void test() throws IOException, URISyntaxException, SourceException, ReactorException {
32 SchemaContext schema = StmtTestUtils.parseYangSources("/bugs/bug4459");
33 assertNotNull(schema);
35 DataSchemaNode dataChildByName = schema.getDataChildByName("my-leaf");
36 assertTrue(dataChildByName instanceof LeafSchemaNode);
37 LeafSchemaNode myLeaf = (LeafSchemaNode) dataChildByName;
39 TypeDefinition<?> type = myLeaf.getType();
40 assertTrue(type instanceof EnumTypeDefinition);
41 EnumTypeDefinition myEnum = (EnumTypeDefinition) type;
43 QName expectedEnumQName = QName.create("foo", "1970-01-01", "QuestionMark-Ampersand-LeftParenthesis-RightParenthesis-QuestionMark-QuestionMark-Ampersand");
44 List<EnumPair> values = myEnum.getValues();
45 for (EnumPair enumPair : values) {
46 if (enumPair.getName().equals("?-&-(-)-?-?-&")) {
47 assertEquals(expectedEnumQName, enumPair.getQName());