Skip to content

Commit d6fdacc

Browse files
committed
issue in which new connection created at each SUT reset
1 parent 6ccd907 commit d6fdacc

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

jdk_8_maven/em/embedded/rest/genome-nexus/src/main/java/em/embedded/org/cbioportal/genome_nexus/EmbeddedEvoMasterController.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ public static void main(String[] args) {
4848
.withExposedPorts(MONGODB_PORT);
4949

5050

51+
private MongoClient mongoClient;
52+
53+
5154
public EmbeddedEvoMasterController() {
5255
this(0);
5356
}
@@ -62,6 +65,15 @@ public String startSut() {
6265

6366
mongodbContainer.start();
6467

68+
try {
69+
mongoClient = new MongoClient(mongodbContainer.getContainerIpAddress(),
70+
mongodbContainer.getMappedPort(MONGODB_PORT));
71+
72+
} catch (Exception e) {
73+
System.out.println("ERROR: " + e.getMessage());
74+
throw new RuntimeException(e);
75+
}
76+
6577
ctx = SpringApplication.run(GenomeNexusAnnotation.class,
6678
new String[]{"--server.port=0",
6779
"--spring.data.mongodb.uri=mongodb://" + mongodbContainer.getContainerIpAddress() + ":" + mongodbContainer.getMappedPort(MONGODB_PORT) + "/" + MONGODB_DATABASE_NAME,
@@ -88,6 +100,7 @@ public void stopSut() {
88100
ctx.stop();
89101
ctx.close();
90102

103+
mongoClient.close();
91104
mongodbContainer.stop();
92105
}
93106

@@ -98,9 +111,6 @@ public String getPackagePrefixesToCover() {
98111

99112
@Override
100113
public void resetStateOfSUT() {
101-
MongoClient mongoClient = new MongoClient(mongodbContainer.getContainerIpAddress(),
102-
mongodbContainer.getMappedPort(MONGODB_PORT));
103-
104114
mongoClient.getDatabase(MONGODB_DATABASE_NAME).drop();
105115
}
106116

jdk_8_maven/em/external/rest/genome-nexus/src/main/java/em/external/org/cbioportal/genome_nexus/ExternalEvoMasterController.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ public void preStop() {
163163

164164
@Override
165165
public void postStop() {
166+
mongoClient.close();
166167
mongodb.stop();
167168
}
168169

0 commit comments

Comments
 (0)