diff --git a/pom.xml b/pom.xml index 8d9ee0cea44219a0ef44cb7f1a33d74b2de02165..c9f8c7fdefb200c8f1c44ccab4e97dee1ec2a398 100644 --- a/pom.xml +++ b/pom.xml @@ -16,10 +16,11 @@ * Philadelphia, PA 19148 * ******************************************************************************* --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> - + <groupId>com.syncleus.maven.plugins</groupId> <artifactId>maven-mongodb-plugin</artifactId> <version>1.0.0-SNAPSHOT</version> diff --git a/src/main/java/com/syncleus/maven/plugins/mongodb/PortUtils.java b/src/main/java/com/syncleus/maven/plugins/mongodb/PortUtils.java index 17336b9bc3909c6c129a1900b29b29f999d457d4..e174b896cb9c8c6a0b8cdb076a9072e5b6bb329b 100644 --- a/src/main/java/com/syncleus/maven/plugins/mongodb/PortUtils.java +++ b/src/main/java/com/syncleus/maven/plugins/mongodb/PortUtils.java @@ -1,6 +1,6 @@ /** * Copyright: (c) Syncleus, Inc. - * + * <p/> * 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. @@ -9,7 +9,7 @@ * 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: - * + * <p/> * Syncleus, Inc. * 2604 South 12th Street * Philadelphia, PA 19148 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 787aaa6eafb38405e41eda4b7498bb7fe156b098..84cf476201461ca955bfb035bf6674bdba9ca62b 100644 --- a/src/main/java/com/syncleus/maven/plugins/mongodb/StartMongoMojo.java +++ b/src/main/java/com/syncleus/maven/plugins/mongodb/StartMongoMojo.java @@ -1,6 +1,6 @@ /** * Copyright: (c) Syncleus, Inc. - * + * <p/> * 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. @@ -9,47 +9,20 @@ * 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: - * + * <p/> * Syncleus, Inc. * 2604 South 12th Street * Philadelphia, PA 19148 */ package com.syncleus.maven.plugins.mongodb; -import static java.util.Collections.*; - -import java.io.File; -import java.io.IOException; -import java.net.Authenticator; -import java.net.InetSocketAddress; -import java.net.PasswordAuthentication; -import java.net.Proxy; -import java.net.ProxySelector; -import java.net.SocketAddress; -import java.net.URI; -import java.net.UnknownHostException; -import java.util.List; -import java.util.concurrent.TimeUnit; - -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.project.MavenProject; - import com.syncleus.maven.plugins.mongodb.log.Loggers; import com.syncleus.maven.plugins.mongodb.log.Loggers.LoggingStyle; - import de.flapdoodle.embed.mongo.Command; import de.flapdoodle.embed.mongo.MongodExecutable; import de.flapdoodle.embed.mongo.MongodProcess; import de.flapdoodle.embed.mongo.MongodStarter; -import de.flapdoodle.embed.mongo.config.ArtifactStoreBuilder; -import de.flapdoodle.embed.mongo.config.DownloadConfigBuilder; -import de.flapdoodle.embed.mongo.config.IMongodConfig; -import de.flapdoodle.embed.mongo.config.MongodConfigBuilder; -import de.flapdoodle.embed.mongo.config.Net; -import de.flapdoodle.embed.mongo.config.RuntimeConfigBuilder; -import de.flapdoodle.embed.mongo.config.Storage; +import de.flapdoodle.embed.mongo.config.*; import de.flapdoodle.embed.mongo.distribution.IFeatureAwareVersion; import de.flapdoodle.embed.mongo.distribution.Version; import de.flapdoodle.embed.mongo.distribution.Versions; @@ -62,6 +35,18 @@ import de.flapdoodle.embed.process.exceptions.DistributionException; import de.flapdoodle.embed.process.runtime.ICommandLinePostProcessor; import de.flapdoodle.embed.process.runtime.Network; import de.flapdoodle.embed.process.store.IArtifactStore; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.project.MavenProject; + +import java.io.File; +import java.io.IOException; +import java.net.*; +import java.util.List; +import java.util.concurrent.TimeUnit; + +import static java.util.Collections.singletonList; /** * When invoked, this goal starts an instance of mongo. The required binaries @@ -70,7 +55,7 @@ import de.flapdoodle.embed.process.store.IArtifactStore; * @goal start * @phase pre-integration-test * @see <a - * href="http://github.com/flapdoodle-oss/embedmongo.flapdoodle.de">http://github.com/flapdoodle-oss/embedmongo.flapdoodle.de</a> + * href="http://github.com/flapdoodle-oss/embedmongo.flapdoodle.de">http://github.com/flapdoodle-oss/embedmongo.flapdoodle.de</a> */ public class StartMongoMojo extends AbstractMojo { @@ -155,14 +140,14 @@ public class StartMongoMojo extends AbstractMojo { /** * @parameter expression="${mongodb.logFile}" - * default-value="mongodb.log" + * default-value="mongodb.log" * @since 1.0.0 */ private String logFile; /** * @parameter expression="${mongodb.logFileEncoding}" - * default-value="utf-8" + * default-value="utf-8" * @since 1.0.0 */ private String logFileEncoding; @@ -171,7 +156,7 @@ public class StartMongoMojo extends AbstractMojo { * The base URL to be used when downloading MongoDB * * @parameter expression="${mongodb.downloadPath}" - * default-value="http://fastdl.mongodb.org/" + * default-value="http://fastdl.mongodb.org/" * @since 1.0.0 */ private String downloadPath; @@ -257,11 +242,11 @@ public class StartMongoMojo extends AbstractMojo { } IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder() - .defaults(Command.MongoD) - .processOutput(getOutputConfig()) - .artifactStore(getArtifactStore()) - .commandLinePostProcessor(commandLinePostProcessor) - .build(); + .defaults(Command.MongoD) + .processOutput(getOutputConfig()) + .artifactStore(getArtifactStore()) + .commandLinePostProcessor(commandLinePostProcessor) + .build(); if (randomPort) { port = PortUtils.allocateRandomPort(); @@ -269,10 +254,10 @@ public class StartMongoMojo extends AbstractMojo { savePortToProjectProperties(); IMongodConfig config = new MongodConfigBuilder() - .version((getVersion() == null || getVersion().equals("") ? Version.Main.PRODUCTION : getVersion())) - .net(new Net(bindIp, port, Network.localhostIsIPv6())) - .replication(new Storage(getDataDirectory(), replSet, oplogSize)) - .build(); + .version((getVersion() == null || getVersion().equals("") ? Version.Main.PRODUCTION : getVersion())) + .net(new Net(bindIp, port, Network.localhostIsIPv6())) + .replication(new Storage(getDataDirectory(), replSet, oplogSize)) + .build(); executable = MongodStarter.getInstance(runtimeConfig).prepare(config); } catch (UnknownHostException e) { @@ -324,7 +309,7 @@ public class StartMongoMojo extends AbstractMojo { return Loggers.none(); default: throw new MojoFailureException("Unexpected logging style encountered: \"" + logging + "\" -> " + - loggingStyle); + loggingStyle); } } 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 b0714a59439b9e69bbd5e552b2e915a7b2fab37e..4a40bedeff965ad046bce83454ecb3740b6997c6 100644 --- a/src/main/java/com/syncleus/maven/plugins/mongodb/StopMongoMojo.java +++ b/src/main/java/com/syncleus/maven/plugins/mongodb/StopMongoMojo.java @@ -1,6 +1,6 @@ /** * Copyright: (c) Syncleus, Inc. - * + * <p/> * 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. @@ -9,23 +9,22 @@ * 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: - * + * <p/> * Syncleus, Inc. * 2604 South 12th Street * Philadelphia, PA 19148 */ package com.syncleus.maven.plugins.mongodb; +import de.flapdoodle.embed.mongo.MongodProcess; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; -import de.flapdoodle.embed.mongo.MongodProcess; - /** * When invoked, this goal stops an instance of mojo that was started by this * plugin. - * + * * @goal stop * @phase post-integration-test */ @@ -41,8 +40,8 @@ public class StopMongoMojo extends AbstractMojo { if (skip) { return; } - - MongodProcess mongod = (MongodProcess)getPluginContext().get(StartMongoMojo + + MongodProcess mongod = (MongodProcess) getPluginContext().get(StartMongoMojo .MONGOD_CONTEXT_PROPERTY_NAME); if (mongod != null) { diff --git a/src/main/java/com/syncleus/maven/plugins/mongodb/log/FileOutputStreamProcessor.java b/src/main/java/com/syncleus/maven/plugins/mongodb/log/FileOutputStreamProcessor.java index b20b8eb67d2c078f7d59c8661ac0c47d205cb661..da58d1a804e3f44e9e2abdc5bd5812954b1baad1 100644 --- a/src/main/java/com/syncleus/maven/plugins/mongodb/log/FileOutputStreamProcessor.java +++ b/src/main/java/com/syncleus/maven/plugins/mongodb/log/FileOutputStreamProcessor.java @@ -1,6 +1,6 @@ /** * Copyright: (c) Syncleus, Inc. - * + * <p/> * 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. @@ -9,19 +9,19 @@ * 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: - * + * <p/> * Syncleus, Inc. * 2604 South 12th Street * Philadelphia, PA 19148 */ package com.syncleus.maven.plugins.mongodb.log; +import de.flapdoodle.embed.process.io.IStreamProcessor; + import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; -import de.flapdoodle.embed.process.io.IStreamProcessor; - public class FileOutputStreamProcessor implements IStreamProcessor { private static OutputStreamWriter stream; diff --git a/src/main/java/com/syncleus/maven/plugins/mongodb/log/Loggers.java b/src/main/java/com/syncleus/maven/plugins/mongodb/log/Loggers.java index 9a53ebb8f388c6e912205acea7333bc1166ef255..a84a2449f6215e5e2e73e0bce2eeccdc80d03771 100644 --- a/src/main/java/com/syncleus/maven/plugins/mongodb/log/Loggers.java +++ b/src/main/java/com/syncleus/maven/plugins/mongodb/log/Loggers.java @@ -1,6 +1,6 @@ /** * Copyright: (c) Syncleus, Inc. - * + * <p/> * 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. @@ -9,7 +9,7 @@ * 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: - * + * <p/> * Syncleus, Inc. * 2604 South 12th Street * Philadelphia, PA 19148 @@ -23,17 +23,13 @@ import de.flapdoodle.embed.process.io.NamedOutputStreamProcessor; public class Loggers { - public enum LoggingStyle { - FILE, CONSOLE, NONE - } - public static ProcessOutput file(String logFile, String encoding) { FileOutputStreamProcessor file = new FileOutputStreamProcessor(logFile, encoding); return new ProcessOutput( - new NamedOutputStreamProcessor("[mongod output]", file), - new NamedOutputStreamProcessor("[mongod error]", file), - new NamedOutputStreamProcessor("[mongod commands]", file)); + new NamedOutputStreamProcessor("[mongod output]", file), + new NamedOutputStreamProcessor("[mongod error]", file), + new NamedOutputStreamProcessor("[mongod commands]", file)); } public static ProcessOutput console() { @@ -44,4 +40,8 @@ public class Loggers { NoopStreamProcessor noop = new NoopStreamProcessor(); return new ProcessOutput(noop, noop, noop); } + + public enum LoggingStyle { + FILE, CONSOLE, NONE + } } diff --git a/src/main/java/com/syncleus/maven/plugins/mongodb/log/NoopStreamProcessor.java b/src/main/java/com/syncleus/maven/plugins/mongodb/log/NoopStreamProcessor.java index 50c97355f4ae38841cc4287f492f9d3463af81be..7eb817d2a84824bb31e468e94b94f35b58c804ec 100644 --- a/src/main/java/com/syncleus/maven/plugins/mongodb/log/NoopStreamProcessor.java +++ b/src/main/java/com/syncleus/maven/plugins/mongodb/log/NoopStreamProcessor.java @@ -1,6 +1,6 @@ /** * Copyright: (c) Syncleus, Inc. - * + * <p/> * 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. @@ -9,7 +9,7 @@ * 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: - * + * <p/> * Syncleus, Inc. * 2604 South 12th Street * Philadelphia, PA 19148 diff --git a/src/test/java/com/syncleus/maven/plugins/mongodb/PortUtilsTest.java b/src/test/java/com/syncleus/maven/plugins/mongodb/PortUtilsTest.java index e246e4f2878ca4f259dfaf3a20006769bce03f8e..fd63f1ff21ac96fc8fd08bb52c1d0073fca3fc31 100644 --- a/src/test/java/com/syncleus/maven/plugins/mongodb/PortUtilsTest.java +++ b/src/test/java/com/syncleus/maven/plugins/mongodb/PortUtilsTest.java @@ -1,6 +1,6 @@ /** * Copyright: (c) Syncleus, Inc. - * + * <p/> * 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. @@ -9,13 +9,16 @@ * 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: - * + * <p/> * Syncleus, Inc. * 2604 South 12th Street * Philadelphia, PA 19148 */ package com.syncleus.maven.plugins.mongodb; +import org.junit.After; +import org.junit.Test; + import java.io.IOException; import java.net.ServerSocket; import java.util.Random; @@ -24,9 +27,6 @@ import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; -import org.junit.After; -import org.junit.Test; - public class PortUtilsTest { private final ScheduledExecutorService testPooledExecutor = Executors.newScheduledThreadPool(20); diff --git a/src/test/resources/example1/pom.xml b/src/test/resources/example1/pom.xml index 2ac8bb421a59203ca83583a55440dbc435aefdeb..cbbb313e1a738e202806b03b0f17c1004bb7c15f 100644 --- a/src/test/resources/example1/pom.xml +++ b/src/test/resources/example1/pom.xml @@ -16,8 +16,8 @@ * Philadelphia, PA 19148 * ******************************************************************************* --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> diff --git a/src/test/resources/example2/pom.xml b/src/test/resources/example2/pom.xml index 1ed9a9c297bc5b4f4ff87b85f3b92540d2182215..6fa669c7bcaa301eda13bc5883868fd74ba2c580 100644 --- a/src/test/resources/example2/pom.xml +++ b/src/test/resources/example2/pom.xml @@ -16,8 +16,8 @@ * Philadelphia, PA 19148 * ******************************************************************************* --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> @@ -54,10 +54,10 @@ </goals> <configuration> <port>37017</port> - <version>2.1.1</version> + <version>2.1.1</version> <databaseDirectory>.</databaseDirectory> <logging>file</logging> - <bindIp>127.0.0.1</bindIp> + <bindIp>127.0.0.1</bindIp> <authEnabled>false</authEnabled> </configuration> </execution> diff --git a/src/test/resources/example3/pom.xml b/src/test/resources/example3/pom.xml index 115cfdd06eaad4ef9e279638914f0ec170fb9481..dfd4bb9339cbb2e6bbf2464bdeb56db7cfaaa841 100644 --- a/src/test/resources/example3/pom.xml +++ b/src/test/resources/example3/pom.xml @@ -16,8 +16,8 @@ * Philadelphia, PA 19148 * ******************************************************************************* --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> diff --git a/src/test/resources/pom.xml b/src/test/resources/pom.xml index d6c5a52e1d71e46608fa3dde0bbf1c0a9c6a6da3..492df64dd7e47abb26bd8c141cd77c0dbebc5b95 100644 --- a/src/test/resources/pom.xml +++ b/src/test/resources/pom.xml @@ -16,8 +16,8 @@ * Philadelphia, PA 19148 * ******************************************************************************* --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> diff --git a/src/test/resources/randomport/pom.xml b/src/test/resources/randomport/pom.xml index c105923576516aaa3b453d32f62630525a6dc547..b26b5f9fcba44c7ed52d7bbc84a9d97fdb28bd81 100644 --- a/src/test/resources/randomport/pom.xml +++ b/src/test/resources/randomport/pom.xml @@ -16,8 +16,8 @@ * Philadelphia, PA 19148 * ******************************************************************************* --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> diff --git a/src/test/resources/randomport/src/test/java/com/syncleus/maven/plugins/mongodb/MongoIT.java b/src/test/resources/randomport/src/test/java/com/syncleus/maven/plugins/mongodb/MongoIT.java index 79128dba93818aba7bc069c209ef07fd1726f1f5..827ba5a7aa395591c700f0d51fed14ceab5383cb 100644 --- a/src/test/resources/randomport/src/test/java/com/syncleus/maven/plugins/mongodb/MongoIT.java +++ b/src/test/resources/randomport/src/test/java/com/syncleus/maven/plugins/mongodb/MongoIT.java @@ -1,6 +1,6 @@ /** * Copyright: (c) Syncleus, Inc. - * + * <p/> * 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. @@ -9,18 +9,18 @@ * 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: - * + * <p/> * Syncleus, Inc. * 2604 South 12th Street * Philadelphia, PA 19148 */ package com.syncleus.maven.plugins.mongodb; -import java.net.Socket; - import org.junit.After; import org.junit.Test; +import java.net.Socket; + public class MongoIT { private Socket mongoSocket;