Fix checkstyle warnings in yang-jmx-generator.
[controller.git] / opendaylight / config / yang-jmx-generator / src / test / java / org / opendaylight / controller / config / yangjmxgenerator / unknownextension / UnknownExtensionTest.java
1 /*
2  * Copyright (c) 2013 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.controller.config.yangjmxgenerator.unknownextension;
9
10 import static org.junit.Assert.assertTrue;
11 import static org.junit.Assert.fail;
12
13 import com.google.common.collect.Lists;
14 import java.io.InputStream;
15 import java.util.List;
16 import java.util.Set;
17 import org.junit.Test;
18 import org.opendaylight.controller.config.yangjmxgenerator.ConfigConstants;
19 import org.opendaylight.controller.config.yangjmxgenerator.ServiceInterfaceEntryTest;
20 import org.opendaylight.controller.config.yangjmxgenerator.plugin.util.YangModelSearchUtils;
21 import org.opendaylight.yangtools.yang.model.api.Module;
22 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
23
24 public class UnknownExtensionTest extends ServiceInterfaceEntryTest {
25
26     @Test
27     public void testStopOnUnknownLanguageExtension() throws Exception {
28         List<InputStream> yangISs = Lists.newArrayList(getClass()
29                 .getResourceAsStream("test-ifcWithUnknownExtension.yang"));
30         yangISs.addAll(getConfigApiYangInputStreams());
31         try {
32             YangParserImpl parser = new YangParserImpl();
33             Set<Module> modulesToBuild = parser
34                     .parseYangModelsFromStreams(yangISs);
35             context = parser.resolveSchemaContext(modulesToBuild);
36             namesToModules = YangModelSearchUtils.mapModulesByNames(context
37                     .getModules());
38             configModule = namesToModules.get(ConfigConstants.CONFIG_MODULE);
39             threadsModule = namesToModules
40                     .get(ConfigConstants.CONFIG_THREADS_MODULE);
41             try {
42                 super.testCreateFromIdentities();
43                 fail();
44             } catch (IllegalStateException e) {
45                 assertTrue(
46                         e.getMessage(),
47                         e.getMessage().startsWith(
48                                 "Unexpected unknown schema node."));
49             }
50         } finally {
51             for (InputStream is : yangISs) {
52                 is.close();
53             }
54         }
55     }
56
57 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.