1 package de.juplo.kafka.chat.backend.persistence;
3 import com.fasterxml.jackson.databind.ObjectMapper;
4 import com.fasterxml.jackson.databind.SerializationFeature;
5 import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
6 import de.juplo.kafka.chat.backend.persistence.storage.files.FilesStorageStrategy;
7 import lombok.extern.slf4j.Slf4j;
8 import org.junit.jupiter.api.BeforeEach;
10 import java.io.IOException;
11 import java.nio.file.Files;
12 import java.nio.file.Path;
13 import java.nio.file.Paths;
14 import java.time.Clock;
18 public class InMemoryWithFilesStorageIT extends AbstractInMemoryStorageIT
20 final static Path path = Paths.get("target","files");
22 final ObjectMapper mapper;
23 final FilesStorageStrategy storageStrategy;
26 public InMemoryWithFilesStorageIT()
28 super(Clock.systemDefaultZone());
29 mapper = new ObjectMapper();
30 mapper.registerModule(new JavaTimeModule());
31 mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
32 storageStrategy = new FilesStorageStrategy(
40 protected StorageStrategy getStorageStrategy()
42 return storageStrategy;
46 void reset() throws Exception
48 if (Files.exists(path))
56 if (!file.equals(path))
58 log.debug("Deleting file {}", file);
64 throw new RuntimeException(e);
67 log.debug("Deleting data-directory {}", path);