Skip to content

Commit aabfc11

Browse files
committed
Make tests faster
1 parent 9bf3852 commit aabfc11

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

java/src/main/java/com/start/Connection.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import com.mongodb.client.MongoDatabase;
2323

2424
public class Connection {
25-
2625
public static void main(String[] args) throws ParseException {
2726
Options options = new Options();
2827
options.addOption("uri", true, "MongoDB connection string."); // hasArg is true by default
@@ -36,14 +35,14 @@ public static void main(String[] args) throws ParseException {
3635

3736
if (cmd.hasOption("strict")) {
3837
ServerApi serverApi = ServerApi.builder()
39-
.version(ServerApiVersion.V1)
40-
.strict(true)
41-
.build();
38+
.version(ServerApiVersion.V1)
39+
.strict(true)
40+
.build();
4241

4342
MongoClientSettings settings = MongoClientSettings.builder()
44-
.applyConnectionString(new ConnectionString(uri))
45-
.serverApi(serverApi)
46-
.build();
43+
.applyConnectionString(new ConnectionString(uri))
44+
.serverApi(serverApi)
45+
.build();
4746

4847
mongoClient = MongoClients.create(settings);
4948
} else {
@@ -75,5 +74,9 @@ public static void main(String[] args) throws ParseException {
7574
assert actual.equals(new Document("_id", 4).append("a", 4)) : "Value should be 4";
7675

7776
mongoClient.close();
77+
78+
// quick way to kill driver's background threads
79+
// and prevent hanging for a long time
80+
System.exit(0);
7881
}
7982
}

0 commit comments

Comments
 (0)