Merge branch 'NIFI-593' into develop

This commit is contained in:
Aldrin Piri 2015-05-06 09:11:24 -04:00
commit b70845b31e
2 changed files with 34 additions and 18 deletions

View File

@ -16,16 +16,19 @@
*/ */
package org.apache.nifi.util; package org.apache.nifi.util;
import static org.junit.Assert.assertEquals; import org.junit.Assert;
import org.junit.Test;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.InputStream; import java.io.InputStream;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
import org.junit.Test; import static org.junit.Assert.assertEquals;
public class NiFiPropertiesTest { public class NiFiPropertiesTest {
@ -36,13 +39,19 @@ public class NiFiPropertiesTest {
assertEquals("UI Banner Text", properties.getBannerText()); assertEquals("UI Banner Text", properties.getBannerText());
List<Path> directories = properties.getNarLibraryDirectories(); Set<File> expectedDirectories = new HashSet<>();
expectedDirectories.add(new File("./target/resources/NiFiProperties/lib/"));
expectedDirectories.add(new File("./target/resources/NiFiProperties/lib2/"));
assertEquals(new File("./target/resources/NiFiProperties/lib/").getPath(), Set<String> directories = new HashSet<>();
directories.get(0).toString()); for (Path narLibDir : properties.getNarLibraryDirectories()) {
assertEquals(new File("./target/resources/NiFiProperties/lib2/").getPath(), directories directories.add(narLibDir.toString());
.get(1).toString()); }
Assert.assertEquals("Did not have the anticipated number of directories", expectedDirectories.size(), directories.size());
for (File expectedDirectory : expectedDirectories) {
Assert.assertTrue("Listed directories did not contain expected directory", directories.contains(expectedDirectory.getPath()));
}
} }
@Test @Test

View File

@ -16,10 +16,10 @@
*/ */
package org.apache.nifi.nar; package org.apache.nifi.nar;
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; import org.apache.nifi.util.NiFiProperties;
import static org.junit.Assert.assertEquals; import org.junit.Assert;
import static org.junit.Assert.assertNull; import org.junit.BeforeClass;
import static org.junit.Assert.assertTrue; import org.junit.Test;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.File; import java.io.File;
@ -32,10 +32,13 @@ import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor; import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes; import java.nio.file.attribute.BasicFileAttributes;
import java.util.HashSet;
import java.util.Set;
import org.apache.nifi.util.NiFiProperties; import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
import org.junit.BeforeClass; import static org.junit.Assert.assertEquals;
import org.junit.Test; import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
public class NarUnpackerTest { public class NarUnpackerTest {
@ -92,13 +95,17 @@ public class NarUnpackerTest {
"org.apache.nifi.processors.dummy.one")); "org.apache.nifi.processors.dummy.one"));
assertTrue(extensionMapping.getAllExtensionNames().contains( assertTrue(extensionMapping.getAllExtensionNames().contains(
"org.apache.nifi.processors.dummy.two")); "org.apache.nifi.processors.dummy.two"));
final File extensionsWorkingDir = properties.getExtensionsWorkingDirectory(); final File extensionsWorkingDir = properties.getExtensionsWorkingDirectory();
File[] extensionFiles = extensionsWorkingDir.listFiles(); File[] extensionFiles = extensionsWorkingDir.listFiles();
assertEquals(2, extensionFiles.length); Set<String> expectedNars = new HashSet<>();
assertEquals("dummy-one.nar-unpacked", extensionFiles[0].getName()); expectedNars.add("dummy-one.nar-unpacked");
assertEquals("dummy-two.nar-unpacked", extensionFiles[1].getName()); expectedNars.add("dummy-two.nar-unpacked");
assertEquals(expectedNars.size(), extensionFiles.length);
for (File extensionFile : extensionFiles) {
Assert.assertTrue(expectedNars.contains(extensionFile.getName()));
}
} }
@Test @Test