BUG-7159: eliminate use of CrossStatementSourceReactor
[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 org.junit.Test;
17 import org.opendaylight.controller.config.yangjmxgenerator.ConfigConstants;
18 import org.opendaylight.controller.config.yangjmxgenerator.ServiceInterfaceEntryTest;
19 import org.opendaylight.controller.config.yangjmxgenerator.plugin.util.YangModelSearchUtils;
20 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
21
22 public class UnknownExtensionTest extends ServiceInterfaceEntryTest {
23
24     @Test
25     public void testStopOnUnknownLanguageExtension() throws Exception {
26         List<InputStream> yangISs = Lists.newArrayList(getClass()
27                 .getResourceAsStream("test-ifcWithUnknownExtension.yang"));
28         yangISs.addAll(getConfigApiYangInputStreams());
29         try {
30             context = YangParserTestUtils.parseYangStreams(yangISs);
31             namesToModules = YangModelSearchUtils.mapModulesByNames(context.getModules());
32             configModule = namesToModules.get(ConfigConstants.CONFIG_MODULE);
33             threadsModule = namesToModules.get(ConfigConstants.CONFIG_THREADS_MODULE);
34             try {
35                 super.testCreateFromIdentities();
36                 fail();
37             } catch (IllegalStateException e) {
38                 assertTrue(e.getMessage(),
39                         e.getMessage().startsWith("Unexpected unknown schema node."));
40             }
41         } finally {
42             for (InputStream is : yangISs) {
43                 is.close();
44             }
45         }
46     }
47
48 }