[GitHub] [nifi] exceptionfactory commented on a change in pull request #5378: NIFI-9166 Refactored nifi-standard-services to use JUnit 5.

2022-02-11 Thread GitBox


exceptionfactory commented on a change in pull request #5378:
URL: https://github.com/apache/nifi/pull/5378#discussion_r804993252



##
File path: 
nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/RestLookupService.java
##
@@ -333,7 +335,8 @@ private void setProxy(OkHttpClient.Builder builder) {
 final Record record;
 try (final InputStream is = responseBody.byteStream();
 final InputStream bufferedIn = new BufferedInputStream(is)) {
-record = handleResponse(bufferedIn, 
responseBody.contentLength(), context);
+String toString = IOUtils.toString(bufferedIn, 
StandardCharsets.UTF_8);
+record = handleResponse(new 
ByteArrayInputStream(toString.getBytes(StandardCharsets.UTF_8)), 
responseBody.contentLength(), context);

Review comment:
   Although this may only be reading one Record, the `UTF-8` encoding is 
also a concern, versus just passing the InputStream directly to the Record 
Reader.




-- 
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: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [nifi] exceptionfactory commented on a change in pull request #5378: NIFI-9166 Refactored nifi-standard-services to use JUnit 5.

2022-02-11 Thread GitBox


exceptionfactory commented on a change in pull request #5378:
URL: https://github.com/apache/nifi/pull/5378#discussion_r804985715



##
File path: 
nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/RestLookupService.java
##
@@ -333,7 +335,8 @@ private void setProxy(OkHttpClient.Builder builder) {
 final Record record;
 try (final InputStream is = responseBody.byteStream();
 final InputStream bufferedIn = new BufferedInputStream(is)) {
-record = handleResponse(bufferedIn, 
responseBody.contentLength(), context);
+String toString = IOUtils.toString(bufferedIn, 
StandardCharsets.UTF_8);
+record = handleResponse(new 
ByteArrayInputStream(toString.getBytes(StandardCharsets.UTF_8)), 
responseBody.contentLength(), context);

Review comment:
   @MikeThomsen, I didn't notice this change before, but it seems 
problematic. Reading in the entire response body to a string, and then 
converting to a byte array before passing to `handleResponse()` could introduce 
memory issues. Was there anything in particular that prompted this change, or 
can it be reverted?
   
   This appears to be the only non-test file changed, so everything else looks 
good.




-- 
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: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [nifi] exceptionfactory commented on a change in pull request #5378: NIFI-9166 Refactored nifi-standard-services to use JUnit 5.

2022-02-11 Thread GitBox


exceptionfactory commented on a change in pull request #5378:
URL: https://github.com/apache/nifi/pull/5378#discussion_r804800508



##
File path: 
nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java
##
@@ -23,48 +23,49 @@
 import org.apache.nifi.reporting.InitializationException;
 import org.apache.nifi.util.TestRunner;
 import org.apache.nifi.util.TestRunners;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+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.api.io.TempDir;
 
 import java.io.File;
+import java.nio.file.Path;
 import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.ArrayList;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
+@DisabledOnOs(OS.WINDOWS)

Review comment:
   @MikeThomsen, following up on this, I took a closer look at 
`DBCPServiceTest` in conjunction with updates to improve reliability in the new 
HikariCPConnectionPool test. As far as the Windows failure, I narrowed it down 
to the derby.log. I was able to implement a solution that works on all 
platforms, and streamlines the tests for JUnit 5 in PR #5759, which is now 
merged. If you rebase and take the current version, that should allow moving 
this forward.




-- 
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: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [nifi] exceptionfactory commented on a change in pull request #5378: NIFI-9166 Refactored nifi-standard-services to use JUnit 5.

2022-02-08 Thread GitBox


exceptionfactory commented on a change in pull request #5378:
URL: https://github.com/apache/nifi/pull/5378#discussion_r802227847



##
File path: 
nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java
##
@@ -23,48 +23,49 @@
 import org.apache.nifi.reporting.InitializationException;
 import org.apache.nifi.util.TestRunner;
 import org.apache.nifi.util.TestRunners;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+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.api.io.TempDir;
 
 import java.io.File;
+import java.nio.file.Path;
 import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.ArrayList;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
+@DisabledOnOs(OS.WINDOWS)

Review comment:
   Thanks @MikeThomsen, I'm inclined to move ahead with merging given all 
of the other improvements in this PR.
   
   I looked at `DatabaseRecordSinkTest` and noticed that it uses the Derby DB 
and similar structure, but it runs on Windows. It seems like this could be 
related to the fact that it uses a custom `AfterAll` method that ignores 
`IOExceptions` when deleting the database location, however, that also allows 
it run on all platforms. Although this is minor, it avoids one step backward. 
Can you take one more look at using the cleanup approach from 
`DatabaseRecordSinkTest`? If that doesn't work, then I'm fine with moving 
forward disabling on Windows, but since it is so similar, it seems worth one 
more try.




-- 
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: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [nifi] exceptionfactory commented on a change in pull request #5378: NIFI-9166 Refactored nifi-standard-services to use JUnit 5.

2022-02-07 Thread GitBox


exceptionfactory commented on a change in pull request #5378:
URL: https://github.com/apache/nifi/pull/5378#discussion_r801271851



##
File path: 
nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java
##
@@ -23,48 +23,49 @@
 import org.apache.nifi.reporting.InitializationException;
 import org.apache.nifi.util.TestRunner;
 import org.apache.nifi.util.TestRunners;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+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.api.io.TempDir;
 
 import java.io.File;
+import java.nio.file.Path;
 import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.ArrayList;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
+@DisabledOnOs(OS.WINDOWS)

Review comment:
   As one other option for now, I would be fine with leaving the 
DBCPServiceTest as it is with JUnit 4 and creating a new Jira issue to revisit 
it later. That could allow the rest of this PR to move forward.




-- 
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: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [nifi] exceptionfactory commented on a change in pull request #5378: NIFI-9166 Refactored nifi-standard-services to use JUnit 5.

2022-02-07 Thread GitBox


exceptionfactory commented on a change in pull request #5378:
URL: https://github.com/apache/nifi/pull/5378#discussion_r801122495



##
File path: 
nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java
##
@@ -23,48 +23,49 @@
 import org.apache.nifi.reporting.InitializationException;
 import org.apache.nifi.util.TestRunner;
 import org.apache.nifi.util.TestRunners;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+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.api.io.TempDir;
 
 import java.io.File;
+import java.nio.file.Path;
 import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.ArrayList;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
+@DisabledOnOs(OS.WINDOWS)

Review comment:
   Thanks for trying out some options @MikeThomsen. It appears that Derby 
still has an open handle to the database files for some reason.  Did you 
consider creating and removing the directory manually in `BeforeAll` and 
`AfterAll` methods?  Given that this is a popular component, it seems like a 
step backwards to disable it as part of the JUnit 5 changes, even if it is just 
on Windows.




-- 
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: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [nifi] exceptionfactory commented on a change in pull request #5378: NIFI-9166 Refactored nifi-standard-services to use JUnit 5.

2022-02-07 Thread GitBox


exceptionfactory commented on a change in pull request #5378:
URL: https://github.com/apache/nifi/pull/5378#discussion_r801122495



##
File path: 
nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java
##
@@ -23,48 +23,49 @@
 import org.apache.nifi.reporting.InitializationException;
 import org.apache.nifi.util.TestRunner;
 import org.apache.nifi.util.TestRunners;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+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.api.io.TempDir;
 
 import java.io.File;
+import java.nio.file.Path;
 import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.ArrayList;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
+@DisabledOnOs(OS.WINDOWS)

Review comment:
   Thanks for trying out some options @MikeThomsen. It appears that Derby 
still has an open handle to the database files for some reason.  Did you 
consider creating and removing the directory manually in `BeforeAll` and 
`AfterAll` methods?  Given that this is a popular component, it seems like a 
step backwards to disable it as part of the JUnit 5 changes.




-- 
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: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [nifi] exceptionfactory commented on a change in pull request #5378: NIFI-9166 Refactored nifi-standard-services to use JUnit 5.

2022-02-04 Thread GitBox


exceptionfactory commented on a change in pull request #5378:
URL: https://github.com/apache/nifi/pull/5378#discussion_r799522493



##
File path: 
nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java
##
@@ -23,48 +23,49 @@
 import org.apache.nifi.reporting.InitializationException;
 import org.apache.nifi.util.TestRunner;
 import org.apache.nifi.util.TestRunners;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+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.api.io.TempDir;
 
 import java.io.File;
+import java.nio.file.Path;
 import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.ArrayList;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
+@DisabledOnOs(OS.WINDOWS)

Review comment:
   Thanks for the reply @MikeThomsen, I looked at the previous automated 
build and observed the errors you mentioned:
   
   ```
   java.io.IOException: Failed to delete temp directory 
C:\Users\RUNNER~1\AppData\Local\Temp\junit8996089088338771159. The following 
paths could not be deleted (see suppressed exceptions for details): , target, 
target\db, target\db\db.lck
   ```
   
   That does raise a question as to why the temporary directory appears to be 
using the `target` directory.  Rather than disabling the test on Windows, it 
looks like the directory should be changed to use an actual temporary 
directory, instead of something under the `target` directory.  I would expect 
that using a regular temporary directory would allow it to work, since the test 
was previously working on JUnit 4.  Can you take a look at making that 
adjustment?




-- 
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: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [nifi] exceptionfactory commented on a change in pull request #5378: NIFI-9166 Refactored nifi-standard-services to use JUnit 5.

2022-02-02 Thread GitBox


exceptionfactory commented on a change in pull request #5378:
URL: https://github.com/apache/nifi/pull/5378#discussion_r798190382



##
File path: 
nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java
##
@@ -23,48 +23,49 @@
 import org.apache.nifi.reporting.InitializationException;
 import org.apache.nifi.util.TestRunner;
 import org.apache.nifi.util.TestRunners;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+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.api.io.TempDir;
 
 import java.io.File;
+import java.nio.file.Path;
 import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.ArrayList;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
+@DisabledOnOs(OS.WINDOWS)

Review comment:
   What was the reason for disabling this test on Windows?




-- 
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: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org