TSK-1042 use try-with-resources for connections
This commit is contained in:
parent
bc18f69777
commit
6c8fb69f60
|
@ -38,19 +38,17 @@ public class DbSchemaCreator {
|
|||
* @throws SQLException will be thrown if there will be some incorrect SQL statements invoked.
|
||||
*/
|
||||
public void run() throws SQLException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
try (Connection connection = dataSource.getConnection()) {
|
||||
connection.setSchema(schemaName);
|
||||
ScriptRunner runner = new ScriptRunner(connection);
|
||||
runner.setStopOnError(true);
|
||||
runner.setLogWriter(logWriter);
|
||||
runner.setErrorLogWriter(errorLogWriter);
|
||||
try {
|
||||
|
||||
InputStream resourceAsStream = this.getClass().getResourceAsStream(DB_SCHEMA);
|
||||
BufferedReader reader =
|
||||
new BufferedReader(new InputStreamReader(resourceAsStream, StandardCharsets.UTF_8));
|
||||
runner.runScript(getSqlWithSchemaNameParsed(reader));
|
||||
} finally {
|
||||
runner.closeConnection();
|
||||
}
|
||||
LOGGER.debug(outWriter.toString());
|
||||
if (!errorWriter.toString().trim().isEmpty()) {
|
||||
|
|
|
@ -29,13 +29,10 @@ public class DbWriter {
|
|||
|
||||
public void generateTestData(DataSource dataSource) throws SQLException {
|
||||
ScriptRunner runner = null;
|
||||
try {
|
||||
runner = configScriptRunner(dataSource);
|
||||
try (Connection connection = dataSource.getConnection()) {
|
||||
runner = configScriptRunner(connection);
|
||||
runner.runScript(new InputStreamReader(this.getClass().getResourceAsStream(INSERTVALUES)));
|
||||
} finally {
|
||||
if (runner != null) {
|
||||
runner.closeConnection();
|
||||
}
|
||||
LOGGER.debug(outWriter.toString());
|
||||
if (!errorWriter.toString().trim().isEmpty()) {
|
||||
LOGGER.error(errorWriter.toString());
|
||||
|
@ -45,13 +42,10 @@ public class DbWriter {
|
|||
|
||||
public void clearDB(DataSource dataSource) throws SQLException {
|
||||
ScriptRunner runner = null;
|
||||
try {
|
||||
runner = configScriptRunner(dataSource);
|
||||
try (Connection connection = dataSource.getConnection()) {
|
||||
runner = configScriptRunner(connection);
|
||||
runner.runScript(new StringReader("DELETE FROM HISTORY_EVENTS;"));
|
||||
} finally {
|
||||
if (runner != null) {
|
||||
runner.closeConnection();
|
||||
}
|
||||
LOGGER.debug(outWriter.toString());
|
||||
if (!errorWriter.toString().trim().isEmpty()) {
|
||||
LOGGER.error(errorWriter.toString());
|
||||
|
@ -59,8 +53,7 @@ public class DbWriter {
|
|||
}
|
||||
}
|
||||
|
||||
private ScriptRunner configScriptRunner(DataSource dataSource) throws SQLException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
private ScriptRunner configScriptRunner(Connection connection) throws SQLException {
|
||||
LOGGER.debug(connection.getMetaData().toString());
|
||||
ScriptRunner runner = new ScriptRunner(connection);
|
||||
runner.setStopOnError(true);
|
||||
|
|
|
@ -24,7 +24,6 @@ public class SampleDataGenerator {
|
|||
private static final String HISTORY_EVENT = TEST_DATA + "/history-event.sql";
|
||||
DataSource dataSource;
|
||||
String dbProductName;
|
||||
private ScriptRunner runner;
|
||||
|
||||
public SampleDataGenerator(DataSource dataSource) throws SQLException {
|
||||
try (Connection connection = dataSource.getConnection()) {
|
||||
|
@ -35,8 +34,6 @@ public class SampleDataGenerator {
|
|||
}
|
||||
}
|
||||
this.dataSource = dataSource;
|
||||
|
||||
runner = new ScriptRunner(dataSource.getConnection());
|
||||
}
|
||||
|
||||
public void generateSampleData(String schemaName) {
|
||||
|
@ -45,16 +42,14 @@ public class SampleDataGenerator {
|
|||
|
||||
final StringWriter errorWriter = new StringWriter();
|
||||
final PrintWriter errorLogWriter = new PrintWriter(errorWriter);
|
||||
try {
|
||||
try (Connection connection = dataSource.getConnection()) {
|
||||
ScriptRunner runner = new ScriptRunner(connection);
|
||||
runner.runScript(selectSchemaScript(dbProductName, schemaName));
|
||||
runner.setStopOnError(false);
|
||||
runner.runScript(
|
||||
new BufferedReader(
|
||||
new InputStreamReader(
|
||||
this.getClass().getResourceAsStream(CLEAR), StandardCharsets.UTF_8)));
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("caught Exception {}", e, e);
|
||||
}
|
||||
|
||||
runner.setStopOnError(true);
|
||||
runner.setLogWriter(logWriter);
|
||||
|
@ -65,7 +60,9 @@ public class SampleDataGenerator {
|
|||
new InputStreamReader(
|
||||
this.getClass().getResourceAsStream(HISTORY_EVENT), StandardCharsets.UTF_8)));
|
||||
|
||||
runner.closeConnection();
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("caught Exception {}", e, e);
|
||||
}
|
||||
|
||||
LOGGER.trace(outWriter.toString());
|
||||
if (!errorWriter.toString().trim().isEmpty()) {
|
||||
|
|
|
@ -47,13 +47,13 @@ public class DbSchemaCreator {
|
|||
* @throws SQLException will be thrown if there will be some incorrect SQL statements invoked.
|
||||
*/
|
||||
public void run() throws SQLException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
try (Connection connection = dataSource.getConnection()) {
|
||||
LOGGER.debug(
|
||||
"Using database of type {} with url '{}'",
|
||||
connection.getMetaData().getDatabaseProductName(),
|
||||
connection.getMetaData().getURL());
|
||||
ScriptRunner runner = getScriptRunnerInstance(connection);
|
||||
try {
|
||||
|
||||
if (!isSchemaPreexisting(connection)) {
|
||||
String scriptPath =
|
||||
selectDbScriptFileName(connection.getMetaData().getDatabaseProductName());
|
||||
|
@ -62,8 +62,6 @@ public class DbSchemaCreator {
|
|||
new BufferedReader(new InputStreamReader(resourceAsStream, StandardCharsets.UTF_8));
|
||||
runner.runScript(getSqlSchemaNameParsed(reader));
|
||||
}
|
||||
} finally {
|
||||
runner.closeConnection();
|
||||
}
|
||||
LOGGER.debug(outWriter.toString());
|
||||
if (!errorWriter.toString().trim().isEmpty()) {
|
||||
|
@ -73,8 +71,7 @@ public class DbSchemaCreator {
|
|||
|
||||
public boolean isValidSchemaVersion(String expectedVersion) {
|
||||
SqlRunner runner = null;
|
||||
try {
|
||||
Connection connection = dataSource.getConnection();
|
||||
try (Connection connection = dataSource.getConnection()) {
|
||||
connection.setSchema(this.schemaName);
|
||||
runner = new SqlRunner(connection);
|
||||
LOGGER.debug(connection.getMetaData().toString());
|
||||
|
@ -102,10 +99,6 @@ public class DbSchemaCreator {
|
|||
+ "has not the expected value {}",
|
||||
expectedVersion);
|
||||
return false;
|
||||
} finally {
|
||||
if (runner != null) {
|
||||
runner.closeConnection();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
public void testInsertClassification()
|
||||
throws SQLException, ClassificationNotFoundException, ClassificationAlreadyExistException,
|
||||
NotAuthorizedException, DomainNotFoundException, InvalidArgumentException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
try (Connection connection = dataSource.getConnection()) {
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
|
||||
final String domain = "DOMAIN_A";
|
||||
|
@ -101,7 +101,8 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
expectedClassification.setDomain("DOMAIN_B");
|
||||
classificationService.createClassification(expectedClassification);
|
||||
connection.commit();
|
||||
Classification actualClassification = classificationService.getClassification(key, "DOMAIN_B");
|
||||
Classification actualClassification =
|
||||
classificationService.getClassification(key, "DOMAIN_B");
|
||||
assertThat(actualClassification, not(IsEqual.equalTo(null)));
|
||||
assertThat(actualClassification.getCreated(), not(IsEqual.equalTo(null)));
|
||||
assertThat(actualClassification.getId(), not(IsEqual.equalTo(null)));
|
||||
|
@ -127,12 +128,13 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
|
||||
connection.commit();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindAllClassifications()
|
||||
throws SQLException, ClassificationAlreadyExistException, NotAuthorizedException,
|
||||
DomainNotFoundException, InvalidArgumentException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
try (Connection connection = dataSource.getConnection()) {
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
Classification classification0 = this.createNewClassificationWithUniqueKey("", "TASK");
|
||||
classificationService.createClassification(classification0);
|
||||
|
@ -145,6 +147,7 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
assertEquals(2 + 1, classificationService.createClassificationQuery().list().size());
|
||||
connection.commit();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModifiedClassification()
|
||||
|
@ -152,7 +155,7 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
NotAuthorizedException, ConcurrencyException, DomainNotFoundException,
|
||||
InvalidArgumentException {
|
||||
|
||||
Connection connection = dataSource.getConnection();
|
||||
try (Connection connection = dataSource.getConnection()) {
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
Classification classification = this.createNewClassificationWithUniqueKey("DOMAIN_A", "TASK");
|
||||
connection.commit();
|
||||
|
@ -168,12 +171,13 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
classification.getKey(), classification.getDomain());
|
||||
assertThat(classification.getDescription(), IsEqual.equalTo(updatedDescription));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInsertAndClassificationQuery()
|
||||
throws SQLException, ClassificationAlreadyExistException, NotAuthorizedException,
|
||||
DomainNotFoundException, InvalidArgumentException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
try (Connection connection = dataSource.getConnection()) {
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
Classification classification = this.createNewClassificationWithUniqueKey("DOMAIN_A", "TASK");
|
||||
classificationService.createClassification(classification);
|
||||
|
@ -185,13 +189,14 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
.list();
|
||||
assertEquals(1, list.size());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateAndClassificationQuery()
|
||||
throws NotAuthorizedException, SQLException, ClassificationAlreadyExistException,
|
||||
ClassificationNotFoundException, ConcurrencyException, DomainNotFoundException,
|
||||
InvalidArgumentException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
try (Connection connection = dataSource.getConnection()) {
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
Classification classification = this.createNewClassificationWithUniqueKey("DOMAIN_A", "TASK");
|
||||
classification.setDescription("");
|
||||
|
@ -217,18 +222,20 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
assertEquals(2, allClassifications.size());
|
||||
connection.commit();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultSettingsWithClassificationQuery()
|
||||
throws NotAuthorizedException, SQLException, ClassificationAlreadyExistException,
|
||||
ClassificationNotFoundException, InvalidArgumentException, ConcurrencyException,
|
||||
DomainNotFoundException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
try (Connection connection = dataSource.getConnection()) {
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
Classification classification = this.createNewClassificationWithUniqueKey("DOMAIN_A", "TASK");
|
||||
classification = classificationService.createClassification(classification);
|
||||
|
||||
Classification classification1 = this.createNewClassificationWithUniqueKey("DOMAIN_A", "TASK");
|
||||
Classification classification1 =
|
||||
this.createNewClassificationWithUniqueKey("DOMAIN_A", "TASK");
|
||||
classification1 = classificationService.createClassification(classification1);
|
||||
classification1.setParentId(classification.getId());
|
||||
classification1 = classificationService.updateClassification(classification1);
|
||||
|
@ -251,15 +258,20 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
.validInDomainEquals(false)
|
||||
.list();
|
||||
assertEquals(0, list.size());
|
||||
list = classificationService.createClassificationQuery().keyIn(classification1.getKey()).list();
|
||||
list =
|
||||
classificationService.createClassificationQuery().keyIn(classification1.getKey()).list();
|
||||
assertEquals(2, list.size());
|
||||
|
||||
list =
|
||||
classificationService.createClassificationQuery().parentIdIn(classification.getId()).list();
|
||||
classificationService
|
||||
.createClassificationQuery()
|
||||
.parentIdIn(classification.getId())
|
||||
.list();
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list.get(0).getKey(), IsEqual.equalTo(classification1.getKey()));
|
||||
connection.commit();
|
||||
}
|
||||
}
|
||||
|
||||
private Classification createNewClassificationWithUniqueKey(String domain, String type) {
|
||||
Classification classification =
|
||||
|
|
|
@ -122,10 +122,11 @@ class TaskServiceImplIntExplicitTest {
|
|||
ClassificationAlreadyExistException, TaskAlreadyExistException,
|
||||
InvalidWorkbasketException, InvalidArgumentException, WorkbasketAlreadyExistException,
|
||||
DomainNotFoundException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
try (Connection connection = dataSource.getConnection()) {
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
|
||||
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket("k1", "DOMAIN_A");
|
||||
WorkbasketImpl workbasket =
|
||||
(WorkbasketImpl) workbasketService.newWorkbasket("k1", "DOMAIN_A");
|
||||
workbasket.setName("workbasket");
|
||||
workbasket.setId("1"); // set id manually for authorization tests
|
||||
|
||||
|
@ -156,6 +157,7 @@ class TaskServiceImplIntExplicitTest {
|
|||
TaskNotFoundException.class, () -> taskServiceImpl2.getTask(workbasket.getId()));
|
||||
connection.commit();
|
||||
}
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "Elena",
|
||||
|
@ -167,7 +169,7 @@ class TaskServiceImplIntExplicitTest {
|
|||
ClassificationAlreadyExistException, TaskAlreadyExistException,
|
||||
InvalidWorkbasketException, InvalidArgumentException, WorkbasketAlreadyExistException,
|
||||
DomainNotFoundException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
try (Connection connection = dataSource.getConnection()) {
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
|
||||
final Task task = this.generateDummyTask();
|
||||
|
@ -189,6 +191,7 @@ class TaskServiceImplIntExplicitTest {
|
|||
assertNotNull(resultTask);
|
||||
connection.commit();
|
||||
}
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "Elena",
|
||||
|
@ -198,7 +201,7 @@ class TaskServiceImplIntExplicitTest {
|
|||
throws NotAuthorizedException, SQLException, ClassificationAlreadyExistException,
|
||||
InvalidWorkbasketException, InvalidArgumentException, WorkbasketAlreadyExistException,
|
||||
DomainNotFoundException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
try (Connection connection = dataSource.getConnection()) {
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
Task test = this.generateDummyTask();
|
||||
((WorkbasketSummaryImpl) (test.getWorkbasketSummary())).setId("2");
|
||||
|
@ -206,6 +209,7 @@ class TaskServiceImplIntExplicitTest {
|
|||
Assertions.assertThrows(
|
||||
WorkbasketNotFoundException.class, () -> taskServiceImpl.createTask(test));
|
||||
}
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "Elena",
|
||||
|
@ -215,14 +219,15 @@ class TaskServiceImplIntExplicitTest {
|
|||
throws NotAuthorizedException, WorkbasketNotFoundException, SQLException,
|
||||
ClassificationAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException,
|
||||
WorkbasketAlreadyExistException, DomainNotFoundException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
try (Connection connection = dataSource.getConnection()) {
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
|
||||
Workbasket wb = workbasketService.newWorkbasket("WB NR.1", "DOMAIN_A");
|
||||
wb.setName("dummy-WB");
|
||||
wb.setType(WorkbasketType.PERSONAL);
|
||||
wb = workbasketService.createWorkbasket(wb);
|
||||
this.createWorkbasketWithSecurity(wb, CurrentUserContext.getUserid(), true, true, true, false);
|
||||
this.createWorkbasketWithSecurity(
|
||||
wb, CurrentUserContext.getUserid(), true, true, true, false);
|
||||
Classification classification =
|
||||
classificationService.newClassification(
|
||||
UUID.randomUUID().toString(), wb.getDomain(), "t1"); // not persisted,
|
||||
|
@ -236,6 +241,7 @@ class TaskServiceImplIntExplicitTest {
|
|||
Assertions.assertThrows(
|
||||
ClassificationNotFoundException.class, () -> taskServiceImpl.createTask(task));
|
||||
}
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "Elena",
|
||||
|
@ -246,9 +252,10 @@ class TaskServiceImplIntExplicitTest {
|
|||
ClassificationNotFoundException, ClassificationAlreadyExistException,
|
||||
TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException,
|
||||
SystemException, WorkbasketAlreadyExistException, DomainNotFoundException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
try (Connection connection = dataSource.getConnection()) {
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket("k1", "DOMAIN_A");
|
||||
WorkbasketImpl workbasket =
|
||||
(WorkbasketImpl) workbasketService.newWorkbasket("k1", "DOMAIN_A");
|
||||
workbasket.setName("workbasket");
|
||||
Classification classification =
|
||||
classificationService.newClassification("TEST", "DOMAIN_A", "TASK");
|
||||
|
@ -290,6 +297,7 @@ class TaskServiceImplIntExplicitTest {
|
|||
assertEquals(0, results.size());
|
||||
connection.commit();
|
||||
}
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "Elena",
|
||||
|
@ -303,11 +311,12 @@ class TaskServiceImplIntExplicitTest {
|
|||
InvalidStateException {
|
||||
final int sleepTime = 100;
|
||||
final String user = CurrentUserContext.getUserid();
|
||||
Connection connection = dataSource.getConnection();
|
||||
try (Connection connection = dataSource.getConnection()) {
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
|
||||
// Source Workbasket
|
||||
WorkbasketImpl wb = (WorkbasketImpl) workbasketService.newWorkbasket("sourceWbKey", "DOMAIN_A");
|
||||
WorkbasketImpl wb =
|
||||
(WorkbasketImpl) workbasketService.newWorkbasket("sourceWbKey", "DOMAIN_A");
|
||||
wb.setName("Basic-Workbasket");
|
||||
wb.setDescription("Just used as base WB for Task here");
|
||||
wb.setOwner(user);
|
||||
|
@ -325,7 +334,8 @@ class TaskServiceImplIntExplicitTest {
|
|||
wb.setType(WorkbasketType.TOPIC);
|
||||
|
||||
Workbasket destinationWB = workbasketService.createWorkbasket(wb);
|
||||
createWorkbasketWithSecurity(destinationWB, destinationWB.getOwner(), false, true, true, true);
|
||||
createWorkbasketWithSecurity(
|
||||
destinationWB, destinationWB.getOwner(), false, true, true, true);
|
||||
|
||||
// Classification required for Task
|
||||
ClassificationImpl classification =
|
||||
|
@ -358,14 +368,17 @@ class TaskServiceImplIntExplicitTest {
|
|||
assertThat(resultTask.getCreated(), not(equalTo(null)));
|
||||
assertThat(resultTask.getCreated(), equalTo(task.getCreated()));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldNotTransferAnyTask() throws SQLException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
try (Connection connection = dataSource.getConnection()) {
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
|
||||
Assertions.assertThrows(
|
||||
TaskNotFoundException.class, () -> taskServiceImpl.transfer(UUID.randomUUID() + "_X", "1"));
|
||||
TaskNotFoundException.class,
|
||||
() -> taskServiceImpl.transfer(UUID.randomUUID() + "_X", "1"));
|
||||
}
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
|
|
|
@ -80,7 +80,7 @@ class WorkbasketServiceImplIntExplicitTest {
|
|||
groupNames = {"businessadmin"})
|
||||
@Test
|
||||
void testUpdateWorkbasket() throws Exception {
|
||||
Connection connection = dataSource.getConnection();
|
||||
try (Connection connection = dataSource.getConnection()) {
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
workBasketService = taskanaEngine.getWorkbasketService();
|
||||
String id0 = IdGenerator.generateWithPrefix("TWB");
|
||||
|
@ -134,6 +134,7 @@ class WorkbasketServiceImplIntExplicitTest {
|
|||
workBasketService.getWorkbasket(id3).getModified());
|
||||
connection.commit();
|
||||
}
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "Elena",
|
||||
|
@ -143,7 +144,7 @@ class WorkbasketServiceImplIntExplicitTest {
|
|||
throws NotAuthorizedException, SQLException, InvalidArgumentException,
|
||||
WorkbasketNotFoundException, DomainNotFoundException, InvalidWorkbasketException,
|
||||
WorkbasketAlreadyExistException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
try (Connection connection = dataSource.getConnection()) {
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
workBasketService = taskanaEngine.getWorkbasketService();
|
||||
Workbasket wb =
|
||||
|
@ -158,6 +159,7 @@ class WorkbasketServiceImplIntExplicitTest {
|
|||
assertEquals(1, workBasketService.getWorkbasketAccessItems("id1").size());
|
||||
connection.commit();
|
||||
}
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "Elena",
|
||||
|
@ -167,7 +169,7 @@ class WorkbasketServiceImplIntExplicitTest {
|
|||
throws NotAuthorizedException, SQLException, InvalidArgumentException,
|
||||
WorkbasketNotFoundException, DomainNotFoundException, InvalidWorkbasketException,
|
||||
WorkbasketAlreadyExistException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
try (Connection connection = dataSource.getConnection()) {
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
workBasketService = taskanaEngine.getWorkbasketService();
|
||||
|
||||
|
@ -184,6 +186,7 @@ class WorkbasketServiceImplIntExplicitTest {
|
|||
assertEquals("zaphod beeblebrox", accessItem.getAccessId());
|
||||
connection.commit();
|
||||
}
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void cleanUp() throws SQLException {
|
||||
|
|
|
@ -125,7 +125,6 @@ public class SampleDataGenerator {
|
|||
|
||||
ScriptRunner runner = getScriptRunner(connection, outWriter, errorWriter);
|
||||
consumer.accept(runner);
|
||||
runner.closeConnection();
|
||||
|
||||
if (LOGGER.isTraceEnabled()) {
|
||||
LOGGER.trace(outWriter.toString());
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package pro.taskana.rest;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
@ -43,8 +44,8 @@ class TestSchemaNameCustomizable {
|
|||
void chekCustomSchemaNameIsDefined() {
|
||||
resetDb();
|
||||
ResultSet rs;
|
||||
try {
|
||||
Statement stmt = dataSource.getConnection().createStatement();
|
||||
try (Connection connection = dataSource.getConnection()) {
|
||||
Statement stmt = connection.createStatement();
|
||||
if (isPostgres) {
|
||||
rs =
|
||||
stmt.executeQuery(
|
||||
|
|
Loading…
Reference in New Issue