[SB3 Update] Move MongoDbTestContainerSupport to functions/common

- use in mongodb-consumer
- use in mongodb-supplier
This commit is contained in:
Chris Bono
2022-10-16 23:16:53 -05:00
parent 09d23c06a1
commit 8800a9c002
8 changed files with 81 additions and 14 deletions

View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.cloud.fn</groupId>
<artifactId>spring-functions-parent</artifactId>
<version>4.0.0-SNAPSHOT</version>
<relativePath>../../spring-functions-parent/pom.xml</relativePath>
</parent>
<artifactId>mongodb-common</artifactId>
<name>mongodb-common</name>
<description>MongoDB Common</description>
<dependencies>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mongodb</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.2</version>
<executions>
<execution>
<id>Jar Tests Package</id>
<phase>package</phase>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1 @@
# empty

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.cloud.fn.consumer.mongo;
package org.springframework.cloud.fn.common.mongo;
import org.junit.jupiter.api.BeforeAll;
import org.testcontainers.containers.MongoDBContainer;

View File

@@ -17,6 +17,7 @@
<module>ftp-common</module>
<module>function-test-support</module>
<module>metadata-store-common</module>
<module>mongodb-common</module>
<module>mqtt-common</module>
<module>redis-common</module>
<module>tcp-common</module>

View File

@@ -23,11 +23,18 @@
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-reactivestreams</artifactId>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mongodb</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mongodb</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud.fn</groupId>
<artifactId>mongodb-common</artifactId>
<version>4.0.0-SNAPSHOT</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@@ -30,6 +30,7 @@ import reactor.test.StepVerifier;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.fn.common.mongo.MongoDbTestContainerSupport;
import org.springframework.data.mongodb.core.ReactiveMongoTemplate;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.GenericMessage;

View File

@@ -33,11 +33,18 @@
<artifactId>splitter-function</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mongodb</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud.fn</groupId>
<artifactId>mongodb-common</artifactId>
<version>4.0.0-SNAPSHOT</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@@ -33,7 +33,10 @@ import reactor.test.StepVerifier;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.fn.common.mongo.MongoDbTestContainerSupport;
import org.springframework.messaging.Message;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.entry;
@@ -41,10 +44,15 @@ import static org.assertj.core.api.Assertions.entry;
@SpringBootTest(properties = {
"mongodb.supplier.collection=testing",
"mongodb.supplier.query={ name: { $exists: true }}",
"mongodb.supplier.update-expression='{ $unset: { name: 0 } }'",
"spring.mongodb.embedded.version=3.5.5"
"mongodb.supplier.update-expression='{ $unset: { name: 0 } }'"
})
class MongodbSupplierApplicationTests {
class MongodbSupplierApplicationTests implements MongoDbTestContainerSupport {
@DynamicPropertySource
static void mongoDbProperties(DynamicPropertyRegistry registry) {
registry.add("spring.data.mongodb.uri", MongoDbTestContainerSupport::mongoDbUri);
registry.add("spring.data.mongodb.database", () -> "test");
}
private ObjectMapper objectMapper = new ObjectMapper();