@Test public void testProcessorLoadsNarResources() throws IOException, ClassNotFoundException { TemporaryFolder temporaryFolder = new TemporaryFolder(); temporaryFolder.create(); NiFiProperties properties = loadSpecifiedProperties("/conf/nifi.properties", NiFiProperties.COMPONENT_DOCS_DIRECTORY, temporaryFolder.getRoot().getAbsolutePath()); NarUnpacker.unpackNars(properties); NarClassLoaders.getInstance().init(properties.getFrameworkWorkingDirectory(), properties.getExtensionsWorkingDirectory()); ExtensionManager.discoverExtensions(NarClassLoaders.getInstance().getExtensionClassLoaders()); DocGenerator.generate(properties); File processorDirectory = new File(temporaryFolder.getRoot(), "org.apache.nifi.processors.WriteResourceToStream"); File indexHtml = new File(processorDirectory, "index.html"); Assert.assertTrue(indexHtml + " should have been generated", indexHtml.exists()); String generatedHtml = FileUtils.readFileToString(indexHtml); Assert.assertNotNull(generatedHtml); Assert.assertTrue(generatedHtml.contains("This example processor loads a resource from the nar and writes it to the FlowFile content")); Assert.assertTrue(generatedHtml.contains("files that were successfully processed")); Assert.assertTrue(generatedHtml.contains("files that were not successfully processed")); Assert.assertTrue(generatedHtml.contains("resources")); }
public static void generate(final NiFiProperties properties) { @SuppressWarnings("rawtypes") final Set<Class> extensionClasses = new HashSet<>(); extensionClasses.addAll(ExtensionManager.getExtensions(Processor.class)); extensionClasses.addAll(ExtensionManager.getExtensions(ControllerService.class)); extensionClasses.addAll(ExtensionManager.getExtensions(ReportingTask.class)); final File explodedNiFiDocsDir = properties.getComponentDocumentationWorkingDirectory(); logger.debug("Generating documentation for: " + extensionClasses.size() + " components in: " + explodedNiFiDocsDir); for (final Class<?> extensionClass : extensionClasses) { if (ConfigurableComponent.class.isAssignableFrom(extensionClass)) { final Class<? extends ConfigurableComponent> componentClass = extensionClass.asSubclass(ConfigurableComponent.class); try { logger.debug("Documenting: " + componentClass); document(explodedNiFiDocsDir, componentClass); } catch (Exception e) { logger.warn("Unable to document: " + componentClass, e); } } } }
DocGenerator { public static void generate(final NiFiProperties properties) { @SuppressWarnings("rawtypes") final Set<Class> extensionClasses = new HashSet<>(); extensionClasses.addAll(ExtensionManager.getExtensions(Processor.class)); extensionClasses.addAll(ExtensionManager.getExtensions(ControllerService.class)); extensionClasses.addAll(ExtensionManager.getExtensions(ReportingTask.class)); final File explodedNiFiDocsDir = properties.getComponentDocumentationWorkingDirectory(); logger.debug("Generating documentation for: " + extensionClasses.size() + " components in: " + explodedNiFiDocsDir); for (final Class<?> extensionClass : extensionClasses) { if (ConfigurableComponent.class.isAssignableFrom(extensionClass)) { final Class<? extends ConfigurableComponent> componentClass = extensionClass.asSubclass(ConfigurableComponent.class); try { logger.debug("Documenting: " + componentClass); document(explodedNiFiDocsDir, componentClass); } catch (Exception e) { logger.warn("Unable to document: " + componentClass, e); } } } } }
DocGenerator { public static void generate(final NiFiProperties properties) { @SuppressWarnings("rawtypes") final Set<Class> extensionClasses = new HashSet<>(); extensionClasses.addAll(ExtensionManager.getExtensions(Processor.class)); extensionClasses.addAll(ExtensionManager.getExtensions(ControllerService.class)); extensionClasses.addAll(ExtensionManager.getExtensions(ReportingTask.class)); final File explodedNiFiDocsDir = properties.getComponentDocumentationWorkingDirectory(); logger.debug("Generating documentation for: " + extensionClasses.size() + " components in: " + explodedNiFiDocsDir); for (final Class<?> extensionClass : extensionClasses) { if (ConfigurableComponent.class.isAssignableFrom(extensionClass)) { final Class<? extends ConfigurableComponent> componentClass = extensionClass.asSubclass(ConfigurableComponent.class); try { logger.debug("Documenting: " + componentClass); document(explodedNiFiDocsDir, componentClass); } catch (Exception e) { logger.warn("Unable to document: " + componentClass, e); } } } }  }
DocGenerator { public static void generate(final NiFiProperties properties) { @SuppressWarnings("rawtypes") final Set<Class> extensionClasses = new HashSet<>(); extensionClasses.addAll(ExtensionManager.getExtensions(Processor.class)); extensionClasses.addAll(ExtensionManager.getExtensions(ControllerService.class)); extensionClasses.addAll(ExtensionManager.getExtensions(ReportingTask.class)); final File explodedNiFiDocsDir = properties.getComponentDocumentationWorkingDirectory(); logger.debug("Generating documentation for: " + extensionClasses.size() + " components in: " + explodedNiFiDocsDir); for (final Class<?> extensionClass : extensionClasses) { if (ConfigurableComponent.class.isAssignableFrom(extensionClass)) { final Class<? extends ConfigurableComponent> componentClass = extensionClass.asSubclass(ConfigurableComponent.class); try { logger.debug("Documenting: " + componentClass); document(explodedNiFiDocsDir, componentClass); } catch (Exception e) { logger.warn("Unable to document: " + componentClass, e); } } } }  static void generate(final NiFiProperties properties); }
DocGenerator { public static void generate(final NiFiProperties properties) { @SuppressWarnings("rawtypes") final Set<Class> extensionClasses = new HashSet<>(); extensionClasses.addAll(ExtensionManager.getExtensions(Processor.class)); extensionClasses.addAll(ExtensionManager.getExtensions(ControllerService.class)); extensionClasses.addAll(ExtensionManager.getExtensions(ReportingTask.class)); final File explodedNiFiDocsDir = properties.getComponentDocumentationWorkingDirectory(); logger.debug("Generating documentation for: " + extensionClasses.size() + " components in: " + explodedNiFiDocsDir); for (final Class<?> extensionClass : extensionClasses) { if (ConfigurableComponent.class.isAssignableFrom(extensionClass)) { final Class<? extends ConfigurableComponent> componentClass = extensionClass.asSubclass(ConfigurableComponent.class); try { logger.debug("Documenting: " + componentClass); document(explodedNiFiDocsDir, componentClass); } catch (Exception e) { logger.warn("Unable to document: " + componentClass, e); } } } }  static void generate(final NiFiProperties properties);  }