-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#9610] Improvements to spring-data-mongodb-reactive
- Loading branch information
1 parent
44466a8
commit 0a049cc
Showing
32 changed files
with
734 additions
and
257 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 2 additions & 39 deletions
41
agent-testweb/mongodb-plugin-testweb/src/main/java/com/pinpoint/test/plugin/MongoServer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,10 @@ | ||
package com.pinpoint.test.plugin; | ||
|
||
import de.flapdoodle.embed.mongo.MongodExecutable; | ||
import de.flapdoodle.embed.mongo.MongodProcess; | ||
import de.flapdoodle.embed.mongo.MongodStarter; | ||
import de.flapdoodle.embed.mongo.config.MongodConfig; | ||
import de.flapdoodle.embed.mongo.config.Net; | ||
import de.flapdoodle.embed.mongo.distribution.Version; | ||
import de.flapdoodle.embed.process.runtime.Network; | ||
import org.springframework.stereotype.Component; | ||
|
||
import javax.annotation.PostConstruct; | ||
import javax.annotation.PreDestroy; | ||
|
||
@Component | ||
public class MongoServer { | ||
private MongodExecutable mongodExecutable; | ||
private MongodProcess mongod; | ||
private static final int PORT = 27017; | ||
private static final int PORT = 62449; | ||
|
||
public String getUri() { | ||
public static String getUri() { | ||
return "mongodb://localhost:" + PORT; | ||
} | ||
|
||
|
||
@PostConstruct | ||
public void init() throws Exception { | ||
MongodStarter starter = MongodStarter.getDefaultInstance(); | ||
|
||
MongodConfig mongodConfig = MongodConfig.builder() | ||
.version(Version.Main.PRODUCTION) | ||
.net(new Net(PORT, Network.localhostIsIPv6())) | ||
.build(); | ||
|
||
this.mongodExecutable = starter.prepare(mongodConfig); | ||
this.mongod = mongodExecutable.start(); | ||
} | ||
@PreDestroy | ||
public void destroy() { | ||
if (mongod != null) { | ||
mongod.stop(); | ||
} | ||
if (mongodExecutable != null) { | ||
mongodExecutable.stop(); | ||
} | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
...tweb/mongodb-plugin-testweb/src/test/java/com/pinpoint/test/plugin/mongo/MongodbTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright 2022 NAVER Corp. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.pinpoint.test.plugin.mongo; | ||
|
||
|
||
import org.junit.AfterClass; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import org.testcontainers.containers.MongoDBContainer; | ||
import org.testcontainers.utility.DockerImageName; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
public class MongodbTest { | ||
private static MongoDBContainer container; | ||
|
||
@BeforeClass | ||
public static void beforeClass() { | ||
// Assume.assumeTrue("Docker not enabled", DockerClientFactory.instance().isDockerAvailable()); | ||
container = new MongoDBContainer(DockerImageName.parse("mongo:4.0.10")); | ||
container.start(); | ||
|
||
System.out.println("##host=" + container.getHost()); | ||
System.out.println("##port=" + container.getFirstMappedPort()); | ||
} | ||
|
||
@AfterClass | ||
public static void select() { | ||
if (container != null) { | ||
container.stop(); | ||
} | ||
} | ||
|
||
@Test | ||
public void test() throws Exception { | ||
System.out.println("TEST"); | ||
TimeUnit.HOURS.sleep(8); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.