Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update dependencies #73

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.jupiter-tools</groupId>
<artifactId>spring-test-mongo</artifactId>
<version>0.15</version>
<version>0.16</version>
<packaging>jar</packaging>

<name>spring-test-mongo</name>
Expand Down Expand Up @@ -45,20 +45,21 @@
</developers>

<properties>
<spring-boot.version>[2.0.3.RELEASE, 2.3.1.RELEASE]</spring-boot.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-boot.version>2.7.4</spring-boot.version>
<junit.vintage.version>5.4.2</junit.vintage.version>
<junit-jupiter.version>5.4.2</junit-jupiter.version>
<junit-platform.version>1.4.2</junit-platform.version>
<jackson.version>2.11.0</jackson.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
<guava.version>27.1-jre</guava.version>
<org.reflections.version>0.9.11</org.reflections.version>
<junit-jupiter.version>5.9.0</junit-jupiter.version>
<junit-platform.version>1.9.0</junit-platform.version>
<jackson.version>2.13.4</jackson.version>
<guava.version>31.1-jre</guava.version>
<org.reflections.version>0.9.12</org.reflections.version>
<testcontainers.version>1.17.5</testcontainers.version>
<jna.version>5.12.1</jna.version>
</properties>

<distributionManagement>
Expand Down Expand Up @@ -139,20 +140,19 @@
<!-- Junit 5 -->

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.5</version>
<groupId>org.testcontainers</groupId>
<artifactId>mongodb</artifactId>
<version>${testcontainers.version}</version>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>1.10.2</version>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>${jna.version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
<version>2.11.0</version>
</dependency>


Expand All @@ -164,7 +164,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.20</version>
<version>1.18.24</version>
<scope>test</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import com.antkorwin.commonutils.exceptions.InternalException;
import org.junit.jupiter.api.extension.Extension;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.MongoDBContainer;
import org.testcontainers.images.builder.Transferable;

import java.io.IOException;
import java.util.UUID;

import static java.nio.charset.StandardCharsets.UTF_8;
Expand All @@ -22,23 +22,18 @@ public class MongoDbTcExtension implements Extension {
static {
System.out.println("Start MongoDb testcontainers extension...\n");

GenericContainer mongo = new GenericContainer("mongo:latest")
.withCommand("mongod --bind_ip_all --replSet rs0")
.withExposedPorts(MONGO_PORT);
MongoDBContainer mongo = new MongoDBContainer("mongo:6.0.2");

mongo.start();

executeInContainer(mongo, "mongo --eval \"rs.initiate()\" || \"rs.status().ok\"");
executeInContainer(mongo, "until mongo --eval \"printjson(rs.isMaster())\" | grep ismaster | grep true > /dev/null 2>&1;do sleep 1;done");

System.setProperty("spring.data.mongodb.host", mongo.getContainerIpAddress());
System.setProperty("spring.data.mongodb.host", mongo.getHost());
System.setProperty("spring.data.mongodb.port", mongo.getMappedPort(MONGO_PORT).toString());
System.setProperty("spring.data.mongodb.replicaSet", "rs0");
System.setProperty("spring.data.mongodb.replicaSet", "docker-rs");
}

private static void executeInContainer(GenericContainer container, String command) {
byte[] contentBytes = command.getBytes(UTF_8);
String shellFilePath = "/etc/mongo-" + UUID.randomUUID().toString();
String shellFilePath = "/etc/mongo-" + UUID.randomUUID();

try {
container.copyFileToContainer(Transferable.of(contentBytes), shellFilePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ void importWithDateValues() {
assertThat(foos).hasSize(2);

assertThat(foos.get(0).getId()).isEqualTo("1");
assertThat(foos.get(0).getTime()).isAfterOrEqualsTo(before);
assertThat(foos.get(0).getTime()).isAfterOrEqualTo(before);

assertThat(foos.get(1).getId()).isEqualTo("2");
assertThat(foos.get(1).getTime()).isAfterOrEqualsTo(plus3Days);
assertThat(foos.get(1).getTime()).isAfterOrEqualTo(plus3Days);
}

@Test
Expand All @@ -96,7 +96,7 @@ void importWithGroovyDataValues() {
List<Foo> foos = mongoTemplate.findAll(Foo.class);
assertThat(foos).hasSize(1);
assertThat(foos.get(0).getId()).isEqualTo("8");
assertThat(foos.get(0).getTime()).isAfterOrEqualsTo(before);
assertThat(foos.get(0).getTime()).isAfterOrEqualTo(before);
assertThat(foos.get(0).getCounter()).isEqualTo(55);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ void dynamicDateValue() {
verify(mongoTemplate, times(2)).save(captor.capture());

Date now = captor.getAllValues().get(0).getTime();
Assertions.assertThat(now).isAfterOrEqualsTo(before);
Assertions.assertThat(now).isAfterOrEqualTo(before);

Date plus = captor.getAllValues().get(1).getTime();
Assertions.assertThat(plus).isAfterOrEqualsTo(plus3days);
Assertions.assertThat(plus).isAfterOrEqualTo(plus3days);
}

@Test
Expand All @@ -191,7 +191,7 @@ void dynamicGroovy() {
verify(mongoTemplate).save(captor.capture());
Foo foo = captor.getValue();
assertThat(foo.getId()).isEqualTo("8");
assertThat(foo.getTime()).isAfterOrEqualsTo(before);
assertThat(foo.getTime()).isAfterOrEqualTo(before);
assertThat(foo.getCounter()).isEqualTo(55);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,28 @@ class EvaluateTests {
void currentTime() {
Date before = new Date();
Date now = (Date) new DateDynamicValue().evaluate("date:[NOW]");
assertThat(now).isAfterOrEqualsTo(before);
assertThat(now).isAfterOrEqualTo(before);
}

@Test
void plus3Minutes() {
Date expected = new Date(new Date().getTime() + TimeUnit.MINUTES.toMillis(3));
Date evaluate = (Date) new DateDynamicValue().evaluate("date:[NOW]+3(MINUTES)");
assertThat(evaluate).isAfterOrEqualsTo(expected);
assertThat(evaluate).isAfterOrEqualTo(expected);
}

@Test
void spaceBetweenPrefix() {
Date before = new Date();
Date now = (Date) new DateDynamicValue().evaluate("date: [NOW]");
assertThat(now).isAfterOrEqualsTo(before);
assertThat(now).isAfterOrEqualTo(before);
}

@Test
void spaceBetweenDirectionAndTimeUnit() {
Date expected = new Date(new Date().getTime() + TimeUnit.MINUTES.toMillis(3));
Date evaluate = (Date) new DateDynamicValue().evaluate("date: [NOW] + 3 (MINUTES)");
assertThat(evaluate).isAfterOrEqualsTo(expected);
assertThat(evaluate).isAfterOrEqualTo(expected);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ void dateTime() {
Date now = (Date) dynamicDataSet.read().get("test").get(0).get("now");
Date tomorrow = (Date) dynamicDataSet.read().get("test").get(0).get("tomorrow");

assertThat(now).isAfterOrEqualsTo(before);
assertThat(tomorrow).isAfterOrEqualsTo(new Date(before.getTime() + TimeUnit.MINUTES.toMillis(3)));
assertThat(now).isAfterOrEqualTo(before);
assertThat(tomorrow).isAfterOrEqualTo(new Date(before.getTime() + TimeUnit.MINUTES.toMillis(3)));

String dynamic = new JsonExport(dynamicDataSet).read();
System.out.println(dynamic);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void readOnlyFailTestInTheTestKitStyle() {
.selectors(selectMethod(RealTests.class, testMethod))
// Act
.execute()
.tests()
.testEvents()
// Assert
.assertStatistics(stats -> stats.started(1)
.succeeded(0)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,28 @@
package com.jupiter.tools.spring.test.mongo.junit5;

import java.util.Date;

import com.jupiter.tools.spring.test.mongo.Bar;
import com.jupiter.tools.spring.test.mongo.Foo;
import com.jupiter.tools.spring.test.mongo.annotation.ExpectedMongoDataSet;
import com.jupiter.tools.spring.test.mongo.annotation.MongoDataSet;
import com.jupiter.tools.spring.test.mongo.idea.skip.test.IdeaSkipTest;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIfSystemProperty;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.platform.launcher.LauncherDiscoveryRequest;
import org.junit.platform.launcher.core.LauncherFactory;
import org.junit.platform.launcher.listeners.SummaryGeneratingListener;
import org.junit.platform.launcher.listeners.TestExecutionSummary;
import org.junit.platform.testkit.engine.EngineTestKit;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.test.context.junit.jupiter.SpringExtension;

import java.util.Date;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.platform.engine.discovery.DiscoverySelectors.selectMethod;
import static org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder.request;
import static org.junit.platform.testkit.engine.EventConditions.event;
import static org.junit.platform.testkit.engine.EventConditions.finishedWithFailure;
import static org.junit.platform.testkit.engine.EventConditions.test;
import static org.junit.platform.testkit.engine.EventConditions.*;
import static org.junit.platform.testkit.engine.TestExecutionResultConditions.instanceOf;
import static org.junit.platform.testkit.engine.TestExecutionResultConditions.message;

Expand Down Expand Up @@ -134,7 +128,7 @@ void readOnlyFailTestInTheTestKitStyle() {
.selectors(selectMethod(RealTests.class, testMethod))
// Act
.execute()
.tests()
.testEvents()
// Assert
.assertStatistics(stats -> stats.started(1)
.succeeded(0)
Expand Down