Advertisement
Guest User

Untitled

a guest
Oct 26th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.41 KB | None | 0 0
  1. public void uploadsResponseFileToFTP(String url, int port, String username, String password) {
  2.            
  3.     TPClient con = null;
  4.     try
  5.     {
  6.         con = new FTPClient();
  7.         con.connect(url, port);
  8.         if (con.login(username, password))
  9.         {              
  10.             FileInputStream in = new FileInputStream(new File("responseFile.txt"));
  11.             boolean result = con.storeFile("responseFile.txt", in);
  12.             if(result) System.out.println("A fájl feltöltése sikeres.");
  13.             in.close();
  14.                
  15.             con.logout();
  16.             con.disconnect();
  17.         }
  18.     }
  19.     catch (Exception e)
  20.     {
  21.         System.out.println("A fájl feltöltése sikeretelen. Hibakód: " + e);
  22.         errorsInRow.add("A fájl feltöltése sikeretelen. Hibakód: " + e);
  23.     } finally {
  24.         if(con != null) {
  25.             try {              
  26.                 con.disconnect();
  27.             } catch (IOException e) {                  
  28.                 System.out.println(e);
  29.             }          
  30.         }
  31. }
  32.  
  33. @Test
  34. void UploadsResponseFileToFTPTest_WrongFilePath() {
  35.        
  36.     dataLoaderService = new DataLoaderService(inputData);      
  37.     String url = "localhost";
  38.     int port =  21;
  39.     String username = "user";
  40.     String password = "1234";
  41.     exceptedErrorsInRow.add("");
  42.                
  43.     dataLoaderService.uploadsResponseFileToFTP(url, port, username, password);     
  44.     errorsInRow = dataLoaderService.getErrorsInRow();
  45.        
  46.     assertEquals("A fájl nem létezik. ", exceptedErrorsInRow, errorsInRow);
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement