diff --git a/build.gradle b/build.gradle index 4d754a8..6220670 100644 --- a/build.gradle +++ b/build.gradle @@ -40,7 +40,8 @@ dependencies { api "org.grails:grails-core" api "org.grails.profiles:plugin" api "org.grails:grails-gorm-testing-support" - api("de.flapdoodle.embed:de.flapdoodle.embed.mongo:2.2.0") { + api "de.flapdoodle.embed:de.flapdoodle.embed.process:4.5.0" + api("de.flapdoodle.embed:de.flapdoodle.embed.mongo:4.5.1") { exclude group: "commons-io" exclude group: "org.apache.commons", module: "commons-lang3" exclude group: "net.java.dev.jna" diff --git a/src/main/groovy/org/grails/plugin/embedded/mongodb/EmbeddedMongoDBGrailsPlugin.groovy b/src/main/groovy/org/grails/plugin/embedded/mongodb/EmbeddedMongoDBGrailsPlugin.groovy index 4958b0b..68c57aa 100644 --- a/src/main/groovy/org/grails/plugin/embedded/mongodb/EmbeddedMongoDBGrailsPlugin.groovy +++ b/src/main/groovy/org/grails/plugin/embedded/mongodb/EmbeddedMongoDBGrailsPlugin.groovy @@ -1,22 +1,18 @@ package org.grails.plugin.embedded.mongodb import com.mongodb.ServerAddress -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.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.distribution.IFeatureAwareVersion -import de.flapdoodle.embed.mongo.distribution.Version -import de.flapdoodle.embed.process.config.IRuntimeConfig -import de.flapdoodle.embed.process.config.io.ProcessOutput -import de.flapdoodle.embed.process.runtime.Network +import de.flapdoodle.embed.mongo.distribution.Versions +import de.flapdoodle.embed.mongo.transitions.Mongod +import de.flapdoodle.embed.mongo.transitions.RunningMongodProcess +import de.flapdoodle.embed.process.io.ProcessOutput +import de.flapdoodle.reverse.TransitionWalker +import de.flapdoodle.reverse.transitions.Start import grails.plugins.* import grails.util.Environment import org.grails.datastore.mapping.mongo.MongoDatastore +import de.flapdoodle.embed.process.distribution.Version class EmbeddedMongoDBGrailsPlugin extends Plugin { @@ -36,34 +32,31 @@ class EmbeddedMongoDBGrailsPlugin extends Plugin { } IFeatureAwareVersion getVersion() { - String version = config.getProperty("grails.mongodb.version", String, Version.Main.PRODUCTION.asInDownloadPath()) - Version.valueOf("V" + version.replaceAll(/(\.|-)/, '_').toUpperCase()) + String version = config.getProperty("grails.mongodb.version", String, de.flapdoodle.embed.mongo.distribution.Version.Main.V6_0.asInDownloadPath()) + Versions.withFeatures(Version.of(version)) } - static MongodExecutable mongodExecutable = null +// static MongodExecutable mongodExecutable = null + TransitionWalker.ReachedState started Closure doWithSpring() {{-> if (Environment.current == Environment.TEST) { - IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder() - .defaults(Command.MongoD) - .processOutput(ProcessOutput.defaultInstanceSilent) - .build() - - MongodStarter starter = MongodStarter.getInstance(runtimeConfig) - - IMongodConfig mongodConfig = new MongodConfigBuilder() - .version(getVersion()) - .net(new Net("127.0.0.1", getPort(), Network.localhostIsIPv6())) - .build() - - mongodExecutable = starter.prepare(mongodConfig) - mongodExecutable.start() + started = Mongod.instance() + .withProcessOutput(Start.to(ProcessOutput.class) + .providedBy(ProcessOutput::silent)) + .withNet(Start.to(Net.class) + .initializedWith(Net.builder() + .bindIp("127.0.0.1") + .port(getPort()) + .isIpv6(de.flapdoodle.net.Net.localhostIsIPv6()) + .build())) + .start(getVersion()) } }} void onShutdown(evt) { - if (mongodExecutable != null) { - mongodExecutable.stop() + if (started != null) { + started.close() } } diff --git a/src/test/groovy/org/grails/plugin/embedded/mongodb/EmbeddedMongoDBGrailsPluginSpec.groovy b/src/test/groovy/org/grails/plugin/embedded/mongodb/EmbeddedMongoDBGrailsPluginSpec.groovy index 518504c..16a165d 100644 --- a/src/test/groovy/org/grails/plugin/embedded/mongodb/EmbeddedMongoDBGrailsPluginSpec.groovy +++ b/src/test/groovy/org/grails/plugin/embedded/mongodb/EmbeddedMongoDBGrailsPluginSpec.groovy @@ -2,6 +2,7 @@ package org.grails.plugin.embedded.mongodb import com.mongodb.ServerAddress import de.flapdoodle.embed.mongo.distribution.Version +import de.flapdoodle.embed.mongo.distribution.Versions import grails.core.GrailsApplication import org.grails.config.PropertySourcesConfig import spock.lang.Specification @@ -20,7 +21,7 @@ class EmbeddedMongoDBGrailsPluginSpec extends Specification { } expect: - new EmbeddedMongoDBGrailsPlugin(grailsApplication: grailsApplication).getVersion().asInDownloadPath() == Version.Main.PRODUCTION.asInDownloadPath() + new EmbeddedMongoDBGrailsPlugin(grailsApplication: grailsApplication).getVersion().asInDownloadPath() == Version.Main.V6_0.asInDownloadPath() } void "test version"() { @@ -32,7 +33,7 @@ class EmbeddedMongoDBGrailsPluginSpec extends Specification { } expect: - new EmbeddedMongoDBGrailsPlugin(grailsApplication: grailsApplication).getVersion() == Version.V4_0_2 + new EmbeddedMongoDBGrailsPlugin(grailsApplication: grailsApplication).getVersion() == Versions.withFeatures(Version.of(Version.V4_0_2.asInDownloadPath())) } void "test version release candidate"() { @@ -44,7 +45,7 @@ class EmbeddedMongoDBGrailsPluginSpec extends Specification { } expect: - new EmbeddedMongoDBGrailsPlugin(grailsApplication: grailsApplication).getVersion() == Version.V3_2_1_RC3 + new EmbeddedMongoDBGrailsPlugin(grailsApplication: grailsApplication).getVersion() == Versions.withFeatures(Version.of(Version.V3_2_1_RC3.asInDownloadPath())) } void "test version not found"() { @@ -59,7 +60,7 @@ class EmbeddedMongoDBGrailsPluginSpec extends Specification { new EmbeddedMongoDBGrailsPlugin(grailsApplication: grailsApplication).getVersion() then: - thrown(IllegalArgumentException) + thrown(ArrayIndexOutOfBoundsException) } void "test default port"() { pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy