use of org.opendaylight.controller.config.spi.ModuleFactory in project controller by opendaylight.
the class JMXGeneratorTest method generateMBEsTest.
@Test
public void generateMBEsTest() throws Exception {
// default value for module factory file is true
map.put(JMXGenerator.MODULE_FACTORY_FILE_BOOLEAN, "randomValue");
jmxGenerator.setAdditionalConfig(map);
Collection<File> files = jmxGenerator.generateSources(context, outputBaseDir, Collections.singleton(threadsJavaModule), m -> Optional.empty());
assertEquals(expectedModuleFileNames, toFileNames(files));
for (File file : files) {
final String name = file.getName();
if (!name.endsWith("java")) {
continue;
}
MbeASTVisitor visitor = new MbeASTVisitor(EXPECTED_PACKAGE_PREFIX + ".threads.java", name);
verifyFile(file, visitor);
switch(name) {
case "AbstractDynamicThreadPoolModule.java":
assertAbstractDynamicThreadPoolModule(visitor);
break;
case "AsyncEventBusModuleMXBean.java":
assertEquals("Incorrenct number of generated methods", 4, visitor.methods.size());
break;
case "AbstractNamingThreadFactoryModuleFactory.java":
assertAbstractNamingThreadFactoryModuleFactory(visitor);
break;
case "AsyncEventBusModule.java":
assertContains(visitor.extnds, EXPECTED_PACKAGE_PREFIX + ".threads.java.AbstractAsyncEventBusModule");
visitor.assertFields(0);
assertEquals("Incorrenct number of generated methods", 2, visitor.methods.size());
visitor.assertConstructors(2);
visitor.assertMethodDescriptions(0);
visitor.assertMethodJavadocs(0);
break;
case "EventBusModuleFactory.java":
assertContains(visitor.extnds, EXPECTED_PACKAGE_PREFIX + ".threads.java.AbstractEventBusModuleFactory");
visitor.assertFields(0);
assertEquals("Incorrenct number of generated methods", 0, visitor.methods.size());
visitor.assertConstructors(0);
visitor.assertMethodDescriptions(0);
visitor.assertMethodJavadocs(0);
break;
}
}
verifyXmlFiles(Collections2.filter(files, input -> input.getName().endsWith("xml")));
// verify ModuleFactory file
File moduleFactoryFile = JMXGenerator.concatFolders(generatedResourcesDir, "META-INF", "services", ModuleFactory.class.getName());
assertTrue(moduleFactoryFile.exists());
Set<String> lines = ImmutableSet.copyOf(Files.readLines(moduleFactoryFile, StandardCharsets.UTF_8));
Set<String> expectedLines = ImmutableSet.of(EXPECTED_PACKAGE_PREFIX + ".threads.java.EventBusModuleFactory", EXPECTED_PACKAGE_PREFIX + ".threads.java.AsyncEventBusModuleFactory", EXPECTED_PACKAGE_PREFIX + ".threads.java.DynamicThreadPoolModuleFactory", EXPECTED_PACKAGE_PREFIX + ".threads.java.NamingThreadFactoryModuleFactory", EXPECTED_PACKAGE_PREFIX + ".threads.java.ThreadPoolRegistryImplModuleFactory");
assertEquals(expectedLines, lines);
}
use of org.opendaylight.controller.config.spi.ModuleFactory in project controller by opendaylight.
the class DependencyResolverManagerTest method mockGetInstance.
private static void mockGetInstance(final DependencyResolverManager tested, final ModuleIdentifier moduleIdentifier) {
ModuleFactory moduleFactory = mock(ModuleFactory.class);
ModuleInternalInfo maybeOldInternalInfo = null;
TransactionModuleJMXRegistration transactionModuleJMXRegistration = null;
boolean isDefaultBean = false;
tested.put(moduleIdentifier, mockedModule(), moduleFactory, maybeOldInternalInfo, transactionModuleJMXRegistration, isDefaultBean, mock(BundleContext.class));
}
use of org.opendaylight.controller.config.spi.ModuleFactory in project controller by opendaylight.
the class BundleContextBackedModuleFactoriesResolverTest method getMockFactory.
private static ModuleFactory getMockFactory(final String name) {
ModuleFactory mock = mock(ModuleFactory.class);
doReturn(name).when(mock).toString();
doReturn(name).when(mock).getImplementationName();
return mock;
}
Aggregations