Github user yjhyjhyjh0 commented on a diff in the pull request:
https://github.com/apache/nifi/pull/3107#discussion_r234407245
--- Diff:
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestExecuteSQLRecord.java
---
@@ -350,6 +357,37 @@ public void invokeOnTriggerRecords(final Integer
queryTimeout, final String quer
assertEquals(durationTime, fetchTime + executionTime);
}
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testWithSqlExceptionErrorProcessingResultSet() throws
Exception {
+ DBCPService dbcp = mock(DBCPService.class);
+ Connection conn = mock(Connection.class);
+ when(dbcp.getConnection(any(Map.class))).thenReturn(conn);
+ when(dbcp.getIdentifier()).thenReturn("mockdbcp");
+ PreparedStatement statement = mock(PreparedStatement.class);
+ when(conn.prepareStatement(anyString())).thenReturn(statement);
+ when(statement.execute()).thenReturn(true);
+ ResultSet rs = mock(ResultSet.class);
+ when(statement.getResultSet()).thenReturn(rs);
+ // Throw an exception the first time you access the ResultSet,
this is after the flow file to hold the results has been created.
+ when(rs.getMetaData()).thenThrow(new SQLException("test execute
statement failed"));
+
--- End diff --
You're right, thanks for point out and suggestion.
I should be more cautious while resolving commit.
I've add lines of mock record writer back and test successfully.
Squashed and pushed.
---