diff options
author | PatrikBuhr <patrik.buhr@est.tech> | 2019-03-22 14:29:29 +0000 |
---|---|---|
committer | PatrikBuhr <patrik.buhr@est.tech> | 2019-03-22 14:29:29 +0000 |
commit | e1a66425d3ba1df5ae2a8f2b99168707e08b655a (patch) | |
tree | bdfcbdbe4a3dd7286a562f974dec61691e216848 /datafile-dmaap-client/src/test | |
parent | 4bd281390ed24b278846775c1157f82db81fddbe (diff) |
Local filename updated, stability issues
The local filename is changed so it contains PNF name
instead of the PNF IP address.
The paralellism is restricted to 100 worker threads in order to
solve problems with too many open file descriptors and out of memory.
Logging is improved.
Change-Id: I24ce2e23020cc253a3c7bebac1ab5cf703b5b144
Issue-ID: DCAEGEN2-1118
Signed-off-by: PatrikBuhr <patrik.buhr@est.tech>
Diffstat (limited to 'datafile-dmaap-client/src/test')
-rw-r--r-- | datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpsClientTest.java | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpsClientTest.java b/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpsClientTest.java index e2882606..9e6c29f8 100644 --- a/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpsClientTest.java +++ b/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpsClientTest.java @@ -73,7 +73,8 @@ public class FtpsClientTest { @BeforeEach protected void setUp() throws Exception { - clientUnderTestSpy = spy(new FtpsClient(createFileServerData())); + clientUnderTestSpy = spy(new FtpsClient(createFileServerData(), FTP_KEY_PATH, FTP_KEY_PASSWORD, TRUSTED_CA_PATH, + TRUSTED_CA_PASSWORD)); clientUnderTestSpy.realFtpsClient = ftpsClientMock; } @@ -104,7 +105,7 @@ public class FtpsClientTest { doReturn(true).when(ftpsClientMock).login(USERNAME, PASSWORD); doReturn(HttpStatus.OK.value()).when(ftpsClientMock).getReplyCode(); - clientUnderTestSpy.open(FTP_KEY_PATH, FTP_KEY_PASSWORD, TRUSTED_CA_PATH, TRUSTED_CA_PASSWORD); + clientUnderTestSpy.open(); doReturn(true).when(ftpsClientMock).retrieveFile(REMOTE_FILE_PATH, outputStreamMock); clientUnderTestSpy.collectFile(REMOTE_FILE_PATH, LOCAL_FILE_PATH); @@ -124,9 +125,8 @@ public class FtpsClientTest { public void collectFileFaultyOwnKey_shouldFail() throws Exception { doReturn(outputStreamMock).when(clientUnderTestSpy).createOutputStream(LOCAL_FILE_PATH); - assertThatThrownBy(() -> clientUnderTestSpy.open(FTP_KEY_PATH, FTP_KEY_PASSWORD, TRUSTED_CA_PATH, - TRUSTED_CA_PASSWORD)).hasMessageContaining( - "Could not open connection: java.io.FileNotFoundException:"); + assertThatThrownBy(() -> clientUnderTestSpy.open()) + .hasMessageContaining("Could not open connection: java.io.FileNotFoundException:"); verify(ftpsClientMock).setNeedClientAuth(true); @@ -142,9 +142,8 @@ public class FtpsClientTest { doReturn(keyManagerMock).when(clientUnderTestSpy).createKeyManager(FTP_KEY_PATH, FTP_KEY_PASSWORD); doThrow(new IOException("problem")).when(clientUnderTestSpy).createInputStream(TRUSTED_CA_PATH); - assertThatThrownBy( - () -> clientUnderTestSpy.open(FTP_KEY_PATH, FTP_KEY_PASSWORD, TRUSTED_CA_PATH, TRUSTED_CA_PASSWORD)) - .hasMessage("Could not open connection: java.io.IOException: problem"); + assertThatThrownBy(() -> clientUnderTestSpy.open()) + .hasMessage("Could not open connection: java.io.IOException: problem"); } @Test @@ -153,9 +152,8 @@ public class FtpsClientTest { doReturn(keyManagerMock).when(clientUnderTestSpy).createKeyManager(FTP_KEY_PATH, FTP_KEY_PASSWORD); doReturn(inputStreamMock).when(clientUnderTestSpy).createInputStream(TRUSTED_CA_PATH); - assertThatThrownBy( - () -> clientUnderTestSpy.open(FTP_KEY_PATH, FTP_KEY_PASSWORD, TRUSTED_CA_PATH, TRUSTED_CA_PASSWORD)) - .hasMessage("Could not open connection: java.io.EOFException"); + assertThatThrownBy(() -> clientUnderTestSpy.open()) + .hasMessage("Could not open connection: java.io.EOFException"); } @Test @@ -166,9 +164,7 @@ public class FtpsClientTest { doReturn(outputStreamMock).when(clientUnderTestSpy).createOutputStream(LOCAL_FILE_PATH); doReturn(false).when(ftpsClientMock).login(USERNAME, PASSWORD); - assertThatThrownBy( - () -> clientUnderTestSpy.open(FTP_KEY_PATH, FTP_KEY_PASSWORD, TRUSTED_CA_PATH, TRUSTED_CA_PASSWORD)) - .hasMessage("Unable to log in to xNF. 127.0.0.1"); + assertThatThrownBy(() -> clientUnderTestSpy.open()).hasMessage("Unable to log in to xNF. 127.0.0.1"); verify(ftpsClientMock).setNeedClientAuth(true); verify(ftpsClientMock).setKeyManager(keyManagerMock); @@ -185,9 +181,8 @@ public class FtpsClientTest { doReturn(true).when(ftpsClientMock).login(USERNAME, PASSWORD); doReturn(503).when(ftpsClientMock).getReplyCode(); - assertThatThrownBy( - () -> clientUnderTestSpy.open(FTP_KEY_PATH, FTP_KEY_PASSWORD, TRUSTED_CA_PATH, TRUSTED_CA_PASSWORD)) - .hasMessage("Unable to connect to xNF. 127.0.0.1 xNF reply code: 503"); + assertThatThrownBy(() -> clientUnderTestSpy.open()) + .hasMessage("Unable to connect to xNF. 127.0.0.1 xNF reply code: 503"); verify(ftpsClientMock).setNeedClientAuth(true); verify(ftpsClientMock).setKeyManager(keyManagerMock); @@ -205,7 +200,7 @@ public class FtpsClientTest { doReturn(outputStreamMock).when(clientUnderTestSpy).createOutputStream(LOCAL_FILE_PATH); doReturn(true).when(ftpsClientMock).login(USERNAME, PASSWORD); doReturn(HttpStatus.OK.value()).when(ftpsClientMock).getReplyCode(); - clientUnderTestSpy.open(FTP_KEY_PATH, FTP_KEY_PASSWORD, TRUSTED_CA_PATH, TRUSTED_CA_PASSWORD); + clientUnderTestSpy.open(); doReturn(false).when(ftpsClientMock).retrieveFile(REMOTE_FILE_PATH, outputStreamMock); @@ -224,7 +219,7 @@ public class FtpsClientTest { doReturn(outputStreamMock).when(clientUnderTestSpy).createOutputStream(LOCAL_FILE_PATH); doReturn(true).when(ftpsClientMock).login(USERNAME, PASSWORD); doReturn(HttpStatus.OK.value()).when(ftpsClientMock).getReplyCode(); - clientUnderTestSpy.open(FTP_KEY_PATH, FTP_KEY_PASSWORD, TRUSTED_CA_PATH, TRUSTED_CA_PASSWORD); + clientUnderTestSpy.open(); when(ftpsClientMock.isConnected()).thenReturn(false); doThrow(new IOException("problem")).when(ftpsClientMock).retrieveFile(REMOTE_FILE_PATH, outputStreamMock); |