X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fconfig%2Fyang-jmx-generator%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fyangjmxgenerator%2Funknownextension%2FUnknownExtensionTest.java;fp=opendaylight%2Fconfig%2Fyang-jmx-generator%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fyangjmxgenerator%2Funknownextension%2FUnknownExtensionTest.java;h=91e92f70e0ac437bca1bf52d7016fb87e91fd008;hp=0000000000000000000000000000000000000000;hb=9fb64948564e252018f9b1e13e7cea2c92f991aa;hpb=1742b3894614be478c333a1043ced8ef1bc5dc84 diff --git a/opendaylight/config/yang-jmx-generator/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/unknownextension/UnknownExtensionTest.java b/opendaylight/config/yang-jmx-generator/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/unknownextension/UnknownExtensionTest.java new file mode 100644 index 0000000000..91e92f70e0 --- /dev/null +++ b/opendaylight/config/yang-jmx-generator/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/unknownextension/UnknownExtensionTest.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.config.yangjmxgenerator.unknownextension; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.InputStream; +import java.util.List; +import java.util.Set; + +import org.junit.Test; +import org.opendaylight.controller.config.yangjmxgenerator.ConfigConstants; +import org.opendaylight.controller.config.yangjmxgenerator.ServiceInterfaceEntryTest; +import org.opendaylight.controller.config.yangjmxgenerator.plugin.util.YangModelSearchUtils; +import org.opendaylight.yangtools.yang.model.api.Module; +import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl; + +import com.google.common.collect.Lists; + +public class UnknownExtensionTest extends ServiceInterfaceEntryTest { + + @Test + public void testStopOnUnknownLanguageExtension() throws Exception { + List yangISs = Lists.newArrayList(getClass() + .getResourceAsStream("test-ifcWithUnknownExtension.yang")); + yangISs.addAll(getConfigApiYangInputStreams()); + try { + YangParserImpl parser = new YangParserImpl(); + Set modulesToBuild = parser + .parseYangModelsFromStreams(yangISs); + context = parser.resolveSchemaContext(modulesToBuild); + namesToModules = YangModelSearchUtils.mapModulesByNames(context + .getModules()); + configModule = namesToModules.get(ConfigConstants.CONFIG_MODULE); + threadsModule = namesToModules + .get(ConfigConstants.CONFIG_THREADS_MODULE); + try { + super.testCreateFromIdentities(); + fail(); + } catch (IllegalStateException e) { + assertTrue( + e.getMessage(), + e.getMessage().startsWith( + "Unexpected unknown schema node.")); + } + } finally { + for (InputStream is : yangISs) { + is.close(); + } + } + } + +}