Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void uploadsResponseFileToFTP(String url, int port, String username, String password) {
- TPClient con = null;
- try
- {
- con = new FTPClient();
- con.connect(url, port);
- if (con.login(username, password))
- {
- FileInputStream in = new FileInputStream(new File("responseFile.txt"));
- boolean result = con.storeFile("responseFile.txt", in);
- if(result) System.out.println("A fájl feltöltése sikeres.");
- in.close();
- con.logout();
- con.disconnect();
- }
- }
- catch (Exception e)
- {
- System.out.println("A fájl feltöltése sikeretelen. Hibakód: " + e);
- errorsInRow.add("A fájl feltöltése sikeretelen. Hibakód: " + e);
- } finally {
- if(con != null) {
- try {
- con.disconnect();
- } catch (IOException e) {
- System.out.println(e);
- }
- }
- }
- @Test
- void UploadsResponseFileToFTPTest_WrongFilePath() {
- dataLoaderService = new DataLoaderService(inputData);
- String url = "localhost";
- int port = 21;
- String username = "user";
- String password = "1234";
- exceptedErrorsInRow.add("");
- dataLoaderService.uploadsResponseFileToFTP(url, port, username, password);
- errorsInRow = dataLoaderService.getErrorsInRow();
- assertEquals("A fájl nem létezik. ", exceptedErrorsInRow, errorsInRow);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement