diff --git a/pom.xml b/pom.xml index 5a0fb1726e9b76fb4cf40bdbcfd339e0481434bc..5016d8fbd34da6f6ffb6414a0a93d7ab76f1ed1d 100644 --- a/pom.xml +++ b/pom.xml @@ -348,7 +348,7 @@ <dependency> <groupId>org.mongodb</groupId> <artifactId>mongo-java-driver</artifactId> - <version>2.13.0</version> + <version>3.0.2</version> </dependency> <dependency> <groupId>org.mockito</groupId> diff --git a/src/main/java/com/syncleus/maven/plugins/mongodb/StartMongoMojo.java b/src/main/java/com/syncleus/maven/plugins/mongodb/StartMongoMojo.java index 74bc7d14002cccb9e01c511e49ab45ae0956500e..6853995ed3aa32d9db54214a7f7c681e58c8e6f0 100644 --- a/src/main/java/com/syncleus/maven/plugins/mongodb/StartMongoMojo.java +++ b/src/main/java/com/syncleus/maven/plugins/mongodb/StartMongoMojo.java @@ -697,13 +697,7 @@ public class StartMongoMojo extends AbstractMongoMojo { throw new MojoExecutionException("Database name is missing"); } - final MongoClient mongoClient; - try { -// mongoClient = new MongoClient(Arrays.asList(new ServerAddress("localhost", getPort()))); - mongoClient = new MongoClient(new ServerAddress("localhost", getPort())); - } catch (final UnknownHostException e) { - throw new MojoExecutionException("Unable to connect to mongo instance", e); - } + final MongoClient mongoClient = new MongoClient(new ServerAddress("localhost", getPort())); getLog().info("Connected to MongoDB"); return mongoClient.getDB(databaseName); } diff --git a/src/test/java/com/mongodb/EmbedMongoDB.java b/src/test/java/com/mongodb/EmbedMongoDB.java index a58f7ea2349aec5add17114d5b26c4d6c6824f7e..bf3cfda19bedffea5137c063ba1b417f5922e518 100644 --- a/src/test/java/com/mongodb/EmbedMongoDB.java +++ b/src/test/java/com/mongodb/EmbedMongoDB.java @@ -16,6 +16,8 @@ */ package com.mongodb; +import org.bson.BsonDocument; + import java.net.UnknownHostException; import java.util.Set; @@ -26,44 +28,20 @@ public class EmbedMongoDB extends DB { } public CommandResult notOkErrorResult(String message) { - try { - CommandResult commandResult = new CommandResult(new ServerAddress("localhost")); - commandResult.put("errmsg", message); - commandResult.put("ok", 0); - return commandResult; - } catch (UnknownHostException e) { - return null; - } + CommandResult commandResult = new CommandResult(new BsonDocument(), new ServerAddress("localhost")); + commandResult.put("errmsg", message); + commandResult.put("ok", 0); + return commandResult; } @Override public CommandResult doEval(String code, Object... args) { - CommandResult commandResult; - try { - commandResult = new CommandResult(new ServerAddress("localhost")); - commandResult.put("ok", 1.0); - commandResult.put("retval", "null"); - } catch (UnknownHostException e) { - return notOkErrorResult(e.getMessage()); - } + CommandResult commandResult = new CommandResult(new BsonDocument(), new ServerAddress("localhost")); + commandResult.put("ok", 1.0); + commandResult.put("retval", "null"); return commandResult; } - @Override - public void requestStart() { - - } - - @Override - public void requestDone() { - - } - - @Override - public void requestEnsureConnection() { - - } - @Override protected DBCollection doGetCollection(String name) { return null; @@ -73,14 +51,4 @@ public class EmbedMongoDB extends DB { public Set<String> getCollectionNames() { return null; } - - @Override - CommandResult doAuthenticate(MongoCredential credentials) { - return null; - } - - @Override - public void cleanCursors(boolean force) { - - } }