diff --git a/nifi/nifi-commons/nifi-properties/src/test/java/org/apache/nifi/util/NiFiPropertiesTest.java b/nifi/nifi-commons/nifi-properties/src/test/java/org/apache/nifi/util/NiFiPropertiesTest.java index 344c74054b..0751275222 100644 --- a/nifi/nifi-commons/nifi-properties/src/test/java/org/apache/nifi/util/NiFiPropertiesTest.java +++ b/nifi/nifi-commons/nifi-properties/src/test/java/org/apache/nifi/util/NiFiPropertiesTest.java @@ -16,16 +16,19 @@ */ 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.File; import java.io.FileInputStream; import java.io.InputStream; import java.nio.file.Path; +import java.util.HashSet; import java.util.List; +import java.util.Set; -import org.junit.Test; +import static org.junit.Assert.assertEquals; public class NiFiPropertiesTest { @@ -36,13 +39,19 @@ public class NiFiPropertiesTest { assertEquals("UI Banner Text", properties.getBannerText()); - List directories = properties.getNarLibraryDirectories(); + Set 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(), - directories.get(0).toString()); - assertEquals(new File("./target/resources/NiFiProperties/lib2/").getPath(), directories - .get(1).toString()); + Set directories = new HashSet<>(); + for (Path narLibDir : properties.getNarLibraryDirectories()) { + directories.add(narLibDir.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 diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-nar-utils/src/test/java/org/apache/nifi/nar/NarUnpackerTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-nar-utils/src/test/java/org/apache/nifi/nar/NarUnpackerTest.java index 33b988db98..66e167ec82 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-nar-utils/src/test/java/org/apache/nifi/nar/NarUnpackerTest.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-nar-utils/src/test/java/org/apache/nifi/nar/NarUnpackerTest.java @@ -16,10 +16,10 @@ */ package org.apache.nifi.nar; -import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import org.apache.nifi.util.NiFiProperties; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; import java.io.BufferedInputStream; import java.io.File; @@ -32,10 +32,13 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; +import java.util.HashSet; +import java.util.Set; -import org.apache.nifi.util.NiFiProperties; -import org.junit.BeforeClass; -import org.junit.Test; +import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; public class NarUnpackerTest { @@ -92,13 +95,17 @@ public class NarUnpackerTest { "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(); - assertEquals(2, extensionFiles.length); - assertEquals("dummy-one.nar-unpacked", extensionFiles[0].getName()); - assertEquals("dummy-two.nar-unpacked", extensionFiles[1].getName()); + Set 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())); + } } @Test