diff --git a/pom.xml b/pom.xml index d4d72b0ba04e1831831b64550610bc2737dd3500..95d674e45ce6aee9b45b4ec6fc5ee09eed41b58f 100644 --- a/pom.xml +++ b/pom.xml @@ -185,6 +185,17 @@ <mavenExecutorId>forked-path</mavenExecutorId> </configuration> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-plugin-plugin</artifactId> + <version>3.4</version> + <executions> + <execution> + <id>default-descriptor</id> + <phase>process-classes</phase> + </execution> + </executions> + </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-gpg-plugin</artifactId> @@ -227,7 +238,7 @@ <dependency> <groupId>org.apache.maven</groupId> <artifactId>maven-project</artifactId> - <version>2.2.1</version> + <version>3.0-alpha-2</version> </dependency> <dependency> <groupId>de.flapdoodle.embed</groupId> @@ -245,6 +256,12 @@ <artifactId>mongo-java-driver</artifactId> <version>2.13.0</version> </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <version>1.10.19</version> + <scope>test</scope> + </dependency> </dependencies> <reporting> diff --git a/src/main/java/com/syncleus/maven/plugins/mongodb/AbstractMongoMojo.java b/src/main/java/com/syncleus/maven/plugins/mongodb/AbstractMongoMojo.java index 7d152f719246672e683bdf37b9dba9b6ee805f5e..f353574ca525e51765036591a3745ed2295d532b 100644 --- a/src/main/java/com/syncleus/maven/plugins/mongodb/AbstractMongoMojo.java +++ b/src/main/java/com/syncleus/maven/plugins/mongodb/AbstractMongoMojo.java @@ -30,6 +30,10 @@ public abstract class AbstractMongoMojo extends AbstractMojo { @Parameter(property = "mongodb.skip", defaultValue = "false") private boolean skip; + protected AbstractMongoMojo(final boolean skip) { + this.skip = skip; + } + @Override public final void execute() throws MojoExecutionException, MojoFailureException { if (skip) { diff --git a/src/main/java/com/syncleus/maven/plugins/mongodb/InitalizerConfig.java b/src/main/java/com/syncleus/maven/plugins/mongodb/InitializerConfig.java similarity index 89% rename from src/main/java/com/syncleus/maven/plugins/mongodb/InitalizerConfig.java rename to src/main/java/com/syncleus/maven/plugins/mongodb/InitializerConfig.java index e9e139ac8be88eb190f73f048e8395046fae0555..8b6042af9aec70d90af59f4f6122fc96d19ca823 100644 --- a/src/main/java/com/syncleus/maven/plugins/mongodb/InitalizerConfig.java +++ b/src/main/java/com/syncleus/maven/plugins/mongodb/InitializerConfig.java @@ -18,12 +18,12 @@ package com.syncleus.maven.plugins.mongodb; import java.io.File; -public class InitalizerConfig { +public class InitializerConfig { private File[] scripts; private String databaseName; - public InitalizerConfig(final File[] scripts, final String databaseName) { + public InitializerConfig(final File[] scripts, final String databaseName) { this.scripts = scripts; this.databaseName = databaseName; } 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 71d0c2dd6a82bffa12a6ad11367aef85c7d15c47..2e7d12c927c3a20d51b4e3fdcb2eb0b8b4247358 100644 --- a/src/main/java/com/syncleus/maven/plugins/mongodb/StartMongoMojo.java +++ b/src/main/java/com/syncleus/maven/plugins/mongodb/StartMongoMojo.java @@ -17,6 +17,7 @@ package com.syncleus.maven.plugins.mongodb; import com.mongodb.CommandResult; +import com.mongodb.DB; import com.mongodb.MongoClient; import com.mongodb.MongoException; import com.syncleus.maven.plugins.mongodb.log.Loggers; @@ -48,7 +49,6 @@ import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; -import com.mongodb.DB; import java.io.File; import java.io.FileNotFoundException; @@ -195,21 +195,18 @@ public class StartMongoMojo extends AbstractMongoMojo { /** * Should authorization be enabled for MongoDB - * */ @Parameter(property = "mongodb.authEnabled", defaultValue = "false") private boolean authEnabled; /** * Sets a value for the --replSet - * */ @Parameter(property = "mongodb.replSet") private String replSet; /** * Set the size for the MongoDB oplog - * */ @Parameter(property = "mongodb.oplogSize", defaultValue = "0") private int oplogSize; @@ -261,11 +258,70 @@ public class StartMongoMojo extends AbstractMongoMojo { private String defaultImportDatabase; @Parameter(property = "mongodb.parallel", defaultValue = "false") - private Boolean parallelImport; + private boolean parallelImport; private Integer setPort = null; - private InitalizerConfig[] initalizations; + private InitializerConfig[] initalizations; + + StartMongoMojo(int port, + boolean randomPort, + String version, + File databaseDirectory, + String bindIp, + String proxyHost, + int proxyPort, + boolean wait, + String logging, + String logFile, + String logFileEncoding, + String downloadPath, + String proxyUser, + String proxyPassword, + boolean authEnabled, + String replSet, + int oplogSize, + String executableNaming, + String artifactDirectory, + Integer syncDelay, + MavenProject project, + String[] features, + ImportDataConfig[] imports, + String defaultImportDatabase, + boolean parallelImport, + Integer setPort, + InitializerConfig[] initalizations, + boolean skip) { + + super(skip); + this.port = port; + this.randomPort = randomPort; + this.version = version; + this.databaseDirectory = databaseDirectory; + this.bindIp = bindIp; + this.proxyHost = proxyHost; + this.proxyPort = proxyPort; + this.wait = wait; + this.logging = logging; + this.logFile = logFile; + this.logFileEncoding = logFileEncoding; + this.downloadPath = downloadPath; + this.proxyUser = proxyUser; + this.proxyPassword = proxyPassword; + this.authEnabled = authEnabled; + this.replSet = replSet; + this.oplogSize = oplogSize; + this.executableNaming = executableNaming; + this.artifactDirectory = artifactDirectory; + this.syncDelay = syncDelay; + this.project = project; + this.features = features; + this.imports = imports; + this.defaultImportDatabase = defaultImportDatabase; + this.parallelImport = parallelImport; + this.setPort = setPort; + this.initalizations = initalizations; + } @Override @SuppressWarnings("unchecked") @@ -285,8 +341,7 @@ public class StartMongoMojo extends AbstractMongoMojo { executable = MongodStarter.getInstance(runtimeConfig).prepare(config); - } - catch (final DistributionException e) { + } catch (final DistributionException e) { throw new MojoExecutionException("Failed to download MongoDB distribution: " + e.withDistribution(), e); } @@ -297,8 +352,8 @@ public class StartMongoMojo extends AbstractMongoMojo { final MongodProcess mongod = executable.start(); this.executeWait(); - - getPluginContext().put(MONGOD_CONTEXT_PROPERTY_NAME, mongod); + if(getPluginContext() != null) + getPluginContext().put(MONGOD_CONTEXT_PROPERTY_NAME, mongod); } catch (final IOException e) { throw new MojoExecutionException("Unable to start the mongod", e); } @@ -326,27 +381,23 @@ public class StartMongoMojo extends AbstractMongoMojo { configBuilder = this.configureSyncDelay(configBuilder); return configBuilder.build(); - } - catch (final UnknownHostException e) { + } catch (final UnknownHostException e) { throw new MojoExecutionException("Unable to determine if localhost is ipv6", e); - } - catch (final IOException e) { + } catch (final IOException e) { throw new MojoExecutionException("Unable to Config MongoDB: ", e); } } private MongodConfigBuilder configureSyncDelay(final MongodConfigBuilder config) { - if(this.syncDelay == null) { + if (this.syncDelay == null) { return config.cmdOptions(new MongoCmdOptionsBuilder() - .defaultSyncDelay() - .build()); - } - else if(this.syncDelay > 0) { + .defaultSyncDelay() + .build()); + } else if (this.syncDelay > 0) { return config.cmdOptions(new MongoCmdOptionsBuilder() - .syncDelay(this.syncDelay) - .build()); - } - else + .syncDelay(this.syncDelay) + .build()); + } else return config; } @@ -393,17 +444,17 @@ public class StartMongoMojo extends AbstractMongoMojo { private IArtifactStore createArtifactStore() throws MojoFailureException { final ITempNaming naming; - if(executableNaming == null) + if (executableNaming == null) throw new IllegalStateException("executableNaming should never be null!"); - else if(executableNaming.equals("uuid")) + else if (executableNaming.equals("uuid")) naming = new UUIDTempNaming(); - else if(executableNaming.equals("user")) + else if (executableNaming.equals("user")) naming = new UserTempNaming(); else throw new MojoFailureException("Unexpected executable naming type encountered: \"" + executableNaming + "\""); de.flapdoodle.embed.process.config.store.DownloadConfigBuilder downloadConfig = new DownloadConfigBuilder().defaultsForCommand(Command.MongoD).downloadPath(downloadPath); - if(artifactDirectory != null ) { + if (artifactDirectory != null) { final IDirectory storePath = new FixedPath(artifactDirectory); downloadConfig = downloadConfig.artifactStorePath(storePath); } @@ -414,8 +465,8 @@ public class StartMongoMojo extends AbstractMongoMojo { final Feature[] features = getFeatures(); - if(this.version == null || this.version.equals("")) { - if(features.length == 0) + if (this.version == null || this.version.equals("")) { + if (features.length == 0) return Version.Main.PRODUCTION; this.version = Version.Main.PRODUCTION.asInDownloadPath(); } @@ -439,7 +490,7 @@ public class StartMongoMojo extends AbstractMongoMojo { }; } - if(features.length == 0) + if (features.length == 0) return Versions.withFeatures(determinedVersion); else return Versions.withFeatures(determinedVersion, features); @@ -476,8 +527,8 @@ public class StartMongoMojo extends AbstractMongoMojo { private Feature[] getFeatures() { final HashSet<Feature> featuresSet = new HashSet<Feature>(); - if(this.features != null && this.features.length > 0) { - for(final String featureString : this.features) + if (this.features != null && this.features.length > 0) { + for (final String featureString : this.features) featuresSet.add(Feature.valueOf(featureString.toUpperCase())); } final Feature[] retVal = new Feature[featuresSet.size()]; @@ -485,7 +536,7 @@ public class StartMongoMojo extends AbstractMongoMojo { } private int getPort() { - if( setPort != null ) + if (setPort != null) return setPort; if (randomPort) @@ -505,21 +556,21 @@ public class StartMongoMojo extends AbstractMongoMojo { } private void startImport() throws MojoExecutionException { - if(imports == null || imports.length == 0) + if (imports == null || imports.length == 0) return; final List<MongoImportProcess> pendingMongoProcess = new ArrayList<MongoImportProcess>(); getLog().info("Default import database: " + defaultImportDatabase); - for(final ImportDataConfig importData: imports) { + for (final ImportDataConfig importData : imports) { getLog().info("Import " + importData); verify(importData); String database = importData.getDatabase(); - if(StringUtils.isBlank(database)){ + if (StringUtils.isBlank(database)) { database = defaultImportDatabase; } @@ -540,18 +591,17 @@ public class StartMongoMojo extends AbstractMongoMojo { final MongoImportProcess importProcess = mongoImport.start(); - if(parallelImport) + if (parallelImport) pendingMongoProcess.add(importProcess); else waitFor(importProcess); - } - catch (final IOException e) { + } catch (final IOException e) { throw new MojoExecutionException("Unexpected IOException encountered", e); } } - for(final MongoImportProcess importProcess: pendingMongoProcess) + for (final MongoImportProcess importProcess : pendingMongoProcess) waitFor(importProcess); } @@ -560,12 +610,11 @@ public class StartMongoMojo extends AbstractMongoMojo { try { final int code = importProcess.waitFor(); - if(code != 0) + if (code != 0) throw new MojoExecutionException("Cannot import '" + importProcess.getConfig().getImportFile() + "'"); getLog().info("Import return code: " + code); - } - catch (final InterruptedException e) { + } catch (final InterruptedException e) { throw new MojoExecutionException("Thread execution interrupted", e); } @@ -587,14 +636,14 @@ public class StartMongoMojo extends AbstractMongoMojo { } private void startInitialization() throws MojoExecutionException, MojoFailureException { - if(initalizations == null || initalizations.length == 0) + if (initalizations == null || initalizations.length == 0) return; - for(final InitalizerConfig initConfig : this.initalizations ) { + for (final InitializerConfig initConfig : this.initalizations) { final DB db = connectToMongoAndGetDatabase(initConfig.getDatabaseName()); - for(final File scriptFile : initConfig.getScripts()) { - if(scriptFile.isDirectory()) + for (final File scriptFile : initConfig.getScripts()) { + if (scriptFile.isDirectory()) this.processScriptDirectory(db, scriptFile); else this.processScriptFile(db, scriptFile); @@ -602,7 +651,7 @@ public class StartMongoMojo extends AbstractMongoMojo { } } - private DB connectToMongoAndGetDatabase(final String databaseName) throws MojoExecutionException { + DB connectToMongoAndGetDatabase(final String databaseName) throws MojoExecutionException { if (databaseName == null || databaseName.trim().length() == 0) { throw new MojoExecutionException("Database name is missing"); } diff --git a/src/main/java/com/syncleus/maven/plugins/mongodb/StopMongoMojo.java b/src/main/java/com/syncleus/maven/plugins/mongodb/StopMongoMojo.java index b4287acb7b55b6bb1d7d40d0492955fa581f8ce3..ca3027a861dff5ae11c1dced4306e9741d06d1a3 100644 --- a/src/main/java/com/syncleus/maven/plugins/mongodb/StopMongoMojo.java +++ b/src/main/java/com/syncleus/maven/plugins/mongodb/StopMongoMojo.java @@ -31,6 +31,11 @@ import org.apache.maven.plugins.annotations.Parameter; */ @Mojo(name = "stop", defaultPhase = LifecyclePhase.POST_INTEGRATION_TEST) public class StopMongoMojo extends AbstractMongoMojo { + + StopMongoMojo(boolean skip) { + super(skip); + } + @Override public void start() throws MojoExecutionException, MojoFailureException { final MongodProcess mongod = (MongodProcess) getPluginContext().get(StartMongoMojo diff --git a/src/test/java/com/mongodb/EmbedMongoClient.java b/src/test/java/com/mongodb/EmbedMongoClient.java new file mode 100644 index 0000000000000000000000000000000000000000..f9cd60826b5088b123fffa72db1de7e2a26623c2 --- /dev/null +++ b/src/test/java/com/mongodb/EmbedMongoClient.java @@ -0,0 +1,24 @@ +/** + * Copyright: (c) Syncleus, Inc. + * + * You may redistribute and modify this source code under the terms and + * conditions of the Open Source Community License - Type C version 1.0 + * or any later version as published by Syncleus, Inc. at www.syncleus.com. + * There should be a copy of the license included with this file. If a copy + * of the license is not included you are granted no right to distribute or + * otherwise use this file except through a legal and valid license. You + * should also contact Syncleus, Inc. at the information below if you cannot + * find a license: + * + * Syncleus, Inc. + * 2604 South 12th Street + * Philadelphia, PA 19148 + */ +package com.mongodb; + +import java.net.UnknownHostException; + +public class EmbedMongoClient extends MongoClient { + public EmbedMongoClient() throws UnknownHostException { + } +} diff --git a/src/test/java/com/mongodb/EmbedMongoDB.java b/src/test/java/com/mongodb/EmbedMongoDB.java new file mode 100644 index 0000000000000000000000000000000000000000..a58f7ea2349aec5add17114d5b26c4d6c6824f7e --- /dev/null +++ b/src/test/java/com/mongodb/EmbedMongoDB.java @@ -0,0 +1,86 @@ +/** + * Copyright: (c) Syncleus, Inc. + * + * You may redistribute and modify this source code under the terms and + * conditions of the Open Source Community License - Type C version 1.0 + * or any later version as published by Syncleus, Inc. at www.syncleus.com. + * There should be a copy of the license included with this file. If a copy + * of the license is not included you are granted no right to distribute or + * otherwise use this file except through a legal and valid license. You + * should also contact Syncleus, Inc. at the information below if you cannot + * find a license: + * + * Syncleus, Inc. + * 2604 South 12th Street + * Philadelphia, PA 19148 + */ +package com.mongodb; + +import java.net.UnknownHostException; +import java.util.Set; + +public class EmbedMongoDB extends DB { + + public EmbedMongoDB(String name) throws UnknownHostException { + super(new EmbedMongoClient(), name); + } + + 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; + } + } + + @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()); + } + return commandResult; + } + + @Override + public void requestStart() { + + } + + @Override + public void requestDone() { + + } + + @Override + public void requestEnsureConnection() { + + } + + @Override + protected DBCollection doGetCollection(String name) { + return null; + } + + @Override + public Set<String> getCollectionNames() { + return null; + } + + @Override + CommandResult doAuthenticate(MongoCredential credentials) { + return null; + } + + @Override + public void cleanCursors(boolean force) { + + } +} diff --git a/src/test/java/com/syncleus/maven/plugins/mongodb/StartMongoMojoTest.java b/src/test/java/com/syncleus/maven/plugins/mongodb/StartMongoMojoTest.java new file mode 100644 index 0000000000000000000000000000000000000000..d5a0f30513ee47f4a88f8b02d7be0e586bb5086a --- /dev/null +++ b/src/test/java/com/syncleus/maven/plugins/mongodb/StartMongoMojoTest.java @@ -0,0 +1,139 @@ +/** + * Copyright: (c) Syncleus, Inc. + * + * You may redistribute and modify this source code under the terms and + * conditions of the Open Source Community License - Type C version 1.0 + * or any later version as published by Syncleus, Inc. at www.syncleus.com. + * There should be a copy of the license included with this file. If a copy + * of the license is not included you are granted no right to distribute or + * otherwise use this file except through a legal and valid license. You + * should also contact Syncleus, Inc. at the information below if you cannot + * find a license: + * + * Syncleus, Inc. + * 2604 South 12th Street + * Philadelphia, PA 19148 + */ +package com.syncleus.maven.plugins.mongodb; + +import com.mongodb.CommandResult; +import com.mongodb.DB; +import com.mongodb.EmbedMongoDB; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.project.MavenProject; +import org.junit.Assert; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.rules.TemporaryFolder; +import org.junit.runner.RunWith; +import org.mockito.BDDMockito; +import org.mockito.Matchers; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.net.UnknownHostException; + +@RunWith(MockitoJUnitRunner.class) +public class StartMongoMojoTest { + + @Rule + public TemporaryFolder createSchemaFolder = new TemporaryFolder(); + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + private final static int PORT = 27017; + private File rootFolder; + private File rootFolderWithError; + + @Test + public void testStartMongo() throws MojoFailureException, MojoExecutionException, IOException { + initFolder(); + try { + new StartMongoMojoForTest(27017, false, "3.0.2", null, null, null, 0, false, "console", null, "utf-8", "http://fastdl.mongodb.org/", null, null, false, null, 0, "uuid", null, 0, new MavenProject(), null, null, null, false, null, new InitializerConfig[]{new InitializerConfig(new File[]{rootFolder}, "myDB")}, false).execute(); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail("Should not fail!"); + } + } + + @Test + public void testStartMongoNoInitalizationDatabase() throws MojoFailureException, MojoExecutionException, IOException { + initFolder(); + + thrown.expect(MojoExecutionException.class); + thrown.expectMessage("Database name is missing"); + + new StartMongoMojo(27017, false, "3.0.2", null, null, null, 0, false,"console", null, "utf-8", "http://fastdl.mongodb.org/", null, null, false, null, 0, "uuid", null, 0, new MavenProject(), null, null, null, false, null, new InitializerConfig[]{new InitializerConfig(new File[]{rootFolder}, null)}, false).execute(); + } + + @Test + public void testStartMongoBadInitializationInstructions() throws IOException, MojoFailureException, MojoExecutionException { + DB database = Mockito.mock(DB.class); + initFolderWithError(); + + CommandResult result = new EmbedMongoDB("myDB").notOkErrorResult("Error while executing instructions from file '" + rootFolderWithError.listFiles()[0].getName()); + BDDMockito.given(database.doEval(Matchers.anyString(), Matchers.<Object>anyVararg())).willReturn(result); + + thrown.expect(MojoExecutionException.class); + thrown.expectMessage("Error while executing instructions from file '" + rootFolderWithError.listFiles()[0].getName()); + + new StartMongoMojoForTest(27017, false, "3.0.2", null, null, null, 0, false, "console", null, "utf-8", "http://fastdl.mongodb.org/", null, null, false, null, 0, "uuid", null, 0, new MavenProject(), null, null, null, false, null, new InitializerConfig[]{new InitializerConfig(new File[]{rootFolderWithError}, "myDB")}, false, database).execute(); + } + + private void initFolder() throws IOException { + File instructionsFile = createSchemaFolder.newFile(); + BufferedWriter out = null; + try { + out = new BufferedWriter(new FileWriter(instructionsFile)); + out.write("db.dropDatabase();\n"); + out.write("db.users.createIndex( { email: 1 }, { unique: true } );\n"); + } finally { + if (out != null) { + out.close(); + } + } + rootFolder = instructionsFile.getParentFile(); + rootFolder.mkdir(); + } + + private void initFolderWithError() throws IOException { + File instructionsFile = createSchemaFolder.newFile(); + BufferedWriter reader = null; + try { + reader = new BufferedWriter(new FileWriter(instructionsFile)); + reader.write("db.unknownInstruction();\n"); + } finally { + if (reader != null) { + reader.close(); + } + } + rootFolderWithError = instructionsFile.getParentFile(); + rootFolderWithError.mkdir(); + } + + static class StartMongoMojoForTest extends StartMongoMojo { + + private final DB database; + + public StartMongoMojoForTest(int port, boolean randomPort, String version, File databaseDirectory, String bindIp, String proxyHost, int proxyPort, boolean wait, String logging, String logFile, String logFileEncoding, String downloadPath, String proxyUser, String proxyPassword, boolean authEnabled, String replSet, int oplogSize, String executableNaming, String artifactDirectory, Integer syncDelay, MavenProject project, String[] features, ImportDataConfig[] imports, String defaultImportDatabase, Boolean parallelImport, Integer setPort, InitializerConfig[] initalizations, boolean skip) throws UnknownHostException { + this(port, randomPort, version, databaseDirectory, bindIp, proxyHost, proxyPort, wait, logging, logFile, logFileEncoding, downloadPath, proxyUser, proxyPassword, authEnabled, replSet, oplogSize, executableNaming, artifactDirectory, syncDelay, project, features, imports, defaultImportDatabase, parallelImport, setPort, initalizations, skip, new EmbedMongoDB("myDB")); + } + + public StartMongoMojoForTest(int port, boolean randomPort, String version, File databaseDirectory, String bindIp, String proxyHost, int proxyPort, boolean wait, String logging, String logFile, String logFileEncoding, String downloadPath, String proxyUser, String proxyPassword, boolean authEnabled, String replSet, int oplogSize, String executableNaming, String artifactDirectory, Integer syncDelay, MavenProject project, String[] features, ImportDataConfig[] imports, String defaultImportDatabase, Boolean parallelImport, Integer setPort, InitializerConfig[] initalizations, boolean skip, DB database) { + super(port, randomPort, version, databaseDirectory, bindIp, proxyHost, proxyPort, wait, logging, logFile, logFileEncoding, downloadPath, proxyUser, proxyPassword, authEnabled, replSet, oplogSize, executableNaming, artifactDirectory, syncDelay, project, features, imports, defaultImportDatabase, parallelImport, setPort, initalizations, skip); + this.database = database; + } + + @Override + DB connectToMongoAndGetDatabase(String databaseName) throws MojoExecutionException { + return database; + } + } +}