package de.juplo.kafka.chat.backend;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
+import org.springframework.boot.autoconfigure.data.mongo.MongoReactiveDataAutoConfiguration;
+import org.springframework.boot.autoconfigure.data.mongo.MongoReactiveRepositoriesAutoConfiguration;
+import org.springframework.boot.autoconfigure.mongo.MongoReactiveAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
{
return Clock.systemDefaultZone();
}
+
+
+ @ConditionalOnExpression("!'${chat.backend.inmemory.storage-strategy}'.toLowerCase().equals('mongodb')")
+ @Configuration
+ @EnableAutoConfiguration(exclude = {
+ MongoReactiveDataAutoConfiguration.class,
+ MongoReactiveAutoConfiguration.class,
+ MongoReactiveRepositoriesAutoConfiguration.class })
+ public static class DisableMongoDBConfiguration
+ {
+ }
}
import de.juplo.kafka.chat.backend.ChatBackendProperties;
import de.juplo.kafka.chat.backend.implementation.ShardingStrategy;
import de.juplo.kafka.chat.backend.implementation.StorageStrategy;
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.boot.autoconfigure.data.mongo.MongoReactiveDataAutoConfiguration;
-import org.springframework.boot.autoconfigure.data.mongo.MongoReactiveRepositoriesAutoConfiguration;
-import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
name = "storage-strategy",
havingValue = "files")
@Configuration
-@EnableAutoConfiguration(
- exclude = {
- MongoReactiveDataAutoConfiguration.class,
- MongoReactiveRepositoriesAutoConfiguration.class,
- MongoAutoConfiguration.class })
public class FilesStorageConfiguration
{
@Bean
package de.juplo.kafka.chat.backend.storage.nostorage;
import de.juplo.kafka.chat.backend.implementation.StorageStrategy;
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.boot.autoconfigure.data.mongo.MongoReactiveDataAutoConfiguration;
-import org.springframework.boot.autoconfigure.data.mongo.MongoReactiveRepositoriesAutoConfiguration;
-import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
havingValue = "none",
matchIfMissing = true)
@Configuration
-@EnableAutoConfiguration(
- exclude = {
- MongoReactiveDataAutoConfiguration.class,
- MongoReactiveRepositoriesAutoConfiguration.class,
- MongoAutoConfiguration.class })
public class NoStorageStorageConfiguration
{
@Bean
package de.juplo.kafka.chat.backend;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.BeforeEach;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import java.io.IOException;
"chat.backend.inmemory.sharding-strategy=none",
"chat.backend.inmemory.storage-strategy=files",
"chat.backend.inmemory.storage-directory=target/files" })
+@ContextConfiguration(classes = InMemoryWithFilesStorageIT.TestConfig.class)
@Slf4j
public class InMemoryWithFilesStorageIT extends AbstractInMemoryStorageIT
{
Files.delete(path);
}
}
+
+
+ static class TestConfig
+ {
+ @Bean
+ ObjectMapper objectMapper()
+ {
+ ObjectMapper objectMapper = new ObjectMapper();
+ objectMapper.registerModule(new JavaTimeModule());
+ objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
+ return objectMapper;
+ }
+ }
}
package de.juplo.kafka.chat.backend.domain;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import de.juplo.kafka.chat.backend.ChatBackendProperties;
import de.juplo.kafka.chat.backend.domain.exceptions.LoadInProgressException;
import de.juplo.kafka.chat.backend.domain.exceptions.UnknownChatroomException;
static class TestConfiguration
{
+ @Bean
+ ObjectMapper objectMapper()
+ {
+ ObjectMapper objectMapper = new ObjectMapper();
+ objectMapper.registerModule(new JavaTimeModule());
+ return objectMapper;
+ }
+
@Bean
Clock clock()
{