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%2FAbstractYangTest.java;fp=opendaylight%2Fconfig%2Fyang-jmx-generator%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fyangjmxgenerator%2FAbstractYangTest.java;h=0000000000000000000000000000000000000000;hp=c0e26688a650d5a77bbe92a122936e7f9dbdeb02;hb=ac6f2699cd0c1e340cc32e8f0d0ca94c8e9c0cc0;hpb=f43b01b81319959b1907e3e04537f5169e7f33d8 diff --git a/opendaylight/config/yang-jmx-generator/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/AbstractYangTest.java b/opendaylight/config/yang-jmx-generator/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/AbstractYangTest.java deleted file mode 100644 index c0e26688a6..0000000000 --- a/opendaylight/config/yang-jmx-generator/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/AbstractYangTest.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * 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; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; - -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Sets; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import org.junit.Assert; -import org.junit.Before; -import org.opendaylight.controller.config.yangjmxgenerator.plugin.util.YangModelSearchUtils; -import org.opendaylight.mdsal.binding.yang.types.TypeProviderImpl; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; - -public abstract class AbstractYangTest { - protected SchemaContext context; - protected Map namesToModules; // are module names globally - // unique? - protected Module configModule, rpcContextModule, threadsModule, - threadsJavaModule, bgpListenerJavaModule, ietfInetTypesModule, - jmxModule, jmxImplModule, testFilesModule, testFiles1Module; - - public static final String EVENTBUS_MXB_NAME = "eventbus"; - public static final String ASYNC_EVENTBUS_MXB_NAME = "async-eventbus"; - public static final String THREADFACTORY_NAMING_MXB_NAME = "threadfactory-naming"; - public static final String THREADPOOL_DYNAMIC_MXB_NAME = "threadpool-dynamic"; - public static final String THREADPOOL_REGISTRY_IMPL_NAME = "threadpool-registry-impl"; - - public static final String BGP_LISTENER_IMPL_MXB_NAME = "bgp-listener-impl"; - - @Before - public void loadYangFiles() throws Exception { - final List yangResources = new ArrayList<>(); - yangResources.add("/test-config-threads.yang"); - yangResources.add("/test-config-threads-java.yang"); - yangResources.add("/config-bgp-listener-impl.yang"); - yangResources.add("/ietf-inet-types.yang"); - yangResources.add("/config-jmx-it.yang"); - yangResources.add("/config-jmx-it-impl.yang"); - yangResources.add("/test-config-files.yang"); - yangResources.add("/test-config-files1.yang"); - - yangResources.addAll(getConfigApiYangs()); - - this.context = YangParserTestUtils.parseYangResources(AbstractYangTest.class, yangResources); - - this.namesToModules = YangModelSearchUtils.mapModulesByNames(this.context - .getModules()); - this.configModule = this.namesToModules.get(ConfigConstants.CONFIG_MODULE); - this.rpcContextModule = this.namesToModules.get(ConfigConstants.CONFIG_MODULE); - this.threadsModule = this.namesToModules - .get(ConfigConstants.CONFIG_THREADS_MODULE); - this.threadsJavaModule = this.namesToModules.get("config-threads-java"); - this.bgpListenerJavaModule = this.namesToModules.get("config-bgp-listener-impl"); - this.ietfInetTypesModule = this.namesToModules - .get(ConfigConstants.IETF_INET_TYPES); - this.jmxModule = this.namesToModules.get("config-jmx-it"); - this.jmxImplModule = this.namesToModules.get("config-jmx-it-impl"); - this.testFilesModule = this.namesToModules.get("test-config-files"); - this.testFiles1Module = this.namesToModules.get("test-config-files1"); - } - - public static List getConfigApiYangs() { - return ImmutableList.of("/META-INF/yang/config@2013-04-05.yang", "/META-INF/yang/rpc-context@2013-06-17.yang"); - } - - public Map mapIdentitiesByQNames(final Module module) { - final Map result = new HashMap<>(); - for (final IdentitySchemaNode identitySchemaNode : module.getIdentities()) { - final QName qName = identitySchemaNode.getQName(); - Preconditions.checkArgument( - result.containsKey(qName) == false, - "Two identities of %s contain same qname %s", - module, qName); - result.put(qName, identitySchemaNode); - } - return result; - } - - protected static List getStreams(final String... paths) { - final List result = new ArrayList<>(); - for (final String path : paths) { - final InputStream is = AbstractYangTest.class.getResourceAsStream(path); - assertNotNull(path + " is null", is); - result.add(is); - } - return result; - } - - protected Map loadThreadsServiceInterfaceEntries(final String packageName) { - final Map identitiesToSIs = new HashMap<>(); - return ServiceInterfaceEntry.create(this.threadsModule, packageName,identitiesToSIs); - } - - protected Map loadThreadsJava( - final Map modulesToSIEs, final String packageName) { - final Map namesToMBEs = ModuleMXBeanEntry - .create(this.threadsJavaModule, modulesToSIEs, this.context, new TypeProviderWrapper(new TypeProviderImpl - (this.context)), packageName); - Assert.assertNotNull(namesToMBEs); - final Set expectedMXBeanNames = Sets.newHashSet(EVENTBUS_MXB_NAME, - ASYNC_EVENTBUS_MXB_NAME, THREADFACTORY_NAMING_MXB_NAME, - THREADPOOL_DYNAMIC_MXB_NAME, THREADPOOL_REGISTRY_IMPL_NAME); - assertThat(namesToMBEs.keySet(), is(expectedMXBeanNames)); - return namesToMBEs; - } - -}