summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cps-ri/src/test/java/org/onap/cps/DatabaseTestContainer.java6
1 files changed, 5 insertions, 1 deletions
diff --git a/cps-ri/src/test/java/org/onap/cps/DatabaseTestContainer.java b/cps-ri/src/test/java/org/onap/cps/DatabaseTestContainer.java
index 759cc95319..a621b2ca4d 100644
--- a/cps-ri/src/test/java/org/onap/cps/DatabaseTestContainer.java
+++ b/cps-ri/src/test/java/org/onap/cps/DatabaseTestContainer.java
@@ -44,6 +44,7 @@ public class DatabaseTestContainer extends PostgreSQLContainer<DatabaseTestConta
public static DatabaseTestContainer getInstance() {
if (databaseTestContainer == null) {
databaseTestContainer = new DatabaseTestContainer();
+ Runtime.getRuntime().addShutdownHook(new Thread(databaseTestContainer::terminate));
}
return databaseTestContainer;
}
@@ -58,7 +59,10 @@ public class DatabaseTestContainer extends PostgreSQLContainer<DatabaseTestConta
@Override
public void stop() {
- //do nothing, JVM handles shut down
+ // do nothing on test completion, image removal will be performed via terminate() on JVM shutdown
}
+ private void terminate() {
+ super.stop();
+ }
}