dan-s1 commented on code in PR #11761:
URL: https://github.com/apache/nifi/pull/11761#discussion_r4403203088


##########
nifi-extension-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/record/sink/db/DatabaseRecordSinkTest.java:
##########
@@ -90,89 +92,102 @@ public class DatabaseRecordSinkTest {
     private static final String SERVICE_ID = 
DBCPConnectionPool.class.getName();
 
     private static final String DRIVER_CLASS = "org.hsqldb.jdbc.JDBCDriver";
-    private static final String CONNECTION_URL_FORMAT = "jdbc:hsqldb:file:%s";
+    private static final String CONNECTION_URL_FORMAT = 
"jdbc:hsqldb:file:%s/nifi";
 
     private String connectionUrl;
     private DBCPConnectionPool dbcpService;
+    private TestRunner runner;
 
     @BeforeEach
     public void setService(@TempDir final Path tempDir) throws 
InitializationException {
         dbcpService = new DBCPConnectionPool();
-        TestRunner runner = TestRunners.newTestRunner(NoOpProcessor.class);
+        runner = TestRunners.newTestRunner(NoOpProcessor.class);
         runner.addControllerService(SERVICE_ID, dbcpService);
 
-        connectionUrl = CONNECTION_URL_FORMAT.formatted(tempDir);
+        connectionUrl = 
CONNECTION_URL_FORMAT.formatted(tempDir.toAbsolutePath());
         runner.setProperty(dbcpService, DATABASE_URL, connectionUrl);
         runner.setProperty(dbcpService, DB_USER, String.class.getSimpleName());
         runner.setProperty(dbcpService, DB_PASSWORD, String.class.getName());
         runner.setProperty(dbcpService, DB_DRIVERNAME, DRIVER_CLASS);
     }
 
+    @AfterEach
+    public void shutdownDatabase() throws SQLException {
+        runner.shutdown();
+        dbcpService.shutdown();
+
+        try (Connection conn = DriverManager.getConnection(connectionUrl);

Review Comment:
   @exceptionfactory 
   That was it I removed
    ```
   runner.setProperty(dbcpService, DB_USER, USERNAME);
   runner.setProperty(dbcpService, DB_PASSWORD, PASSWORD);
   ```
    
   and replaced 
   ```
   when(dbContext.getProperty(DB_USER)).thenReturn(new MockPropertyValue(null));
   when(dbContext.getProperty(DB_PASSWORD)).thenReturn(new 
MockPropertyValue(null));
   ```
   with
   ```
   when(dbContext.getProperty(DB_USER)).thenReturn(new 
MockPropertyValue(USERNAME));
   when(dbContext.getProperty(DB_PASSWORD)).thenReturn(new 
MockPropertyValue(PASSWORD));
   ```
   and the tests passed.
   Thanks for your help chasing that down!



-- 
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]

Reply via email to