exceptionfactory commented on a change in pull request #5791:
URL: https://github.com/apache/nifi/pull/5791#discussion_r815317202
##########
File path:
nifi-nar-bundles/nifi-hive-bundle/nifi-hive-processors/src/test/java/org/apache/nifi/processors/hive/TestUpdateHiveTable.java
##########
@@ -121,13 +120,10 @@
new String[]{"Location:",
"hdfs://mycluster:8020/warehouse/tablespace/managed/hive/_newTable", null}
};
- @Rule
- public TemporaryFolder folder = new TemporaryFolder();
Review comment:
This should be replaced with `@TempDir` and `Files.createTempDir()`
should be removed in `testSetup()`.
##########
File path:
nifi-nar-bundles/nifi-hive-bundle/nifi-hive_1_1-processors/src/test/java/org/apache/nifi/processors/hive/TestPutHive_1_1QL.java
##########
@@ -40,27 +39,24 @@
import java.util.HashMap;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class TestPutHive_1_1QL {
private static final String createPersons = "CREATE TABLE PERSONS (id
integer primary key, name varchar(100), code integer)";
private static final String createPersonsAutoId = "CREATE TABLE PERSONS
(id INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1), name
VARCHAR(100), code INTEGER check(code <= 100))";
- @Rule
- public TemporaryFolder folder = new TemporaryFolder();
Review comment:
This should be replaced with JUnit 5 `TempDir`.
##########
File path:
nifi-nar-bundles/nifi-hive-bundle/nifi-hive3-processors/src/test/java/org/apache/nifi/processors/orc/PutORCTest.java
##########
@@ -96,12 +100,12 @@
private PutORC proc;
private TestRunner testRunner;
- @BeforeClass
+ @BeforeAll
public static void setupBeforeClass() {
- Assume.assumeTrue("Test only runs on *nix",
!SystemUtils.IS_OS_WINDOWS);
+ BasicConfigurator.configure();
Review comment:
This reference to Log4j `BasicConfigurator` should be removed.
##########
File path:
nifi-nar-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/test/java/org/apache/nifi/processors/hadoop/GetHDFSTest.java
##########
@@ -62,12 +61,12 @@
private NiFiProperties mockNiFiProperties;
private KerberosProperties kerberosProperties;
- @BeforeClass
+ @BeforeAll
public static void setUpSuite() {
- Assume.assumeTrue("Test only runs on *nix",
!SystemUtils.IS_OS_WINDOWS);
+ assumeTrue(!SystemUtils.IS_OS_WINDOWS, "Test only runs on *nix");
Review comment:
This should be replaced with the `DisabledOnOs` class-level annotation.
##########
File path:
nifi-nar-bundles/nifi-hive-bundle/nifi-hive3-processors/src/test/java/org/apache/nifi/processors/hive/TestPutHive3QL.java
##########
@@ -40,27 +39,24 @@
import java.util.HashMap;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class TestPutHive3QL {
private static final String createPersons = "CREATE TABLE PERSONS (id
integer primary key, name varchar(100), code integer)";
private static final String createPersonsAutoId = "CREATE TABLE PERSONS
(id INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1), name
VARCHAR(100), code INTEGER check(code <= 100))";
- @Rule
- public TemporaryFolder folder = new TemporaryFolder();
Review comment:
These changes should be adjusted to use JUnit 5 `TempDir` and usage of
`Files.createTempDir()`.
##########
File path:
nifi-nar-bundles/nifi-hive-bundle/nifi-hive3-processors/src/test/java/org/apache/nifi/processors/hive/TestUpdateHive3Table.java
##########
@@ -124,15 +123,12 @@
new String[]{"Location:",
"hdfs://mycluster:8020/warehouse/tablespace/managed/hive/_newTable", null}
};
- @Rule
- public TemporaryFolder folder = new TemporaryFolder();
Review comment:
This should be replaced with JUnit 5 `@TempDir`
##########
File path:
nifi-nar-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/test/java/org/apache/nifi/processors/hadoop/AbstractHadoopTest.java
##########
@@ -117,26 +117,35 @@ public void testErrorConditions() {
if (pc instanceof MockProcessContext) {
results = ((MockProcessContext) pc).validate();
}
- Assert.assertEquals(1, results.size());
+ assertEquals(1, results.size());
}
@Test
- public void testTimeoutDetection() throws Exception {
+ public void testTimeoutDetection() {
SimpleHadoopProcessor processor = new
SimpleHadoopProcessor(kerberosProperties);
TestRunner runner = TestRunners.newTestRunner(processor);
- try {
+ assertThrows(IOException.class, () -> {
final File brokenCoreSite = new
File("src/test/resources/core-site-broken.xml");
final ResourceReference brokenCoreSiteReference = new
FileResourceReference(brokenCoreSite);
final ResourceReferences references = new
StandardResourceReferences(Collections.singletonList(brokenCoreSiteReference));
final List<String> locations = references.asLocations();
processor.resetHDFSResources(locations,
runner.getProcessContext());
- Assert.fail("Should have thrown SocketTimeoutException");
- } catch (IOException e) {
- }
+ });
+
+// try {
+// final File brokenCoreSite = new
File("src/test/resources/core-site-broken.xml");
+// final ResourceReference brokenCoreSiteReference = new
FileResourceReference(brokenCoreSite);
+// final ResourceReferences references = new
StandardResourceReferences(Collections.singletonList(brokenCoreSiteReference));
+// final List<String> locations = references.asLocations();
+// processor.resetHDFSResources(locations,
runner.getProcessContext());
+// Assert.fail("Should have thrown SocketTimeoutException");
+// } catch (IOException e) {
+// e.printStackTrace();
+// }
Review comment:
These commented lines should be removed.
##########
File path:
nifi-nar-bundles/nifi-hive-bundle/nifi-hive_1_1-processors/src/test/java/org/apache/nifi/processors/hive/TestUpdateHive_1_1Table.java
##########
@@ -122,13 +118,10 @@
new String[]{"Location:",
"hdfs://mycluster:8020/warehouse/tablespace/managed/hive/_newTable", null}
};
- @Rule
- public TemporaryFolder folder = new TemporaryFolder();
Review comment:
This should be replaced with JUnit 5 `TempDir`.
##########
File path:
nifi-nar-bundles/nifi-hive-bundle/nifi-hive-processors/src/test/java/org/apache/nifi/processors/hive/TestPutHiveQL.java
##########
@@ -42,25 +41,22 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
public class TestPutHiveQL {
private static final String createPersons = "CREATE TABLE PERSONS (id
integer primary key, name varchar(100), code integer)";
private static final String createPersonsAutoId = "CREATE TABLE PERSONS
(id INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1), name
VARCHAR(100), code INTEGER check(code <= 100))";
- @Rule
- public TemporaryFolder folder = new TemporaryFolder();
Review comment:
Replacing this approach with `Files.createTempDir()` in individual
methods results in a number of directories that need to be cleaned up. Can this
approach be changed to use the JUnit 5 `TempDir` annotation so that the use of
`Files.createTempDir()` can be removed?
##########
File path:
nifi-nar-bundles/nifi-hive-bundle/nifi-hive_1_1-processors/src/test/java/org/apache/nifi/processors/hive/TestPutHive_1_1QL.java
##########
@@ -15,6 +15,7 @@
* limitations under the License.
*/
+import com.google.common.io.Files;
Review comment:
Usage of Google Guava should be avoided.
##########
File path:
nifi-nar-bundles/nifi-hive-bundle/nifi-hive3-processors/src/test/java/org/apache/nifi/processors/orc/PutORCTest.java
##########
@@ -34,6 +33,7 @@
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo;
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils;
import org.apache.hadoop.io.IntWritable;
+import org.apache.log4j.BasicConfigurator;
Review comment:
Usage of Log4j should be removed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]