From 3ae8ff6f8090b31ba13fae44674ec1e13ef7bc5e Mon Sep 17 00:00:00 2001 From: Jeffrey Phillips Freeman <jeffrey.freeman@syncleus.com> Date: Thu, 11 Jun 2015 21:56:34 -0400 Subject: [PATCH] Reformated all the code. --- pom.xml | 5 +- .../maven/plugins/mongodb/PortUtils.java | 4 +- .../maven/plugins/mongodb/StartMongoMojo.java | 73 ++++++++----------- .../maven/plugins/mongodb/StopMongoMojo.java | 13 ++-- .../log/FileOutputStreamProcessor.java | 8 +- .../maven/plugins/mongodb/log/Loggers.java | 18 ++--- .../mongodb/log/NoopStreamProcessor.java | 4 +- .../maven/plugins/mongodb/PortUtilsTest.java | 10 +-- src/test/resources/example1/pom.xml | 4 +- src/test/resources/example2/pom.xml | 8 +- src/test/resources/example3/pom.xml | 4 +- src/test/resources/pom.xml | 4 +- src/test/resources/randomport/pom.xml | 4 +- .../maven/plugins/mongodb/MongoIT.java | 8 +- 14 files changed, 76 insertions(+), 91 deletions(-) diff --git a/pom.xml b/pom.xml index 8d9ee0c..c9f8c7f 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 17336b9..e174b89 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 787aaa6..84cf476 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 b0714a5..4a40bed 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 b20b8eb..da58d1a 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 9a53ebb..a84a244 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 50c9735..7eb817d 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 e246e4f..fd63f1f 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 2ac8bb4..cbbb313 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 1ed9a9c..6fa669c 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 115cfdd..dfd4bb9 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 d6c5a52..492df64 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 c105923..b26b5f9 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 79128db..827ba5a 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; -- GitLab