1 package de.juplo.kafka.chat.backend;
3 import com.fasterxml.jackson.databind.ObjectMapper;
4 import com.fasterxml.jackson.databind.SerializationFeature;
5 import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
6 import lombok.extern.slf4j.Slf4j;
7 import org.junit.jupiter.api.BeforeEach;
8 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.context.annotation.Bean;
10 import org.springframework.test.context.ContextConfiguration;
11 import org.springframework.test.context.TestPropertySource;
13 import java.io.IOException;
14 import java.nio.file.Files;
15 import java.nio.file.Path;
16 import java.nio.file.Paths;
19 @TestPropertySource(properties = {
20 "chat.backend.inmemory.sharding-strategy=none",
21 "chat.backend.inmemory.storage-strategy=files",
22 "chat.backend.inmemory.storage-directory=target/files" })
23 @ContextConfiguration(classes = InMemoryWithFilesStorageIT.TestConfig.class)
25 public class InMemoryWithFilesStorageIT extends AbstractInMemoryStorageIT
29 @Autowired ChatBackendProperties properties)
32 Path path = Paths.get(properties.getInmemory().getStorageDirectory());
33 if (Files.exists(path))
41 if (!file.equals(path))
43 log.debug("Deleting file {}", file);
49 throw new RuntimeException(e);
52 log.debug("Deleting data-directory {}", path);
58 static class TestConfig
61 ObjectMapper objectMapper()
63 ObjectMapper objectMapper = new ObjectMapper();
64 objectMapper.registerModule(new JavaTimeModule());
65 objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);