31 lines
1.3 KiB
Java
31 lines
1.3 KiB
Java
|
|
package com.config;
|
||
|
|
|
||
|
|
import com.common.service.DmStandardizedBatchWriter;
|
||
|
|
import com.common.service.impl.SyslogNonNormalMessageServiceImpl;
|
||
|
|
import org.junit.jupiter.api.Test;
|
||
|
|
import org.springframework.beans.factory.annotation.Value;
|
||
|
|
|
||
|
|
import java.io.InputStream;
|
||
|
|
import java.util.Properties;
|
||
|
|
|
||
|
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||
|
|
|
||
|
|
class DmBatchDefaultsTest {
|
||
|
|
@Test
|
||
|
|
void propertiesAndInjectionFallbacksBothDefaultTo2000() throws Exception {
|
||
|
|
Properties properties = new Properties();
|
||
|
|
try (InputStream input = getClass().getResourceAsStream("/application.properties")) {
|
||
|
|
properties.load(input);
|
||
|
|
}
|
||
|
|
assertEquals("${DM_STANDARDIZED_WRITE_BATCH_SIZE:2000}",
|
||
|
|
properties.getProperty("dm.standardized-write.batch-size"));
|
||
|
|
assertEquals("${DM_NON_NORMAL_WRITE_BATCH_SIZE:2000}",
|
||
|
|
properties.getProperty("dm.non-normal-write.batch-size"));
|
||
|
|
assertEquals("${dm.standardized-write.batch-size:2000}",
|
||
|
|
DmStandardizedBatchWriter.class.getDeclaredField("batchSize").getAnnotation(Value.class).value());
|
||
|
|
assertEquals("${dm.non-normal-write.batch-size:2000}",
|
||
|
|
SyslogNonNormalMessageServiceImpl.class.getDeclaredField("nonNormalBatchSize")
|
||
|
|
.getAnnotation(Value.class).value());
|
||
|
|
}
|
||
|
|
}
|