If you have a REST API with MongoDB as the persistence layer, you will want to write Integration Tests to validate the overall logic, and for such you can use either Embedded MongoDB or a MongoDB Test Container.
For the example below, we will be using flapdoodle-oss embedded mongo which has support in Springboot
Requirements:
- Write an Integration Test that uses Embedded Mongo, MockMVC in Springboot.
- Configure and customize the connection properties of the Embedded MongoDB Instance.
Problem Encountered: You cant use @DataMongoTest and @AutoConfigureMockMVC together. The exception you will encounter states:
Unsatisfied dependency expressed through field 'mvc'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.test.web.servlet.MockMvc' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)
Solution: In order to be able to run an Embedded MongoDB, auto configure mockMVC and autowire all proper beans, then you need to use.
@AutoConfigureMockMvc
@AutoConfigureDataMongo
@SpringBootTest
Lets write a simple project to cover the setup from API endpoint, @Controller, @Service, @Repository, and finally an IntegrationTest to validate.
The API will retrieve Users.
The domain object is User with [ID, Firstname, LastName]
The @Controller will expose our API endpoint for retrieving persisted Users.
The @Service will be the middle layer receiving input from the @Controller and passing the request to the @Repository layer and returning the response back.
The @Repository will deal with the persistence layer.
We will also create a @Configuration class that will only be used for the Integration Tests.
Maven Dependencies:
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example.mongodb.embedded</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>Demo project for usage of embedded mongodb</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.16</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
As this is a SpringBoot project, we will need to define our entry point.
DemoApplication.java
package com.example.mongodb.embedded.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
User.java
package com.example.mongodb.embedded.demo.entity;
import org.springframework.data.annotation.Id;
import lombok.Builder;
import lombok.Data;
@Data
@Builder
public class User {
@Id
private Long id;
private String firstName;
private String lastName;
}
UserController.java
package com.example.mongodb.embedded.demo.controller;
import com.example.mongodb.embedded.demo.entity.User;
import com.example.mongodb.embedded.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
public class UserController {
@Autowired
private UserService userService;
@GetMapping(value = "/" , params = "id")
public ResponseEntity<User> getUserById(Long id){
return ResponseEntity.of(userService.getUserById(id));
}
@GetMapping(value = "/" , params = "firstName")
public ResponseEntity<List<User>> getUsersByFirstName(String firstName){
return ResponseEntity.ok(userService.getUserByFirstName(firstName));
}
}
UserService.java
package com.example.mongodb.embedded.demo.service;
import com.example.mongodb.embedded.demo.entity.User;
import com.example.mongodb.embedded.demo.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
@Service
public class UserService {
@Autowired
private UserRepository userRepository;
public Optional<User> getUserById(Long id){
return userRepository.findById(id);
}
public List<User> getUserByFirstName(String firstName){
return userRepository.findByFirstName(firstName);
}
}
UserRepository.java
package com.example.mongodb.embedded.demo.repository;
import com.example.mongodb.embedded.demo.entity.User;
import org.springframework.data.mongodb.repository.MongoRepository;
import java.util.List;
public interface UserRepository extends MongoRepository<User, Long> {
//Spring converts this to Regex findByFirstnameRegex(String firstname) {"firstname" : {"$regex" : firstname }}
// automatically
public List<User> findByFirstName(String firstName);
}
MongoDbTestConfiguration.java This will exist in our src\test\java\com\example\mongodb\embedded\demo directory and its purpose is to costumize the embedded MongoDb IP/Port information. I wanted to change it to use localhost:28017 just to see if it is possible 🙂 and it worked. This @configuration will only affect our Tests.
package com.example.mongodb.embedded.demo;
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.distribution.Version;
import de.flapdoodle.embed.process.runtime.Network;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.io.IOException;
@Configuration
public class MongoDbTestConfiguration {
private static final String IP = "localhost";
private static final int PORT = 28017;
@Bean
public IMongodConfig embeddedMongoConfiguration() throws IOException {
return new MongodConfigBuilder()
.version(Version.V4_0_2)
.net(new Net(IP, PORT, Network.localhostIsIPv6()))
.build();
}
}
UserControllerIT.java
package com.example.mongodb.embedded.demo.controller;
import com.example.mongodb.embedded.demo.entity.User;
import com.example.mongodb.embedded.demo.repository.UserRepository;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.data.mongo.AutoConfigureDataMongo;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.web.servlet.MockMvc;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@AutoConfigureMockMvc
@AutoConfigureDataMongo
@SpringBootTest
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class UserControllerIT {
@Autowired
private MockMvc mvc;
@Autowired
private UserRepository userRepository;
@BeforeAll
public void setup(){
userRepository.save(User.builder().id(1L).firstName("James").lastName("Bond").build());
userRepository.save(User.builder().id(2L).firstName("James").lastName("Farley").build());
userRepository.save(User.builder().id(3L).firstName("Marley").lastName("Hemp").build());
userRepository.save(User.builder().id(4L).firstName("James").lastName("Bond").build());
}
@Test
public void test_getById_successfull() throws Exception {
mvc.perform(get("/").param("id", "1")).andExpect(status().isOk()).andExpect(content().string("{\"id\":1,\"firstName\":\"James\",\"lastName\":\"Bond\"}")); ;
mvc.perform(get("/").param("id", "2")).andExpect(status().isOk()).andExpect(content().string("{\"id\":2,\"firstName\":\"James\",\"lastName\":\"Farley\"}")); ;
mvc.perform(get("/").param("id", "3")).andExpect(status().isOk()).andExpect(content().string("{\"id\":3,\"firstName\":\"Marley\",\"lastName\":\"Hemp\"}"));
mvc.perform(get("/").param("id", "4")).andExpect(status().isOk()).andExpect(content().string("{\"id\":4,\"firstName\":\"James\",\"lastName\":\"Bond\"}")); ;
}
@Test
public void test_getByFirstName_successfull() throws Exception {
mvc.perform(get("/").param("firstName", "James")).andExpect(status().isOk()).andExpect(content().string("[{\"id\":1,\"firstName\":\"James\",\"lastName\":\"Bond\"},{\"id\":2,\"firstName\":\"James\",\"lastName\":\"Farley\"},{\"id\":4,\"firstName\":\"James\",\"lastName\":\"Bond\"}]"));
mvc.perform(get("/").param("firstName", "Marley")).andExpect(status().isOk()).andExpect(content().string("[{\"id\":3,\"firstName\":\"Marley\",\"lastName\":\"Hemp\"}]")); ;
}
}
Log. As seen in the log, we are starting up an embedded MongoDb instance on localhost:28017. If you remote the @Configuration file, then MongoDb Embedded will still start up and work, but will connect to a random port on localhost.
"C:\Program Files\Java\jdk-11.0.7\bin\java.exe" -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.1\lib\idea_rt.jar=56512:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.1\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\ezsusmu\AppData\Local\Temp\classpath790150688.jar com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit5 com.example.mongodb.embedded.demo.controller.UserControllerIT
22:20:18.551 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
22:20:18.571 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)]
22:20:18.609 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [com.example.mongodb.embedded.demo.controller.UserControllerIT] from class [org.springframework.boot.test.context.SpringBootTestContextBootstrapper]
22:20:18.625 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [com.example.mongodb.embedded.demo.controller.UserControllerIT], using SpringBootContextLoader
22:20:18.633 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.example.mongodb.embedded.demo.controller.UserControllerIT]: class path resource [com/example/mongodb/embedded/demo/controller/UserControllerIT-context.xml] does not exist
22:20:18.634 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.example.mongodb.embedded.demo.controller.UserControllerIT]: class path resource [com/example/mongodb/embedded/demo/controller/UserControllerITContext.groovy] does not exist
22:20:18.634 [main] INFO org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [com.example.mongodb.embedded.demo.controller.UserControllerIT]: no resource found for suffixes {-context.xml, Context.groovy}.
22:20:18.635 [main] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [com.example.mongodb.embedded.demo.controller.UserControllerIT]: UserControllerIT does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
22:20:18.739 [main] DEBUG org.springframework.test.context.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [com.example.mongodb.embedded.demo.controller.UserControllerIT]
22:20:18.859 [main] DEBUG org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider - Identified candidate component class: file [C:\Users\ezsusmu\Downloads\demo\target\classes\com\example\mongodb\embedded\demo\DemoApplication.class]
22:20:18.861 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Found @SpringBootConfiguration com.example.mongodb.embedded.demo.DemoApplication for test class com.example.mongodb.embedded.demo.controller.UserControllerIT
22:20:19.020 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - @TestExecutionListeners is not present for class [com.example.mongodb.embedded.demo.controller.UserControllerIT]: using defaults.
22:20:19.021 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.event.ApplicationEventsTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, org.springframework.test.context.event.EventPublishingTestExecutionListener]
22:20:19.053 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@4097cac, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@ec2cc4, org.springframework.test.context.event.ApplicationEventsTestExecutionListener@2a5b3fee, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@7c1e2a2d, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@333dd51e, org.springframework.test.context.support.DirtiesContextTestExecutionListener@52d645b1, org.springframework.test.context.transaction.TransactionalTestExecutionListener@2101b44a, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@2cc3ad05, org.springframework.test.context.event.EventPublishingTestExecutionListener@710b18a6, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@119020fb, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@3d9f6567, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@c055c54, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@25e2ab5a, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@35e5d0e5, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener@73173f63]
22:20:19.093 [main] DEBUG org.springframework.test.context.support.TestPropertySourceUtils - Adding inlined properties to environment: {spring.jmx.enabled=false, org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.4.3)
2021-03-08 22:20:19.617 INFO 35152 --- [ main] c.e.m.e.d.controller.UserControllerIT : Starting UserControllerIT using Java
2021-03-08 22:20:19.621 INFO 35152 --- [ main] c.e.m.e.d.controller.UserControllerIT : No active profile set, falling back to default profiles: default
2021-03-08 22:20:21.094 INFO 35152 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data MongoDB repositories in DEFAULT mode.
2021-03-08 22:20:21.221 INFO 35152 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 117 ms. Found 1 MongoDB repository interfaces.
2021-03-08 22:20:23.792 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:23.791+0100 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2021-03-08 22:20:23.796 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:23.792+0100 I CONTROL [main] note: noprealloc may hurt performance in many applications
2021-03-08 22:20:23.953 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:23.953+0100 I CONTROL [initandlisten] MongoDB starting : pid=26996 port=28017 dbpath=C:\Users\ezsusmu\AppData\Local\Temp\embedmongo-db-d7afa1ef-e576-400a-9d56-625f5d44c05d 64-bit host=SE-00018098
2021-03-08 22:20:23.953 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:23.953+0100 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2021-03-08 22:20:23.953 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:23.953+0100 I CONTROL [initandlisten] db version v4.0.2
2021-03-08 22:20:23.953 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:23.953+0100 I CONTROL [initandlisten] git version: fc1573ba18aee42f97a3bb13b67af7d837826b47
2021-03-08 22:20:23.953 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:23.953+0100 I CONTROL [initandlisten] allocator: tcmalloc
2021-03-08 22:20:23.954 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:23.953+0100 I CONTROL [initandlisten] modules: none
2021-03-08 22:20:23.954 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:23.953+0100 I CONTROL [initandlisten] build environment:
2021-03-08 22:20:23.954 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:23.953+0100 I CONTROL [initandlisten] distmod: 2008plus-ssl
2021-03-08 22:20:23.954 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:23.953+0100 I CONTROL [initandlisten] distarch: x86_64
2021-03-08 22:20:23.954 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:23.953+0100 I CONTROL [initandlisten] target_arch: x86_64
2021-03-08 22:20:23.954 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:23.953+0100 I CONTROL [initandlisten] options: { net: { bindIp: "127.0.0.1", port: 28017 }, security: { authorization: "disabled" }, storage: { dbPath: "C:\Users\ezsusmu\AppData\Local\Temp\embedmongo-db-d7afa1ef-e576-400a-9d56-625f5d44c05d", journal: { enabled: false }, mmapv1: { preallocDataFiles: false, smallFiles: true }, syncPeriodSecs: 0.0 } }
2021-03-08 22:20:23.957 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:23.957+0100 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=15793M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),statistics_log=(wait=0),verbose=(recovery_progress),,log=(enabled=false),
2021-03-08 22:20:23.983 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:23.983+0100 I STORAGE [initandlisten] WiredTiger message [1615238423:983329][26996:140704645209760], txn-recover: Set global recovery timestamp: 0
2021-03-08 22:20:24.008 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:24.008+0100 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2021-03-08 22:20:24.076 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:24.076+0100 W STORAGE [initandlisten] Detected configuration for non-active storage engine mmapv1 when current storage engine is wiredTiger
2021-03-08 22:20:24.077 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:24.077+0100 I STORAGE [initandlisten] createCollection: admin.system.version with provided UUID: 8d1f9c53-2a79-476c-a7d9-fbcbd147b6aa
2021-03-08 22:20:24.152 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:24.153+0100 I COMMAND [initandlisten] setting featureCompatibilityVersion to 4.0
2021-03-08 22:20:24.158 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:24.158+0100 I STORAGE [initandlisten] createCollection: local.startup_log with generated UUID: bc68b343-2263-407e-af1b-294a1f690a5c
2021-03-08 22:20:24.792 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:24.792+0100 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory 'C:/Users/ezsusmu/AppData/Local/Temp/embedmongo-db-d7afa1ef-e576-400a-9d56-625f5d44c05d/diagnostic.data'
2021-03-08 22:20:24.796 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:24.796+0100 I STORAGE [LogicalSessionCacheRefresh] createCollection: config.system.sessions with generated UUID: 34e8c174-0d62-4b4a-8c16-eccfb58890a8
2021-03-08 22:20:24.796 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:24.796+0100 I NETWORK [initandlisten] waiting for connections on port 28017
2021-03-08 22:20:24.797 INFO 35152 --- [ main] d.f.embed.mongo.MongodExecutable : start de.flapdoodle.embed.mongo.config.MongodConfigBuilder$ImmutableMongodConfig@6e6d4780
2021-03-08 22:20:24.912 INFO 35152 --- [ main] org.mongodb.driver.cluster : Cluster created with settings {hosts=[localhost:28017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms'}
2021-03-08 22:20:24.926 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:24.926+0100 I INDEX [LogicalSessionCacheRefresh] build index on: config.system.sessions properties: { v: 2, key: { lastUse: 1 }, name: "lsidTTLIndex", ns: "config.system.sessions", expireAfterSeconds: 1800 }
2021-03-08 22:20:24.926 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:24.926+0100 I INDEX [LogicalSessionCacheRefresh] building index using bulk method; build may temporarily use up to 500 megabytes of RAM
2021-03-08 22:20:24.932 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:24.932+0100 I INDEX [LogicalSessionCacheRefresh] build index done. scanned 0 total records. 0 secs
2021-03-08 22:20:24.933 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:24.933+0100 I COMMAND [LogicalSessionCacheRefresh] command config.$cmd command: createIndexes { createIndexes: "system.sessions", indexes: [ { key: { lastUse: 1 }, name: "lsidTTLIndex", expireAfterSeconds: 1800 } ], $db: "config" } numYields:0 reslen:114 locks:{ Global: { acquireCount: { r: 1, w: 1 } }, Database: { acquireCount: { W: 1 } }, Collection: { acquireCount: { w: 1 } } } protocol:op_msg 136ms
2021-03-08 22:20:24.964 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:24.964+0100 I NETWORK [listener] connection accepted from 127.0.0.1:56530 #1 (1 connection now open)
2021-03-08 22:20:24.965 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:24.965+0100 I NETWORK [listener] connection accepted from 127.0.0.1:56531 #2 (2 connections now open)
2021-03-08 22:20:24.978 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:24.978+0100 I NETWORK [conn2] received client metadata from 127.0.0.1:56531 conn2: { driver: { name: "mongo-java-driver|sync|spring-boot", version: "4.1.1" }, os: { type: "Windows", name: "Windows 10", architecture: "amd64", version: "10.0" }, platform: "Java/Oracle Corporation/11.0.7+8-LTS" }
2021-03-08 22:20:24.978 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:24.978+0100 I NETWORK [conn1] received client metadata from 127.0.0.1:56530 conn1: { driver: { name: "mongo-java-driver|sync|spring-boot", version: "4.1.1" }, os: { type: "Windows", name: "Windows 10", architecture: "amd64", version: "10.0" }, platform: "Java/Oracle Corporation/11.0.7+8-LTS" }
2021-03-08 22:20:24.997 INFO 35152 --- [localhost:28017] org.mongodb.driver.connection : Opened connection [connectionId{localValue:2, serverValue:2}] to localhost:28017
2021-03-08 22:20:24.997 INFO 35152 --- [localhost:28017] org.mongodb.driver.connection : Opened connection [connectionId{localValue:1, serverValue:1}] to localhost:28017
2021-03-08 22:20:24.999 INFO 35152 --- [localhost:28017] org.mongodb.driver.cluster : Monitor thread successfully connected to server with description ServerDescription{address=localhost:28017, type=STANDALONE, state=CONNECTED, ok=true, minWireVersion=0, maxWireVersion=7, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=30073400}
2021-03-08 22:20:26.253 INFO 35152 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2021-03-08 22:20:26.895 INFO 35152 --- [ main] o.s.b.t.m.w.SpringBootMockServletContext : Initializing Spring TestDispatcherServlet ''
2021-03-08 22:20:26.896 INFO 35152 --- [ main] o.s.t.web.servlet.TestDispatcherServlet : Initializing Servlet ''
2021-03-08 22:20:26.898 INFO 35152 --- [ main] o.s.t.web.servlet.TestDispatcherServlet : Completed initialization in 2 ms
2021-03-08 22:20:26.938 INFO 35152 --- [ main] c.e.m.e.d.controller.UserControllerIT : Started UserControllerIT in 7.832 seconds (JVM running for 9.503)
2021-03-08 22:20:27.134 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:27.134+0100 I NETWORK [listener] connection accepted from 127.0.0.1:56534 #3 (3 connections now open)
2021-03-08 22:20:27.135 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:27.135+0100 I NETWORK [conn3] received client metadata from 127.0.0.1:56534 conn3: { driver: { name: "mongo-java-driver|sync|spring-boot", version: "4.1.1" }, os: { type: "Windows", name: "Windows 10", architecture: "amd64", version: "10.0" }, platform: "Java/Oracle Corporation/11.0.7+8-LTS" }
2021-03-08 22:20:27.138 INFO 35152 --- [ main] org.mongodb.driver.connection : Opened connection [connectionId{localValue:3, serverValue:3}] to localhost:28017
2021-03-08 22:20:27.170 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:27.170+0100 I STORAGE [conn3] createCollection: test.user with generated UUID: 30bdad08-176c-416b-b564-e29eaae48f90
2021-03-08 22:20:28.405 INFO 35152 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
2021-03-08 22:20:28.414 INFO 35152 --- [extShutdownHook] org.mongodb.driver.connection : Closed connection [connectionId{localValue:3, serverValue:3}] to localhost:28017 because the pool has been closed.
2021-03-08 22:20:28.415 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:28.415+0100 I NETWORK [conn3] end connection 127.0.0.1:56534 (2 connections now open)
2021-03-08 22:20:28.416 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:28.416+0100 I NETWORK [conn1] end connection 127.0.0.1:56530 (1 connection now open)
2021-03-08 22:20:28.417 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:28.416+0100 I NETWORK [conn2] end connection 127.0.0.1:56531 (0 connections now open)
2021-03-08 22:20:28.419 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:28.419+0100 I NETWORK [listener] connection accepted from 127.0.0.1:56535 #4 (1 connection now open)
2021-03-08 22:20:28.420 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:28.420+0100 I COMMAND [conn4] terminating, shutdown command received { shutdown: 1, force: true, $db: "admin" }
2021-03-08 22:20:28.421 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:28.420+0100 I NETWORK [conn4] shutdown: going to close listening sockets...
2021-03-08 22:20:28.421 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:28.421+0100 I CONTROL [conn4] Shutting down free monitoring
2021-03-08 22:20:28.421 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:28.421+0100 I FTDC [conn4] Shutting down full-time diagnostic data capture
2021-03-08 22:20:28.426 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:28.426+0100 I STORAGE [conn4] WiredTigerKVEngine shutting down
2021-03-08 22:20:28.467 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:28.467+0100 I STORAGE [conn4] shutdown: removing fs lock...
2021-03-08 22:20:28.467 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:28.467+0100 I CONTROL [conn4] now exiting
2021-03-08 22:20:28.467 INFO 35152 --- [ Thread-2] o.s.b.a.mongo.embedded.EmbeddedMongo : 2021-03-08T22:20:28.467+0100 I CONTROL [conn4] shutting down with code:0
Process finished with exit code 0