dan-s1 commented on code in PR #11761:
URL: https://github.com/apache/nifi/pull/11761#discussion_r4295124831
##########
nifi-extension-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java:
##########
@@ -63,25 +66,55 @@ public class DBCPServiceTest {
private static final String NON_JDBC_URL =
"http://localhost:3306/database";
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_test_db";
private TestRunner runner;
private DBCPConnectionPool service;
+ private String connectionUrl;
+
+ private Path databasePath;
+
@BeforeEach
public void setService(@TempDir final Path tempDir) throws
InitializationException {
service = new DBCPConnectionPool();
runner = TestRunners.newTestRunner(NoOpProcessor.class);
runner.addControllerService(SERVICE_ID, service);
- final String url = CONNECTION_URL_FORMAT.formatted(tempDir);
- runner.setProperty(service, DBCPProperties.DATABASE_URL, url);
+ databasePath = tempDir.toAbsolutePath();
+ connectionUrl = CONNECTION_URL_FORMAT.formatted(databasePath);
+ runner.setProperty(service, DBCPProperties.DATABASE_URL,
connectionUrl);
runner.setProperty(service, DBCPProperties.DB_USER,
String.class.getSimpleName());
runner.setProperty(service, DBCPProperties.DB_PASSWORD,
String.class.getName());
runner.setProperty(service, DBCPProperties.DB_DRIVERNAME,
DRIVER_CLASS);
}
+ @AfterEach
+ public void shutdownDatabase() throws Exception {
+ runner.shutdown();
+
+ // Property validation tests may never create the database.
+ // Do not create it just to shut it down.
+ final Path propertiesFile =
databasePath.resolve("nifi_test_db.properties");
+ if (Files.exists(propertiesFile)) {
+ final Properties properties = new Properties();
+ properties.setProperty("user", String.class.getSimpleName());
+ properties.setProperty("password", String.class.getName());
Review Comment:
@exceptionfactory
When I removed the lines
```
properties.setProperty("user", String.class.getSimpleName());
properties.setProperty("password", String.class.getName());
`
I get the following error stacktrace for each of the tests in
`DBCPServiceTest`
```
java.sql.SQLInvalidAuthorizationSpecException: invalid authorization
specification - not found: SA
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCConnection.<init>(Unknown Source)
at org.hsqldb.jdbc.JDBCDriver.getConnection(Unknown Source)
at org.hsqldb.jdbc.JDBCDriver.connect(Unknown Source)
at
org.apache.nifi.dbcp.DBCPServiceTest.shutdownDatabase(DBCPServiceTest.java:105)
Caused by: org.hsqldb.HsqlException: invalid authorization specification -
not found: SA
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.rights.UserManager.get(Unknown Source)
at org.hsqldb.rights.UserManager.getUser(Unknown Source)
at org.hsqldb.Database.connect(Unknown Source)
at org.hsqldb.DatabaseManager.newSession(Unknown Source)
... 4 more
```
--
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]