- @LocalServerPort
- private int port;
- @Autowired
- private WebTestClient webTestClient;
-
- @Test
- void contextLoads()
- {
- Awaitility
- .await()
- .atMost(Duration.ofSeconds(15))
- .untilAsserted(() ->
- {
- webTestClient
- .get()
- .uri("http://localhost:{port}/actuator/health", port)
- .exchange()
- .expectStatus().isOk()
- .expectBody().jsonPath("$.status").isEqualTo("UP");
- webTestClient
- .get()
- .uri("http://localhost:{port}/618e89ae-fdc0-4c65-8055-f49908295e8f", port)
- .accept(MediaType.APPLICATION_JSON)
- .exchange()
- .expectStatus().isOk()
- .expectBody().jsonPath("$.name").isEqualTo("Peter's Chat-Room");
- webTestClient
- .get()
- .uri("http://localhost:{port}/618e89ae-fdc0-4c65-8055-f49908295e8f/ute/1478", port)
- .accept(MediaType.APPLICATION_JSON)
- .exchange()
- .expectStatus().isOk()
- .expectBody().jsonPath("$.text").isEqualTo("Nachricht Nr. 1478");
- });
- }
+ final static Path path = Paths.get("target","files");
+
+ final ObjectMapper mapper;
+ final FilesStorageStrategy storageStrategy;
+
+
+ public InMemoryWithFilesStorageIT()
+ {
+ super(Clock.systemDefaultZone());
+ mapper = new ObjectMapper();
+ mapper.registerModule(new JavaTimeModule());
+ mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
+ storageStrategy = new FilesStorageStrategy(
+ path,
+ chatRoomId -> 0,
+ mapper);
+ }
+
+
+ @Override
+ protected StorageStrategy getStorageStrategy()
+ {
+ return storageStrategy;
+ }
+
+ @BeforeEach
+ void reset() throws Exception
+ {
+ if (Files.exists(path))
+ {
+ Files
+ .walk(path)
+ .forEach(file ->
+ {
+ try
+ {
+ if (!file.equals(path))
+ {
+ log.debug("Deleting file {}", file);
+ Files.delete(file);
+ }
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException(e);
+ }
+ });
+ log.debug("Deleting data-directory {}", path);
+ Files.delete(path);
+ }
+ }