Skip to content

Commit b45499e

Browse files
committed
test: add test for SinkOrchestratorTest ssl password loader
1 parent 2a53340 commit b45499e

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

dagger-core/src/test/java/com/gotocompany/dagger/core/sink/SinkOrchestratorTest.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,20 +113,24 @@ public void shouldParseSslPasswords() throws IOException {
113113
assertEquals(producerProperties.getProperty("ssl.keystore.password"), "keystore-password");
114114
}
115115

116-
@Test
117-
public void shouldThr() throws IOException {
118-
File trustStorePasswordFile = writeDummyPasswordFile("truststore-password.txt", "truststore-password");
119-
File keyStorePasswordFile = writeDummyPasswordFile("keystore-password.txt", "keystore-password");
120-
when(configuration.getString(eq(Constants.SINK_KAFKA_SSL_TRUSTSTORE_PASSWORD_LOCATION_KEY), anyString())).thenReturn(trustStorePasswordFile.getAbsolutePath());
121-
when(configuration.getString(eq(Constants.SINK_KAFKA_SSL_KEYSTORE_PASSWORD_LOCATION_KEY), anyString())).thenReturn(keyStorePasswordFile.getAbsolutePath());
116+
@Test(expected = IllegalArgumentException.class)
117+
public void shouldThrowWhenKeyStorePasswordIsNotExists() {
118+
when(configuration.getString(eq(Constants.SINK_KAFKA_SSL_KEYSTORE_PASSWORD_LOCATION_KEY), anyString())).thenReturn("/non-exists.txt");
122119
when(configuration.getString(eq(Constants.SINK_KAFKA_BROKERS_KEY), anyString())).thenReturn("10.200.216.87:6668");
123120
when(configuration.getBoolean(eq(Constants.SINK_KAFKA_PRODUCE_LARGE_MESSAGE_ENABLE_KEY), anyBoolean())).thenReturn(true);
124121
when(configuration.getString(eq(Constants.SINK_KAFKA_LINGER_MS_KEY), anyString())).thenReturn("1000");
125122

126-
Properties producerProperties = sinkOrchestrator.getProducerProperties(configuration);
123+
sinkOrchestrator.getProducerProperties(configuration);
124+
}
127125

128-
assertEquals(producerProperties.getProperty("ssl.truststore.password"), "truststore-password");
129-
assertEquals(producerProperties.getProperty("ssl.keystore.password"), "keystore-password");
126+
@Test(expected = IllegalArgumentException.class)
127+
public void shouldThrowWhenTrustStorePasswordIsNotExists() {
128+
when(configuration.getString(eq(Constants.SINK_KAFKA_SSL_TRUSTSTORE_PASSWORD_LOCATION_KEY), anyString())).thenReturn("/non-exists.txt");
129+
when(configuration.getString(eq(Constants.SINK_KAFKA_BROKERS_KEY), anyString())).thenReturn("10.200.216.87:6668");
130+
when(configuration.getBoolean(eq(Constants.SINK_KAFKA_PRODUCE_LARGE_MESSAGE_ENABLE_KEY), anyBoolean())).thenReturn(true);
131+
when(configuration.getString(eq(Constants.SINK_KAFKA_LINGER_MS_KEY), anyString())).thenReturn("1000");
132+
133+
sinkOrchestrator.getProducerProperties(configuration);
130134
}
131135

132136
@Test

0 commit comments

Comments
 (0)