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
9 package org.opendaylight.yangtools.yang.stmt;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertNotNull;
14 import java.io.FileNotFoundException;
15 import java.net.URISyntaxException;
16 import org.junit.Test;
17 import org.opendaylight.yangtools.yang.common.QName;
18 import org.opendaylight.yangtools.yang.model.api.Module;
19 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
20 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
22 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
24 public class Bug5712Test {
27 public void testTypedefWithNewStatementParser() throws ReactorException, SourceException, FileNotFoundException,
29 SchemaContext schemaContext = StmtTestUtils.parseYangSources("/bugs/bug5712");
30 assertNotNull(schemaContext);
32 Module badModule = schemaContext.findModuleByName("bad", null);
33 assertNotNull(badModule);
35 checkThing2TypeDef(badModule);
38 private void checkThing2TypeDef(Module badModule) {
39 TypeDefinition<?> thing2 = null;
40 for (TypeDefinition<?> typeDef : badModule.getTypeDefinitions()) {
41 if (typeDef.getQName().getLocalName().equals("thing2")) {
47 assertNotNull(thing2);
48 TypeDefinition<?> baseType = thing2.getBaseType();
49 assertEquals(QName.create("urn:opendaylight:bad", "2016-04-11", "thing"), baseType.getQName());