This is an automated email from the ASF dual-hosted git repository.

exceptionfactory pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/main by this push:
     new ba75357664 NIFI-15282 Enabled JSON Tests on Windows with conditional 
newline handling (#10604)
ba75357664 is described below

commit ba75357664d1b6f003e8b384914d8e1cafb58375
Author: dan-s1 <[email protected]>
AuthorDate: Fri Dec 5 15:27:38 2025 -0500

    NIFI-15282 Enabled JSON Tests on Windows with conditional newline handling 
(#10604)
    
    Signed-off-by: David Handermann <[email protected]>
---
 .../processors/jolt/TestJoltTransformRecord.java   | 68 ++++++++-----------
 .../processors/standard/TestConvertRecord.java     |  6 +-
 .../nifi/processors/standard/TestForkRecord.java   | 78 +++++++++-------------
 .../nifi/processors/standard/util/JsonUtil.java    | 38 +++++++++++
 4 files changed, 100 insertions(+), 90 deletions(-)

diff --git 
a/nifi-extension-bundles/nifi-jolt-bundle/nifi-jolt-processors/src/test/java/org/apache/nifi/processors/jolt/TestJoltTransformRecord.java
 
b/nifi-extension-bundles/nifi-jolt-bundle/nifi-jolt-processors/src/test/java/org/apache/nifi/processors/jolt/TestJoltTransformRecord.java
index 308bb9dd42..9e70d6a8f6 100644
--- 
a/nifi-extension-bundles/nifi-jolt-bundle/nifi-jolt-processors/src/test/java/org/apache/nifi/processors/jolt/TestJoltTransformRecord.java
+++ 
b/nifi-extension-bundles/nifi-jolt-bundle/nifi-jolt-processors/src/test/java/org/apache/nifi/processors/jolt/TestJoltTransformRecord.java
@@ -37,8 +37,6 @@ import org.apache.nifi.util.TestRunners;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.DisabledOnOs;
-import org.junit.jupiter.api.condition.OS;
 import org.junit.jupiter.params.ParameterizedTest;
 import org.junit.jupiter.params.provider.Arguments;
 import org.junit.jupiter.params.provider.MethodSource;
@@ -61,7 +59,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
-@DisabledOnOs(OS.WINDOWS) //The pretty printed json comparisons don't work on 
windows
 public class TestJoltTransformRecord {
 
     final static String CHAINR_SPEC_PATH = 
"src/test/resources/specs/chainrSpec.json";
@@ -301,8 +298,7 @@ public class TestJoltTransformRecord {
         final MockFlowFile transformed = 
runner.getFlowFilesForRelationship(JoltTransformRecord.REL_SUCCESS).getFirst();
         transformed.assertAttributeExists(CoreAttributes.MIME_TYPE.key());
         transformed.assertAttributeEquals(CoreAttributes.MIME_TYPE.key(), 
"application/json");
-        
assertEquals(Files.readString(Paths.get("src/test/resources/TestJoltTransformRecord/chainrOutput.json")),
-                new String(transformed.toByteArray()));
+        
transformed.assertContentEquals(getExpectedContent("src/test/resources/TestJoltTransformRecord/chainrOutput.json"));
     }
 
     @Test
@@ -323,8 +319,7 @@ public class TestJoltTransformRecord {
         final MockFlowFile transformed = 
runner.getFlowFilesForRelationship(JoltTransformRecord.REL_SUCCESS).getFirst();
         transformed.assertAttributeExists(CoreAttributes.MIME_TYPE.key());
         transformed.assertAttributeEquals(CoreAttributes.MIME_TYPE.key(), 
"application/json");
-        
assertEquals(Files.readString(Paths.get("src/test/resources/TestJoltTransformRecord/shiftrOutput.json")),
-                new String(transformed.toByteArray()));
+        
transformed.assertContentEquals(getExpectedContent("src/test/resources/TestJoltTransformRecord/shiftrOutput.json"));
     }
 
     @Test
@@ -345,8 +340,7 @@ public class TestJoltTransformRecord {
         final MockFlowFile transformed = 
runner.getFlowFilesForRelationship(JoltTransformRecord.REL_SUCCESS).getFirst();
         transformed.assertAttributeExists(CoreAttributes.MIME_TYPE .key());
         transformed.assertAttributeEquals(CoreAttributes.MIME_TYPE.key(), 
"application/json");
-        
assertEquals(Files.readString(Paths.get("src/test/resources/TestJoltTransformRecord/shiftrOutput.json")),
-                new String(transformed.toByteArray()));
+        
transformed.assertContentEquals(getExpectedContent("src/test/resources/TestJoltTransformRecord/shiftrOutput.json"));
     }
 
     @Test
@@ -385,8 +379,7 @@ public class TestJoltTransformRecord {
         final MockFlowFile transformed = 
runner.getFlowFilesForRelationship(JoltTransformRecord.REL_SUCCESS).getFirst();
         transformed.assertAttributeExists(CoreAttributes.MIME_TYPE.key());
         transformed.assertAttributeEquals(CoreAttributes.MIME_TYPE.key(), 
"application/json");
-        
assertEquals(Files.readString(Paths.get("src/test/resources/TestJoltTransformRecord/shiftrOutputMultipleOutputRecords.json")),
-                new String(transformed.toByteArray()));
+        
transformed.assertContentEquals(getExpectedContent("src/test/resources/TestJoltTransformRecord/shiftrOutputMultipleOutputRecords.json"));
     }
 
     @Test
@@ -407,8 +400,7 @@ public class TestJoltTransformRecord {
         final MockFlowFile transformed = 
runner.getFlowFilesForRelationship(JoltTransformRecord.REL_SUCCESS).getFirst();
         transformed.assertAttributeExists(CoreAttributes.MIME_TYPE.key());
         transformed.assertAttributeEquals(CoreAttributes.MIME_TYPE.key(), 
"application/json");
-        
assertEquals(Files.readString(Paths.get("src/test/resources/TestJoltTransformRecord/shiftrOutput.json")),
-                new String(transformed.toByteArray()));
+        
transformed.assertContentEquals(getExpectedContent("src/test/resources/TestJoltTransformRecord/shiftrOutput.json"));
     }
 
     @Test
@@ -427,8 +419,7 @@ public class TestJoltTransformRecord {
         runner.assertTransferCount(JoltTransformRecord.REL_SUCCESS, 1);
         runner.assertTransferCount(JoltTransformRecord.REL_ORIGINAL, 1);
         final MockFlowFile transformed = 
runner.getFlowFilesForRelationship(JoltTransformRecord.REL_SUCCESS).getFirst();
-        
assertEquals(Files.readString(Paths.get("src/test/resources/TestJoltTransformRecord/defaultrOutput.json")),
-                new String(transformed.toByteArray()));
+        
transformed.assertContentEquals(getExpectedContent("src/test/resources/TestJoltTransformRecord/defaultrOutput.json"));
     }
 
     @Test
@@ -447,9 +438,7 @@ public class TestJoltTransformRecord {
         runner.assertTransferCount(JoltTransformRecord.REL_SUCCESS, 1);
         runner.assertTransferCount(JoltTransformRecord.REL_ORIGINAL, 1);
         final MockFlowFile transformed = 
runner.getFlowFilesForRelationship(JoltTransformRecord.REL_SUCCESS).getFirst();
-        
assertEquals(Files.readString(Paths.get("src/test/resources/TestJoltTransformRecord/removrOutput.json")),
-                new String(transformed.toByteArray()));
-
+        
transformed.assertContentEquals(getExpectedContent("src/test/resources/TestJoltTransformRecord/removrOutput.json"));
     }
 
     @Test
@@ -468,9 +457,7 @@ public class TestJoltTransformRecord {
         runner.assertTransferCount(JoltTransformRecord.REL_SUCCESS, 1);
         runner.assertTransferCount(JoltTransformRecord.REL_ORIGINAL, 1);
         final MockFlowFile transformed = 
runner.getFlowFilesForRelationship(JoltTransformRecord.REL_SUCCESS).getFirst();
-        
assertEquals(Files.readString(Paths.get("src/test/resources/TestJoltTransformRecord/cardrOutput.json")),
-                new String(transformed.toByteArray()));
-
+        
transformed.assertContentEquals(getExpectedContent("src/test/resources/TestJoltTransformRecord/cardrOutput.json"));
     }
 
     @Test
@@ -489,8 +476,7 @@ public class TestJoltTransformRecord {
         final MockFlowFile transformed = 
runner.getFlowFilesForRelationship(JoltTransformRecord.REL_SUCCESS).getFirst();
         transformed.assertAttributeExists(CoreAttributes.MIME_TYPE.key());
         transformed.assertAttributeEquals(CoreAttributes.MIME_TYPE.key(), 
"application/json");
-        
assertEquals(Files.readString(Paths.get("src/test/resources/TestJoltTransformRecord/sortrOutput.json")),
-                new String(transformed.toByteArray()));
+        
transformed.assertContentEquals(getExpectedContent("src/test/resources/TestJoltTransformRecord/sortrOutput.json"));
     }
 
     @Test
@@ -510,9 +496,7 @@ public class TestJoltTransformRecord {
         runner.assertTransferCount(JoltTransformRecord.REL_SUCCESS, 1);
         runner.assertTransferCount(JoltTransformRecord.REL_ORIGINAL, 1);
         final MockFlowFile transformed = 
runner.getFlowFilesForRelationship(JoltTransformRecord.REL_SUCCESS).getFirst();
-        
assertEquals(Files.readString(Paths.get("src/test/resources/TestJoltTransformRecord/defaultrELOutput.json")),
-                new String(transformed.toByteArray()));
-
+        
transformed.assertContentEquals(getExpectedContent("src/test/resources/TestJoltTransformRecord/defaultrELOutput.json"));
     }
 
     @Test
@@ -531,8 +515,7 @@ public class TestJoltTransformRecord {
         runner.run();
         runner.assertTransferCount(JoltTransformRecord.REL_SUCCESS, 1);
         final MockFlowFile transformed = 
runner.getFlowFilesForRelationship(JoltTransformRecord.REL_SUCCESS).getFirst();
-        
assertEquals(Files.readString(Paths.get("src/test/resources/TestJoltTransformRecord/modifierDefaultOutput.json")),
-                new String(transformed.toByteArray()));
+        
transformed.assertContentEquals(getExpectedContent("src/test/resources/TestJoltTransformRecord/modifierDefaultOutput.json"));
     }
 
     @Test
@@ -551,8 +534,7 @@ public class TestJoltTransformRecord {
         runner.assertTransferCount(JoltTransformRecord.REL_SUCCESS, 1);
         runner.assertTransferCount(JoltTransformRecord.REL_ORIGINAL, 1);
         final MockFlowFile transformed = 
runner.getFlowFilesForRelationship(JoltTransformRecord.REL_SUCCESS).getFirst();
-        
assertEquals(Files.readString(Paths.get("src/test/resources/TestJoltTransformRecord/modifierDefineOutput.json")),
-                new String(transformed.toByteArray()));
+        
transformed.assertContentEquals(getExpectedContent("src/test/resources/TestJoltTransformRecord/modifierDefineOutput.json"));
     }
 
     @Test
@@ -571,8 +553,7 @@ public class TestJoltTransformRecord {
         runner.assertTransferCount(JoltTransformRecord.REL_SUCCESS, 1);
         runner.assertTransferCount(JoltTransformRecord.REL_ORIGINAL, 1);
         final MockFlowFile transformed = 
runner.getFlowFilesForRelationship(JoltTransformRecord.REL_SUCCESS).getFirst();
-        
assertEquals(Files.readString(Paths.get("src/test/resources/TestJoltTransformRecord/modifierOverwriteOutput.json")),
-                new String(transformed.toByteArray()));
+        
transformed.assertContentEquals(getExpectedContent("src/test/resources/TestJoltTransformRecord/modifierOverwriteOutput.json"));
     }
 
     @Test
@@ -592,8 +573,7 @@ public class TestJoltTransformRecord {
         final MockFlowFile transformed = 
runner.getFlowFilesForRelationship(JoltTransformRecord.REL_SUCCESS).getFirst();
         transformed.assertAttributeExists(CoreAttributes.MIME_TYPE.key());
         transformed.assertAttributeEquals(CoreAttributes.MIME_TYPE.key(), 
"application/json");
-        
assertEquals(Files.readString(Paths.get("src/test/resources/TestJoltTransformRecord/sortrOutput.json")),
-                new String(transformed.toByteArray()));
+        
transformed.assertContentEquals(getExpectedContent("src/test/resources/TestJoltTransformRecord/sortrOutput.json"));
     }
 
     @Test
@@ -617,8 +597,7 @@ public class TestJoltTransformRecord {
         final MockFlowFile transformed = 
runner.getFlowFilesForRelationship(JoltTransformRecord.REL_SUCCESS).getFirst();
         transformed.assertAttributeExists(CoreAttributes.MIME_TYPE.key());
         transformed.assertAttributeEquals(CoreAttributes.MIME_TYPE.key(), 
"application/json");
-        
assertEquals(Files.readString(Paths.get("src/test/resources/TestJoltTransformRecord/defaultrOutput.json")),
-                new String(transformed.toByteArray()));
+        
transformed.assertContentEquals(getExpectedContent("src/test/resources/TestJoltTransformRecord/defaultrOutput.json"));
     }
 
     @Test
@@ -670,8 +649,7 @@ public class TestJoltTransformRecord {
         runner.assertTransferCount(JoltTransformRecord.REL_ORIGINAL, 1);
 
         final MockFlowFile transformed = 
runner.getFlowFilesForRelationship(JoltTransformRecord.REL_SUCCESS).getFirst();
-        
assertEquals(Files.readString(Paths.get("src/test/resources/TestJoltTransformRecord/defaultrOutput.json")),
-                new String(transformed.toByteArray()));
+        
transformed.assertContentEquals(getExpectedContent("src/test/resources/TestJoltTransformRecord/defaultrOutput.json"));
     }
 
     @Test
@@ -707,8 +685,7 @@ public class TestJoltTransformRecord {
         runner.assertTransferCount(JoltTransformRecord.REL_ORIGINAL, 1);
 
         final MockFlowFile transformed = 
runner.getFlowFilesForRelationship(JoltTransformRecord.REL_SUCCESS).getFirst();
-        
assertEquals(Files.readString(Paths.get("src/test/resources/TestJoltTransformRecord/flattenedOutput.json")),
-                new String(transformed.toByteArray()));
+        
transformed.assertContentEquals(getExpectedContent("src/test/resources/TestJoltTransformRecord/flattenedOutput.json"));
     }
 
     private static Stream<Arguments> getChainrArguments() {
@@ -747,4 +724,15 @@ public class TestJoltTransformRecord {
             recordGenerator.apply(numRecords, parser);
         }
     }
+
+    private static String getExpectedContent(String path) throws IOException {
+        final boolean windows = 
System.getProperty("os.name").startsWith("Windows");
+        String expectedContent = Files.readString(Paths.get(path));
+
+        if (windows) {
+            expectedContent = expectedContent.replaceAll("\n", "\r\n");
+        }
+
+        return expectedContent;
+    }
 }
diff --git 
a/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestConvertRecord.java
 
b/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestConvertRecord.java
index 18c934145f..502757f161 100644
--- 
a/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestConvertRecord.java
+++ 
b/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestConvertRecord.java
@@ -26,6 +26,7 @@ import org.apache.nifi.csv.CSVRecordSetWriter;
 import org.apache.nifi.csv.CSVUtils;
 import org.apache.nifi.json.JsonRecordSetWriter;
 import org.apache.nifi.json.JsonTreeReader;
+import org.apache.nifi.processors.standard.util.JsonUtil;
 import org.apache.nifi.reporting.InitializationException;
 import org.apache.nifi.schema.access.SchemaAccessUtils;
 import org.apache.nifi.schema.inference.SchemaInferenceUtil;
@@ -39,8 +40,6 @@ import org.apache.nifi.util.TestRunners;
 import org.apache.nifi.xml.XMLReader;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.DisabledOnOs;
-import org.junit.jupiter.api.condition.OS;
 import org.xerial.snappy.SnappyInputStream;
 
 import java.io.ByteArrayInputStream;
@@ -58,7 +57,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
-@DisabledOnOs(value = OS.WINDOWS, disabledReason = "Pretty-printing is not 
portable across operating systems")
 public class TestConvertRecord {
 
     private static final String PERSON_SCHEMA;
@@ -288,7 +286,7 @@ public class TestConvertRecord {
             out.flush();
         }
 
-        assertEquals(Files.readString(person), 
baos.toString(StandardCharsets.UTF_8));
+        assertEquals(JsonUtil.getExpectedContent(person), 
baos.toString(StandardCharsets.UTF_8));
     }
 
     @Test
diff --git 
a/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestForkRecord.java
 
b/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestForkRecord.java
index db0fff865d..93594d0111 100644
--- 
a/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestForkRecord.java
+++ 
b/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestForkRecord.java
@@ -24,9 +24,9 @@ import org.apache.nifi.json.JsonRecordSetWriter;
 import org.apache.nifi.json.JsonTreeReader;
 import org.apache.nifi.json.JsonTreeRowRecordReader;
 import org.apache.nifi.logging.ComponentLog;
+import org.apache.nifi.processors.standard.util.JsonUtil;
 import org.apache.nifi.reporting.InitializationException;
 import org.apache.nifi.schema.access.SchemaAccessUtils;
-import org.apache.nifi.schema.access.SchemaNotFoundException;
 import org.apache.nifi.serialization.MalformedRecordException;
 import org.apache.nifi.serialization.RecordReader;
 import org.apache.nifi.serialization.RecordReaderFactory;
@@ -39,9 +39,8 @@ import org.apache.nifi.serialization.record.RecordSchema;
 import org.apache.nifi.util.MockFlowFile;
 import org.apache.nifi.util.TestRunner;
 import org.apache.nifi.util.TestRunners;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.DisabledOnOs;
-import org.junit.jupiter.api.condition.OS;
 
 import java.io.File;
 import java.io.IOException;
@@ -52,12 +51,12 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
-@DisabledOnOs(value = OS.WINDOWS, disabledReason = "Pretty printing is not 
portable as these fail on windows")
 public class TestForkRecord {
 
     private final String dateFormat = RecordFieldType.DATE.getDefaultFormat();
     private final String timeFormat = RecordFieldType.TIME.getDefaultFormat();
     private final String timestampFormat = 
RecordFieldType.TIMESTAMP.getDefaultFormat();
+    private TestRunner runner;
 
     private List<RecordField> getDefaultFields() {
         final List<RecordField> fields = new ArrayList<>();
@@ -97,10 +96,13 @@ public class TestForkRecord {
         return new SimpleRecordSchema(transactionFields);
     }
 
-    @Test
-    public void testForkExtractSimpleWithoutParentFields() throws IOException, 
MalformedRecordException, InitializationException {
-        TestRunner runner = TestRunners.newTestRunner(new ForkRecord());
+    @BeforeEach
+    void setUp() {
+        runner = TestRunners.newTestRunner(ForkRecord.class);
+    }
 
+    @Test
+    public void testForkExtractSimpleWithoutParentFields() throws IOException, 
InitializationException {
         final DataType accountRecordType = 
RecordFieldType.RECORD.getRecordDataType(getAccountSchema());
         final DataType accountsType = 
RecordFieldType.ARRAY.getArrayDataType(accountRecordType);
 
@@ -126,15 +128,13 @@ public class TestForkRecord {
         runner.assertTransferCount(ForkRecord.REL_ORIGINAL, 1);
         runner.assertTransferCount(ForkRecord.REL_FORK, 1);
 
-        final MockFlowFile mff = 
runner.getFlowFilesForRelationship(ForkRecord.REL_FORK).get(0);
+        final MockFlowFile mff = 
runner.getFlowFilesForRelationship(ForkRecord.REL_FORK).getFirst();
         mff.assertAttributeEquals("record.count", "2");
         mff.assertContentEquals("header\n42,4750.89\n43,48212.38\n");
     }
 
     @Test
-    public void testForkExtractSimpleWithParentFields() throws IOException, 
MalformedRecordException, InitializationException {
-        TestRunner runner = TestRunners.newTestRunner(new ForkRecord());
-
+    public void testForkExtractSimpleWithParentFields() throws IOException, 
InitializationException {
         final DataType accountRecordType = 
RecordFieldType.RECORD.getRecordDataType(getAccountSchema());
         final DataType accountsType = 
RecordFieldType.ARRAY.getArrayDataType(accountRecordType);
 
@@ -165,15 +165,13 @@ public class TestForkRecord {
         runner.assertTransferCount(ForkRecord.REL_ORIGINAL, 1);
         runner.assertTransferCount(ForkRecord.REL_FORK, 1);
 
-        final MockFlowFile mff = 
runner.getFlowFilesForRelationship(ForkRecord.REL_FORK).get(0);
+        final MockFlowFile mff = 
runner.getFlowFilesForRelationship(ForkRecord.REL_FORK).getFirst();
         mff.assertAttributeEquals("record.count", "2");
         mff.assertContentEquals("header\n42,John Doe,123 My Street,My 
City,MS,11111,USA,4750.89\n43,John Doe,123 My Street,My 
City,MS,11111,USA,48212.38\n");
     }
 
     @Test
-    public void testForkExtractNotAnArray() throws IOException, 
MalformedRecordException, InitializationException {
-        TestRunner runner = TestRunners.newTestRunner(new ForkRecord());
-
+    public void testForkExtractNotAnArray() throws IOException, 
InitializationException {
         final DataType accountRecordType = 
RecordFieldType.RECORD.getRecordDataType(getAccountSchema());
         final DataType accountsType = 
RecordFieldType.ARRAY.getArrayDataType(accountRecordType);
 
@@ -204,14 +202,12 @@ public class TestForkRecord {
         runner.assertTransferCount(ForkRecord.REL_ORIGINAL, 1);
         runner.assertTransferCount(ForkRecord.REL_FORK, 1);
 
-        final MockFlowFile mff = 
runner.getFlowFilesForRelationship(ForkRecord.REL_FORK).get(0);
+        final MockFlowFile mff = 
runner.getFlowFilesForRelationship(ForkRecord.REL_FORK).getFirst();
         mff.assertAttributeEquals("record.count", "0");
     }
 
     @Test
-    public void testForkExtractNotAnArrayOfRecords() throws IOException, 
MalformedRecordException, InitializationException {
-        TestRunner runner = TestRunners.newTestRunner(new ForkRecord());
-
+    public void testForkExtractNotAnArrayOfRecords() throws IOException, 
InitializationException {
         final DataType accountRecordType = 
RecordFieldType.STRING.getDataType();
         final DataType accountsType = 
RecordFieldType.ARRAY.getArrayDataType(accountRecordType);
 
@@ -242,14 +238,12 @@ public class TestForkRecord {
         runner.assertTransferCount(ForkRecord.REL_ORIGINAL, 1);
         runner.assertTransferCount(ForkRecord.REL_FORK, 1);
 
-        final MockFlowFile mff = 
runner.getFlowFilesForRelationship(ForkRecord.REL_FORK).get(0);
+        final MockFlowFile mff = 
runner.getFlowFilesForRelationship(ForkRecord.REL_FORK).getFirst();
         mff.assertAttributeEquals("record.count", "0");
     }
 
     @Test
-    public void testForkExtractComplexWithParentFields() throws IOException, 
MalformedRecordException, InitializationException {
-        TestRunner runner = TestRunners.newTestRunner(new ForkRecord());
-
+    public void testForkExtractComplexWithParentFields() throws IOException, 
InitializationException {
         final DataType accountRecordType = 
RecordFieldType.RECORD.getRecordDataType(getAccountWithTransactionSchema());
         final DataType accountsType = 
RecordFieldType.ARRAY.getArrayDataType(accountRecordType);
 
@@ -281,16 +275,14 @@ public class TestForkRecord {
         runner.assertTransferCount(ForkRecord.REL_ORIGINAL, 1);
         runner.assertTransferCount(ForkRecord.REL_FORK, 1);
 
-        final MockFlowFile mff = 
runner.getFlowFilesForRelationship(ForkRecord.REL_FORK).get(0);
+        final MockFlowFile mff = 
runner.getFlowFilesForRelationship(ForkRecord.REL_FORK).getFirst();
         mff.assertAttributeEquals("record.count", "4");
         mff.assertContentEquals("header\n5,John Doe,123 My Street,My 
City,MS,11111,USA,4750.89,150.31\n6,John Doe,123 My Street,My 
City,MS,11111,USA,4750.89,-15.31\n"
                 + "7,John Doe,123 My Street,My 
City,MS,11111,USA,48212.38,36.78\n8,John Doe,123 My Street,My 
City,MS,11111,USA,48212.38,-21.34\n");
     }
 
     @Test
-    public void testForkExtractComplexWithoutParentFields() throws 
IOException, MalformedRecordException, InitializationException {
-        TestRunner runner = TestRunners.newTestRunner(new ForkRecord());
-
+    public void testForkExtractComplexWithoutParentFields() throws 
IOException, InitializationException {
         final DataType accountRecordType = 
RecordFieldType.RECORD.getRecordDataType(getAccountWithTransactionSchema());
         final DataType accountsType = 
RecordFieldType.ARRAY.getArrayDataType(accountRecordType);
 
@@ -322,15 +314,13 @@ public class TestForkRecord {
         runner.assertTransferCount(ForkRecord.REL_ORIGINAL, 1);
         runner.assertTransferCount(ForkRecord.REL_FORK, 1);
 
-        final MockFlowFile mff = 
runner.getFlowFilesForRelationship(ForkRecord.REL_FORK).get(0);
+        final MockFlowFile mff = 
runner.getFlowFilesForRelationship(ForkRecord.REL_FORK).getFirst();
         mff.assertAttributeEquals("record.count", "4");
         
mff.assertContentEquals("header\n5,150.31\n6,-15.31\n7,36.78\n8,-21.34\n");
     }
 
     @Test
-    public void testForkExtractComplexWithParentFieldsAndNull() throws 
IOException, MalformedRecordException, InitializationException {
-        TestRunner runner = TestRunners.newTestRunner(new ForkRecord());
-
+    public void testForkExtractComplexWithParentFieldsAndNull() throws 
IOException, InitializationException {
         final DataType accountRecordType = 
RecordFieldType.RECORD.getRecordDataType(getAccountWithTransactionSchema());
         final DataType accountsType = 
RecordFieldType.ARRAY.getArrayDataType(accountRecordType);
 
@@ -362,7 +352,7 @@ public class TestForkRecord {
         runner.assertTransferCount(ForkRecord.REL_ORIGINAL, 1);
         runner.assertTransferCount(ForkRecord.REL_FORK, 1);
 
-        final MockFlowFile mff = 
runner.getFlowFilesForRelationship(ForkRecord.REL_FORK).get(0);
+        final MockFlowFile mff = 
runner.getFlowFilesForRelationship(ForkRecord.REL_FORK).getFirst();
         mff.assertAttributeEquals("record.count", "4");
         mff.assertContentEquals("header\n5,John Doe,123 My Street,My 
City,MS,11111,USA,4750.89,150.31\n6,John Doe,123 My Street,My 
City,MS,11111,USA,4750.89,-15.31\n"
                 + "7,John Doe,123 My Street,My 
City,MS,11111,USA,48212.38,36.78\n8,John Doe,123 My Street,My 
City,MS,11111,USA,48212.38,-21.34\n");
@@ -370,8 +360,6 @@ public class TestForkRecord {
 
     @Test
     public void testSplitMode() throws InitializationException, IOException {
-        String expectedOutput = null;
-        final TestRunner runner = TestRunners.newTestRunner(new ForkRecord());
         final JsonTreeReader jsonReader = new JsonTreeReader();
         runner.addControllerService("record-reader", jsonReader);
 
@@ -399,9 +387,9 @@ public class TestForkRecord {
         runner.run();
         runner.assertTransferCount(ForkRecord.REL_ORIGINAL, 1);
         runner.assertTransferCount(ForkRecord.REL_FORK, 1);
-        expectedOutput = new 
String(Files.readAllBytes(Paths.get("src/test/resources/TestForkRecord/output/split-address.json")));
-        
runner.getFlowFilesForRelationship(ForkRecord.REL_FORK).get(0).assertContentEquals(expectedOutput);
-        
runner.getFlowFilesForRelationship(ForkRecord.REL_FORK).get(0).assertAttributeEquals("record.count",
 "5");
+        String expectedContent = 
JsonUtil.getExpectedContent(Paths.get("src/test/resources/TestForkRecord/output/split-address.json"));
+        
runner.getFlowFilesForRelationship(ForkRecord.REL_FORK).getFirst().assertContentEquals(expectedContent);
+        
runner.getFlowFilesForRelationship(ForkRecord.REL_FORK).getFirst().assertAttributeEquals("record.count",
 "5");
 
         runner.clearTransferState();
         runner.setProperty("my-path", "/bankAccounts[*]/last5Transactions");
@@ -409,15 +397,13 @@ public class TestForkRecord {
         runner.run();
         runner.assertTransferCount(ForkRecord.REL_ORIGINAL, 1);
         runner.assertTransferCount(ForkRecord.REL_FORK, 1);
-        expectedOutput = new 
String(Files.readAllBytes(Paths.get("src/test/resources/TestForkRecord/output/split-transactions.json")));
-        
runner.getFlowFilesForRelationship(ForkRecord.REL_FORK).get(0).assertContentEquals(expectedOutput);
-        
runner.getFlowFilesForRelationship(ForkRecord.REL_FORK).get(0).assertAttributeEquals("record.count",
 "6");
+        expectedContent = 
JsonUtil.getExpectedContent(Paths.get("src/test/resources/TestForkRecord/output/split-transactions.json"));
+        
runner.getFlowFilesForRelationship(ForkRecord.REL_FORK).getFirst().assertContentEquals(expectedContent);
+        
runner.getFlowFilesForRelationship(ForkRecord.REL_FORK).getFirst().assertAttributeEquals("record.count",
 "6");
     }
 
     @Test
     public void testExtractMode() throws InitializationException, IOException {
-        String expectedOutput = null;
-        final TestRunner runner = TestRunners.newTestRunner(new ForkRecord());
         final JsonTreeReader jsonReader = new JsonTreeReader();
         runner.addControllerService("record-reader", jsonReader);
 
@@ -446,9 +432,9 @@ public class TestForkRecord {
         runner.run();
         runner.assertTransferCount(ForkRecord.REL_ORIGINAL, 1);
         runner.assertTransferCount(ForkRecord.REL_FORK, 1);
-        expectedOutput = new 
String(Files.readAllBytes(Paths.get("src/test/resources/TestForkRecord/output/extract-transactions.json")));
-        
runner.getFlowFilesForRelationship(ForkRecord.REL_FORK).get(0).assertContentEquals(expectedOutput);
-        
runner.getFlowFilesForRelationship(ForkRecord.REL_FORK).get(0).assertAttributeEquals("record.count",
 "6");
+        String expectedContent = 
JsonUtil.getExpectedContent(Paths.get("src/test/resources/TestForkRecord/output/extract-transactions.json"));
+        
runner.getFlowFilesForRelationship(ForkRecord.REL_FORK).getFirst().assertContentEquals(expectedContent);
+        
runner.getFlowFilesForRelationship(ForkRecord.REL_FORK).getFirst().assertAttributeEquals("record.count",
 "6");
     }
 
     private class JsonRecordReader extends AbstractControllerService 
implements RecordReaderFactory {
@@ -483,7 +469,7 @@ public class TestForkRecord {
         }
 
         @Override
-        public RecordSchema getSchema(Map<String, String> variables, 
RecordSchema readSchema) throws SchemaNotFoundException, IOException {
+        public RecordSchema getSchema(Map<String, String> variables, 
RecordSchema readSchema) {
             return this.schema;
         }
 
diff --git 
a/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/util/JsonUtil.java
 
b/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/util/JsonUtil.java
new file mode 100644
index 0000000000..77adedce54
--- /dev/null
+++ 
b/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/util/JsonUtil.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.processors.standard.util;
+
+import java.io.IOException;
+import java.nio.file.Files;
+
+import java.nio.file.Path;
+
+public class JsonUtil {
+    private JsonUtil() {
+    }
+
+    public static String getExpectedContent(Path path) throws IOException {
+        final boolean windows = 
System.getProperty("os.name").startsWith("Windows");
+        String expectedContent = Files.readString(path);
+
+        if (windows) {
+            expectedContent = expectedContent.replaceAll("\n", "\r\n");
+        }
+
+        return expectedContent;
+    }
+}

Reply via email to