knguyen1 commented on code in PR #8417:
URL: https://github.com/apache/nifi/pull/8417#discussion_r1492873788
##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestEncodeContent.java:
##########
@@ -123,43 +122,275 @@ public void testFailDecodeNotBase32() throws IOException
{
testRunner.assertAllFlowFilesTransferred(EncodeContent.REL_FAILURE, 1);
}
- @Test
- public void testHexRoundTrip() throws IOException {
- final TestRunner testRunner = TestRunners.newTestRunner(new
EncodeContent());
+ @Test void testEncodeDecodeSpecialCharsBase64() {
+ final String specialChars = "!@#$%^&*()_+{}:\"<>?[];',./~`-=";
+ final String expectedOutput =
"IUAjJCVeJiooKV8re306Ijw+P1tdOycsLi9+YC09" + System.lineSeparator();
- testRunner.setProperty(EncodeContent.MODE, EncodeContent.ENCODE_MODE);
- testRunner.setProperty(EncodeContent.ENCODING,
EncodeContent.HEX_ENCODING);
+ executeTestSuccessHelper(EncodingMode.ENCODE,
EncodingType.BASE64_ENCODING, specialChars, expectedOutput);
+ testRunner.clearTransferState(); // clear the state for the next test
+ executeTestSuccessHelper(EncodingMode.DECODE,
EncodingType.BASE64_ENCODING, expectedOutput, specialChars);
+ }
- testRunner.enqueue(FILE_PATH);
- testRunner.clearTransferState();
- testRunner.run();
+ @Test void testBasicDecodeBase32() {
+ executeTestSuccessHelper(EncodingMode.DECODE,
EncodingType.BASE32_ENCODING, "NBSWY3DP", "hello");
+ }
- testRunner.assertAllFlowFilesTransferred(EncodeContent.REL_SUCCESS, 1);
+ @Test void testBasicDecodeBase64() {
+ executeTestSuccessHelper(EncodingMode.DECODE,
EncodingType.BASE64_ENCODING, "Zm9v", "foo");
+ }
- MockFlowFile flowFile =
testRunner.getFlowFilesForRelationship(EncodeContent.REL_SUCCESS).get(0);
- testRunner.assertQueueEmpty();
+ @Test void testBasicDecodeHex() {
+ executeTestSuccessHelper(EncodingMode.DECODE,
EncodingType.HEX_ENCODING, "666F6F", "foo");
+ }
- testRunner.setProperty(EncodeContent.MODE, EncodeContent.DECODE_MODE);
- testRunner.enqueue(flowFile);
- testRunner.clearTransferState();
- testRunner.run();
- testRunner.assertAllFlowFilesTransferred(EncodeContent.REL_SUCCESS, 1);
+ @Test void testBasicEncodeHex0() {
+ executeTestSuccessHelper(EncodingMode.ENCODE,
EncodingType.HEX_ENCODING, "hello", "68656C6C6F");
+ }
- flowFile =
testRunner.getFlowFilesForRelationship(EncodeContent.REL_SUCCESS).get(0);
- flowFile.assertContentEquals(FILE_PATH);
+ @Test void testBasicEncodeHex1() {
+ executeTestSuccessHelper(EncodingMode.ENCODE,
EncodingType.HEX_ENCODING, "foo", "666F6F");
}
- @Test
- public void testFailDecodeNotHex() throws IOException {
- final TestRunner testRunner = TestRunners.newTestRunner(new
EncodeContent());
+ @Test void testBasicEncodeBase320() {
+ executeTestSuccessHelper(EncodingMode.ENCODE,
EncodingType.BASE32_ENCODING, "hello", "NBSWY3DP" + System.lineSeparator());
+ }
Review Comment:
Refactored
https://github.com/apache/nifi/pull/8417/commits/9fd11b7ae031fe416783f0135b7a94752b534ade
--
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]