From d506ae77d45e71a9a92bdfff61fe0e9ea126c6be Mon Sep 17 00:00:00 2001 From: Jeffrey Phillips Freeman <jeffrey.freeman@syncleus.com> Date: Wed, 17 Jun 2015 20:45:50 -0400 Subject: [PATCH] Updated driver version. --- pom.xml | 2 +- .../maven/plugins/mongodb/StartMongoMojo.java | 8 +-- src/test/java/com/mongodb/EmbedMongoDB.java | 50 ++++--------------- 3 files changed, 11 insertions(+), 49 deletions(-) diff --git a/pom.xml b/pom.xml index 5a0fb17..5016d8f 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 74bc7d1..6853995 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 a58f7ea..bf3cfda 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) { - - } } -- GitLab