1 package de.juplo.kafka.chat.backend.persistence.inmemory;
3 import com.fasterxml.jackson.databind.ObjectMapper;
4 import de.juplo.kafka.chat.backend.domain.ChatHomeServiceWithShardsTest;
5 import de.juplo.kafka.chat.backend.persistence.ShardingStrategy;
6 import de.juplo.kafka.chat.backend.persistence.StorageStrategy;
7 import de.juplo.kafka.chat.backend.storage.files.FilesStorageStrategy;
8 import org.springframework.boot.test.context.TestConfiguration;
9 import org.springframework.context.annotation.Bean;
11 import java.nio.file.Paths;
12 import java.time.Clock;
13 import java.util.stream.IntStream;
15 public class ShardedChatHomeServiceTest extends ChatHomeServiceWithShardsTest
18 static class Configuration
21 ShardedChatHomeService chatHome(
22 StorageStrategy storageStrategy,
25 SimpleChatHomeService[] chatHomes = new SimpleChatHomeService[NUM_SHARDS];
29 .forEach(shard -> chatHomes[shard] = new SimpleChatHomeService(
35 ShardingStrategy strategy = new KafkaLikeShardingStrategy(NUM_SHARDS);
37 return new ShardedChatHomeService(chatHomes, strategy);
41 public FilesStorageStrategy storageStrategy(Clock clock)
43 return new FilesStorageStrategy(
44 Paths.get("target", "test-classes", "data", "files"),
45 new KafkaLikeShardingStrategy(NUM_SHARDS),
52 return Clock.systemDefaultZone();
57 return new int[] { OWNED_SHARD };