Search in sources :

Example 46 with NiFiProperties

use of org.apache.nifi.util.NiFiProperties in project nifi-minifi by apache.

the class MiNiFi method main.

/**
 * Main entry point of the application.
 *
 * @param args things which are ignored
 */
public static void main(String[] args) {
    logger.info("Launching MiNiFi...");
    try {
        NiFiProperties niFiProperties = NiFiProperties.createBasicNiFiProperties(null, null);
        new MiNiFi(niFiProperties);
    } catch (final Throwable t) {
        logger.error("Failure to launch MiNiFi due to " + t, t);
    }
}
Also used : NiFiProperties(org.apache.nifi.util.NiFiProperties)

Example 47 with NiFiProperties

use of org.apache.nifi.util.NiFiProperties in project nifi-minifi by apache.

the class MiNiFiPersistentProvenanceRepositoryTest method createTestableRepositoryConfiguration.

private RepositoryConfiguration createTestableRepositoryConfiguration(final NiFiProperties properties) {
    Class klass = MiNiFiPersistentProvenanceRepository.class;
    Method createRepositoryConfigurationMethod;
    RepositoryConfiguration configuration = null;
    try {
        createRepositoryConfigurationMethod = klass.getDeclaredMethod("createRepositoryConfiguration", NiFiProperties.class);
        createRepositoryConfigurationMethod.setAccessible(true);
        configuration = (RepositoryConfiguration) createRepositoryConfigurationMethod.invoke(null, properties);
    } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
        e.printStackTrace();
    }
    return configuration;
}
Also used : NiFiProperties(org.apache.nifi.util.NiFiProperties) BeforeClass(org.junit.BeforeClass) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 48 with NiFiProperties

use of org.apache.nifi.util.NiFiProperties in project nifi-minifi by apache.

the class NarUnpackerTest method testUnpackNarsFromNonDir.

@Test
public void testUnpackNarsFromNonDir() throws IOException {
    final File nonDir = new File("./target/file.txt");
    nonDir.createNewFile();
    nonDir.deleteOnExit();
    final Map<String, String> others = new HashMap<>();
    others.put("nifi.nar.library.directory.alt", nonDir.toString());
    NiFiProperties properties = loadSpecifiedProperties("/NarUnpacker/conf/nifi.properties", others);
    final ExtensionMapping extensionMapping = NarUnpacker.unpackNars(properties);
    assertNull(extensionMapping);
}
Also used : NiFiProperties(org.apache.nifi.util.NiFiProperties) HashMap(java.util.HashMap) File(java.io.File) Test(org.junit.Test)

Example 49 with NiFiProperties

use of org.apache.nifi.util.NiFiProperties in project nifi-minifi by apache.

the class NarUnpackerTest method testUnpackNarsFromEmptyDir.

@Test
public void testUnpackNarsFromEmptyDir() throws IOException {
    final File emptyDir = new File("./target/empty/dir");
    emptyDir.delete();
    emptyDir.deleteOnExit();
    assertTrue(emptyDir.mkdirs());
    final Map<String, String> others = new HashMap<>();
    others.put("nifi.nar.library.directory.alt", emptyDir.toString());
    NiFiProperties properties = loadSpecifiedProperties("/NarUnpacker/conf/nifi.properties", others);
    final ExtensionMapping extensionMapping = NarUnpacker.unpackNars(properties);
    assertEquals(1, extensionMapping.getAllExtensionNames().size());
    assertTrue(extensionMapping.getAllExtensionNames().contains("org.apache.nifi.processors.dummy.one"));
    final File extensionsWorkingDir = properties.getExtensionsWorkingDirectory();
    File[] extensionFiles = extensionsWorkingDir.listFiles();
    assertEquals(1, extensionFiles.length);
    assertEquals("dummy-one.nar-unpacked", extensionFiles[0].getName());
}
Also used : NiFiProperties(org.apache.nifi.util.NiFiProperties) HashMap(java.util.HashMap) File(java.io.File) Test(org.junit.Test)

Example 50 with NiFiProperties

use of org.apache.nifi.util.NiFiProperties in project nifi-minifi by apache.

the class NarUnpackerTest method testUnpackNars.

@Test
public void testUnpackNars() {
    NiFiProperties properties = loadSpecifiedProperties("/NarUnpacker/conf/nifi.properties", Collections.EMPTY_MAP);
    assertEquals("./target/NarUnpacker/lib/", properties.getProperty("nifi.nar.library.directory"));
    assertEquals("./target/NarUnpacker/lib2/", properties.getProperty("nifi.nar.library.directory.alt"));
    final ExtensionMapping extensionMapping = NarUnpacker.unpackNars(properties);
    assertEquals(2, extensionMapping.getAllExtensionNames().size());
    assertTrue(extensionMapping.getAllExtensionNames().contains("org.apache.nifi.processors.dummy.one"));
    assertTrue(extensionMapping.getAllExtensionNames().contains("org.apache.nifi.processors.dummy.two"));
    final File extensionsWorkingDir = properties.getExtensionsWorkingDirectory();
    File[] extensionFiles = extensionsWorkingDir.listFiles();
    Set<String> expectedNars = new HashSet<>();
    expectedNars.add("dummy-one.nar-unpacked");
    expectedNars.add("dummy-two.nar-unpacked");
    assertEquals(expectedNars.size(), extensionFiles.length);
    for (File extensionFile : extensionFiles) {
        Assert.assertTrue(expectedNars.contains(extensionFile.getName()));
    }
}
Also used : NiFiProperties(org.apache.nifi.util.NiFiProperties) File(java.io.File) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

NiFiProperties (org.apache.nifi.util.NiFiProperties)98 Test (org.junit.Test)63 HashMap (java.util.HashMap)28 Properties (java.util.Properties)24 File (java.io.File)16 Bundle (org.apache.nifi.bundle.Bundle)13 Matchers.anyString (org.mockito.Matchers.anyString)13 IOException (java.io.IOException)10 HashSet (java.util.HashSet)10 Map (java.util.Map)8 X509Certificate (java.security.cert.X509Certificate)7 Mockito.anyString (org.mockito.Mockito.anyString)7 InputStream (java.io.InputStream)6 ArrayList (java.util.ArrayList)6 SystemBundle (org.apache.nifi.nar.SystemBundle)6 SslContextFactory (org.eclipse.jetty.util.ssl.SslContextFactory)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 IdentityMapping (org.apache.nifi.authorization.util.IdentityMapping)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 FileInputStream (java.io.FileInputStream)4