Produced by Araxis Merge on 11/14/2017 6:57:21 AM Central Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | cbs.zip\cbs\cbs\src\test\java\gov\va\cpss\service | FtpServiceIT.java | Thu Nov 9 14:19:48 2017 UTC |
| 2 | cbs.zip\cbs\cbs\src\test\java\gov\va\cpss\service | FtpServiceIT.java | Tue Nov 14 12:28:53 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 838 |
| Changed | 1 | 2 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | package go v.va.cpss. service; | |
| 2 | ||
| 3 | import sta tic org.ju nit.Assert .assertEqu als; | |
| 4 | import sta tic org.ju nit.Assert .assertFal se; | |
| 5 | import sta tic org.ju nit.Assert .assertNot Null; | |
| 6 | import sta tic org.ju nit.Assert .assertTru e; | |
| 7 | import sta tic org.ju nit.Assert .fail; | |
| 8 | import sta tic org.ju nit.Assume .assumeTru e; | |
| 9 | ||
| 10 | import jav a.io.Buffe redReader; | |
| 11 | import jav a.io.File; | |
| 12 | import jav a.io.Input StreamRead er; | |
| 13 | import jav a.util.Arr ayList; | |
| 14 | import jav a.util.Lis t; | |
| 15 | ||
| 16 | import org .apache.lo g4j.Logger ; | |
| 17 | import org .junit.Bef ore; | |
| 18 | import org .junit.Tes t; | |
| 19 | import org .junit.run ner.RunWit h; | |
| 20 | import org .springfra mework.bea ns.factory .annotatio n.Autowire d; | |
| 21 | import org .springfra mework.bea ns.factory .annotatio n.Value; | |
| 22 | import org .springfra mework.tes t.context. ContextCon figuration ; | |
| 23 | import org .springfra mework.tes t.context. junit4.Spr ingJUnit4C lassRunner ; | |
| 24 | ||
| 25 | /** | |
| 26 | * Integra tion Unit Tests to t est succes s and fail ure cases of SFTP Se rvice. | |
| 27 | * Various test file s are refe renced in src/test/r esources/f ps directo ry. | |
| 28 | * | |
| 29 | * @author DN S BROWNL | |
| 30 | */ | |
| 31 | @RunWith(S pringJUnit 4ClassRunn er.class) | |
| 32 | @ContextCo nfiguratio n(location s = { "/te st-context .xml", "/c pss-sftp-s ervice.xml " }) | |
| 33 | public cla ss FtpServ iceIT { | |
| 34 | ||
| 35 | @S uppressWar nings("unu sed") | |
| 36 | pr ivate Logg er logger = Logger.g etLogger(t his.getCla ss().getCa nonicalNam e()); | |
| 37 | ||
| 38 | @V alue("${ru n.integrat ion.test:f alse}") | |
| 39 | pr ivate Bool ean runInt egrationTe st; | |
| 40 | ||
| 41 | pr ivate fina l String D ATA_DIRECT ORY = "psd ata"; | |
| 42 | ||
| 43 | @A utowired | |
| 44 | pr ivate Sftp Service sf tpService; | |
| 45 | ||
| 46 | /* * | |
| 47 | * Only run these test s if prope rty is set to run in tegration test. | |
| 48 | * / | |
| 49 | @B efore | |
| 50 | pu blic final void befo reTest() { | |
| 51 | assu meTrue(run Integratio nTest); | |
| 52 | } | |
| 53 | ||
| 54 | @T est | |
| 55 | pu blic final void test Remove() { | |
| 56 | ||
| 57 | fina l String f ilename = "CCPC-to-C PSS_empty. txt"; | |
| 58 | fina l String l ocalFilepa th = new F ile(this.g etClass(). getClassLo ader().get Resource(" fps/" + fi lename).ge tFile()) | |
| 59 | .getAbso lutePath() ; | |
| 60 | fina l String t argetDirec tory = get ArchiveDir ectory(); | |
| 61 | ||
| 62 | // E nsure test server is in expect ed initial state. | |
| 63 | asse rtFalse(sf tpService. ftpFileExi stsInDirec tory(filen ame, DATA_ DIRECTORY) ); | |
| 64 | asse rtFalse(sf tpService. ftpFileExi stsInDirec tory(filen ame, targe tDirectory )); | |
| 65 | ||
| 66 | // F TP test fi les to ser ver. | |
| 67 | asse rtTrue(sft pService.f tpFileToSe rver(local Filepath, DATA_DIREC TORY)); | |
| 68 | asse rtTrue(sft pService.f tpMoveFile FromDirect oryToDirec tory(filen ame, DATA_ DIRECTORY, targetDir ectory)); | |
| 69 | asse rtTrue(sft pService.f tpFileToSe rver(local Filepath, DATA_DIREC TORY)); | |
| 70 | ||
| 71 | // E nsure test server ha s the file s. | |
| 72 | asse rtTrue(sft pService.f tpFileExis tsInDirect ory(filena me, DATA_D IRECTORY)) ; | |
| 73 | asse rtTrue(sft pService.f tpFileExis tsInDirect ory(filena me, target Directory) ); | |
| 74 | ||
| 75 | // R emove file from the specified directorie s. | |
| 76 | asse rtTrue(sft pService.f tpRemoveFi leFromDire ctory(file name, DATA _DIRECTORY )); | |
| 77 | asse rtTrue(sft pService.f tpRemoveFi leFromDire ctory(file name, targ etDirector y)); | |
| 78 | ||
| 79 | // V erify file is no lon ger in the target di rectories. | |
| 80 | asse rtFalse(sf tpService. ftpFileExi stsInDirec tory(filen ame, DATA_ DIRECTORY) ); | |
| 81 | asse rtFalse(sf tpService. ftpFileExi stsInDirec tory(filen ame, targe tDirectory )); | |
| 82 | } | |
| 83 | ||
| 84 | @T est | |
| 85 | pu blic final void test Move() { | |
| 86 | ||
| 87 | fina l String f ilename = "CCPC-to-C PSS_empty. txt"; | |
| 88 | fina l String l ocalFilepa th = new F ile(this.g etClass(). getClassLo ader().get Resource(" fps/" + fi lename).ge tFile()) | |
| 89 | .getAbso lutePath() ; | |
| 90 | fina l String t argetDirec tory = get ErrorDirec tory(); | |
| 91 | ||
| 92 | // E nsure test server is in expect ed initial state. | |
| 93 | asse rtFalse(sf tpService. ftpFileExi stsInDirec tory(filen ame, targe tDirectory )); | |
| 94 | ||
| 95 | // F TP test fi le to serv er. | |
| 96 | asse rtTrue(sft pService.f tpFileToSe rver(local Filepath)) ; | |
| 97 | ||
| 98 | // M ove file t o the spec ified dire ctory. | |
| 99 | asse rtTrue(sft pService.f tpMoveFile ToDirector y(filename , targetDi rectory)); | |
| 100 | ||
| 101 | // V erify file is no lon ger in the original directory. | |
| 102 | asse rtFalse(sf tpService. ftpFileExi stsInDirec tory(filen ame, DATA_ DIRECTORY) ); | |
| 103 | ||
| 104 | // V erify file is in the target di rectory. | |
| 105 | asse rtTrue(sft pService.f tpFileExis tsInDirect ory(filena me, target Directory) ); | |
| 106 | ||
| 107 | // C leanup. | |
| 108 | asse rtTrue(sft pService.f tpRemoveFi leFromDire ctory(file name, targ etDirector y)); | |
| 109 | } | |
| 110 | ||
| 111 | @T est | |
| 112 | pu blic final void test RenameFile InDirector y() { | |
| 113 | ||
| 114 | fina l String f ilename = "CCPC-to-C PSS_empty. txt"; | |
| 115 | fina l String l ocalFilepa th = new F ile(this.g etClass(). getClassLo ader().get Resource(" fps/" + fi lename).ge tFile()) | |
| 116 | .getAbso lutePath() ; | |
| 117 | fina l String t argetFilen ame = file name + ".1 21110.send cbs"; | |
| 118 | fina l String t argetDirec tory = get ErrorDirec tory(); | |
| 119 | ||
| 120 | try { | |
| 121 | ||
| 122 | // Ens ure test s erver is i n expected initial s tate. | |
| 123 | assert False(sftp Service.ft pFileExist sInDirecto ry(filenam e, targetD irectory)) ; | |
| 124 | ||
| 125 | // Ens ure test s erver is i n expected initial s tate. | |
| 126 | assert False(sftp Service.ft pFileExist sInDirecto ry(filenam e, targetD irectory)) ; | |
| 127 | ||
| 128 | // FTP test file to server . | |
| 129 | assert True(sftpS ervice.ftp FileToServ erWithName (localFile path, targ etFilename , targetDi rectory)); | |
| 130 | ||
| 131 | // Ver ify file i s in the t arget dire ctory. | |
| 132 | assert True(sftpS ervice.ftp FileExists InDirector y(targetFi lename, ta rgetDirect ory)); | |
| 133 | ||
| 134 | Thread .sleep(400 0); | |
| 135 | ||
| 136 | // Mov e file to the specif ied direct ory. | |
| 137 | assert True(sftpS ervice.ftp RenameFile InDirector y(targetFi lename, fi lename, ta rgetDirect ory)); | |
| 138 | ||
| 139 | // Ver ify file i s no longe r in the o riginal di rectory. | |
| 140 | assert False(sftp Service.ft pFileExist sInDirecto ry(targetF ilename, t argetDirec tory)); | |
| 141 | ||
| 142 | // Ver ify file i s in the t arget dire ctory. | |
| 143 | assert True(sftpS ervice.ftp FileExists InDirector y(filename , targetDi rectory)); | |
| 144 | ||
| 145 | Thread .sleep(400 0); | |
| 146 | ||
| 147 | // Cle anup. | |
| 148 | assert True(sftpS ervice.ftp RemoveFile FromDirect ory(filena me, target Directory) ); | |
| 149 | ||
| 150 | } ca tch (Excep tion e) { | |
| 151 | fail(e .getMessag e()); | |
| 152 | } | |
| 153 | } | |
| 154 | ||
| 155 | @T est | |
| 156 | pu blic final void test Put() { | |
| 157 | ||
| 158 | fina l String f ilename = "CPSS-to-C CPC_PS_inv alid_seque nce_number .txt"; | |
| 159 | fina l String l ocalFilepa th = new F ile(this.g etClass(). getClassLo ader().get Resource(" fps/" + fi lename).ge tFile()) | |
| 160 | .getAbso lutePath() ; | |
| 161 | ||
| 162 | // E nsure test server is in expect ed initial state. | |
| 163 | asse rtFalse(sf tpService. ftpFileExi stsInDirec tory(filen ame, DATA_ DIRECTORY) ); | |
| 164 | ||
| 165 | // F TP test fi le to serv er. | |
| 166 | asse rtTrue(sft pService.f tpFileToSe rver(local Filepath, DATA_DIREC TORY)); | |
| 167 | ||
| 168 | // V erify file is in the target di rectory. | |
| 169 | asse rtTrue(sft pService.f tpFileExis tsInDirect ory(filena me, DATA_D IRECTORY)) ; | |
| 170 | ||
| 171 | // C leanup. | |
| 172 | asse rtTrue(sft pService.f tpRemoveFi leFromDire ctory(file name, DATA _DIRECTORY )); | |
| 173 | } | |
| 174 | ||
| 175 | @T est | |
| 176 | pu blic final void test PutRename( ) { | |
| 177 | ||
| 178 | fina l String f ilename = "CPSS-to-C CPC_PS_inv alid_seque nce_number .txt"; | |
| 179 | fina l String l ocalFilepa th = new F ile(this.g etClass(). getClassLo ader().get Resource(" fps/" + fi lename).ge tFile()) | |
| 180 | .getAbso lutePath() ; | |
| 181 | fina l String t argetFilen ame = file name + ".1 21110.send cbs"; | |
| 182 | ||
| 183 | // E nsure test server is in expect ed initial state. | |
| 184 | asse rtFalse(sf tpService. ftpFileExi stsInDirec tory(filen ame, DATA_ DIRECTORY) ); | |
| 185 | ||
| 186 | // F TP test fi le to serv er. | |
| 187 | asse rtTrue(sft pService.f tpFileToSe rverWithNa me(localFi lepath, ta rgetFilena me, DATA_D IRECTORY)) ; | |
| 188 | ||
| 189 | // V erify file is in the target di rectory. | |
| 190 | asse rtTrue(sft pService.f tpFileExis tsInDirect ory(target Filename, DATA_DIREC TORY)); | |
| 191 | ||
| 192 | // C leanup. | |
| 193 | asse rtTrue(sft pService.f tpRemoveFi leFromDire ctory(targ etFilename , DATA_DIR ECTORY)); | |
| 194 | } | |
| 195 | ||
| 196 | @T est | |
| 197 | pu blic final void test PutEmpty() { | |
| 198 | ||
| 199 | fina l String t argetFilen ame = "tes t.don"; | |
| 200 | ||
| 201 | // E nsure test server is in expect ed initial state. | |
| 202 | asse rtFalse(sf tpService. ftpFileExi stsInDirec tory(targe tFilename, DATA_DIRE CTORY)); | |
| 203 | ||
| 204 | // F TP test fi le to serv er. | |
| 205 | asse rtTrue(sft pService.f tpEmptyFil eToServerW ithName(ta rgetFilena me, DATA_D IRECTORY)) ; | |
| 206 | ||
| 207 | // V erify file is in the target di rectory. | |
| 208 | asse rtTrue(sft pService.f tpFileExis tsInDirect ory(target Filename, DATA_DIREC TORY)); | |
| 209 | ||
| 210 | // C leanup. | |
| 211 | asse rtTrue(sft pService.f tpRemoveFi leFromDire ctory(targ etFilename , DATA_DIR ECTORY)); | |
| 212 | } | |
| 213 | ||
| 214 | @T est | |
| 215 | pu blic final void test PutString( ) { | |
| 216 | ||
| 217 | fina l String t argetFilen ame = "tes t.txt"; | |
| 218 | ||
| 219 | fina l String c ontent = " This is ro w 1\nThis is row 2!" ; | |
| 220 | ||
| 221 | // E nsure test server is in expect ed initial state. | |
| 222 | asse rtFalse(sf tpService. ftpFileExi stsInDirec tory(targe tFilename, DATA_DIRE CTORY)); | |
| 223 | ||
| 224 | // F TP test fi le to serv er. | |
| 225 | asse rtTrue(sft pService.f tpStringAs FileToServ erWithName (content, targetFile name, DATA _DIRECTORY )); | |
| 226 | ||
| 227 | // V erify file is in the target di rectory. | |
| 228 | asse rtTrue(sft pService.f tpFileExis tsInDirect ory(target Filename, DATA_DIREC TORY)); | |
| 229 | ||
| 230 | // C leanup. | |
| 231 | asse rtTrue(sft pService.f tpRemoveFi leFromDire ctory(targ etFilename , DATA_DIR ECTORY)); | |
| 232 | } | |
| 233 | ||
| 234 | @T est | |
| 235 | pu blic final void test Ls() { | |
| 236 | ||
| 237 | fina l String f ilename = "CPSS-to-C CPC_PS_inv alid_seque nce_number .txt"; | |
| 238 | fina l String l ocalFilepa th = new F ile(this.g etClass(). getClassLo ader().get Resource(" fps/" + fi lename).ge tFile()) | |
| 239 | .getAbso lutePath() ; | |
| 240 | ||
| 241 | // E nsure test server is in expect ed initial state. | |
| 242 | asse rtFalse(sf tpService. ftpFileExi stsInDirec tory(filen ame, DATA_ DIRECTORY) ); | |
| 243 | ||
| 244 | // F TP test fi le to serv er. | |
| 245 | asse rtTrue(sft pService.f tpFileToSe rver(local Filepath, DATA_DIREC TORY)); | |
| 246 | ||
| 247 | // V erify file is in the target di rectory. | |
| 248 | asse rtTrue(sft pService.f tpFileExis tsInDirect ory(filena me, DATA_D IRECTORY)) ; | |
| 249 | ||
| 250 | // C leanup. | |
| 251 | asse rtTrue(sft pService.f tpRemoveFi leFromDire ctory(file name, DATA _DIRECTORY )); | |
| 252 | } | |
| 253 | ||
| 254 | @T est | |
| 255 | pu blic final void test FileInfoLs () { | |
| 256 | ||
| 257 | fina l String f ilename1 = "CPSS-to- CCPC_PS_in valid_sequ ence_numbe r.txt"; | |
| 258 | fina l String l ocalFilepa th1 = new File( | |
| 259 | this.get Class().ge tClassLoad er().getRe source("fp s/" + file name1).get File()).ge tAbsoluteP ath(); | |
| 260 | fina l String f ilename2 = "CPSS-to- CCPC_PS_in valid_end_ of_file.tx t"; | |
| 261 | fina l String l ocalFilepa th2 = new File( | |
| 262 | this.get Class().ge tClassLoad er().getRe source("fp s/" + file name2).get File()).ge tAbsoluteP ath(); | |
| 263 | fina l String f ilename3 = "CPSS-to- CCPC_PH_in valid_end_ of_file.tx t"; | |
| 264 | fina l String l ocalFilepa th3 = new File( | |
| 265 | this.get Class().ge tClassLoad er().getRe source("fp s/" + file name3).get File()).ge tAbsoluteP ath(); | |
| 266 | ||
| 267 | // E nsure test server is in expect ed initial state. | |
| 268 | asse rtFalse(sf tpService. ftpFileExi stsInDirec tory(filen ame1, DATA _DIRECTORY )); | |
| 269 | asse rtFalse(sf tpService. ftpFileExi stsInDirec tory(filen ame2, DATA _DIRECTORY )); | |
| 270 | asse rtFalse(sf tpService. ftpFileExi stsInDirec tory(filen ame3, DATA _DIRECTORY )); | |
| 271 | ||
| 272 | // F TP test fi le to serv er. | |
| 273 | asse rtTrue(sft pService.f tpFileToSe rver(local Filepath1, DATA_DIRE CTORY)); | |
| 274 | ||
| 275 | try { | |
| 276 | Thread .sleep(300 0); | |
| 277 | } ca tch (Excep tion e) { | |
| 278 | fail(" Failure sl eeping"); | |
| 279 | } | |
| 280 | ||
| 281 | asse rtTrue(sft pService.f tpFileToSe rver(local Filepath3, DATA_DIRE CTORY)); | |
| 282 | ||
| 283 | try { | |
| 284 | Thread .sleep(300 0); | |
| 285 | } ca tch (Excep tion e) { | |
| 286 | fail(" Failure sl eeping"); | |
| 287 | } | |
| 288 | ||
| 289 | asse rtTrue(sft pService.f tpFileToSe rver(local Filepath2, DATA_DIRE CTORY)); | |
| 290 | ||
| 291 | // f tpGetFileI nfoListInD irectory h as been re moved from SftpServi ce to | |
| 292 | // r emove the dependency on Spring Integrati on. - Brad | |
| 293 | // T est to see if the li st comes b ack with t he proper files. | |
| 294 | // L ist<FileIn fo<?>> fil eList = | |
| 295 | // s ftpService .ftpGetFil eInfoListI nDirectory (DATA_DIRE CTORY); | |
| 296 | // a ssertTrue( fileList.s ize() == 3 ); | |
| 297 | // L ist<String > fileName List = new ArrayList <String>() ; | |
| 298 | // f ileNameLis t.add(file name1); | |
| 299 | // f ileNameLis t.add(file name2); | |
| 300 | // f ileNameLis t.add(file name3); | |
| 301 | // f or(FileInf o<?> fileI nfo: fileL ist) { | |
| 302 | // a ssertTrue( fileNameLi st.contain s(fileInfo .getFilena me())); | |
| 303 | // } | |
| 304 | ||
| 305 | // E nsure the dates are sorted. | |
| 306 | List <String> s erverFileL ist = sftp Service.ft pGetFileLi stWithExte nsionInDir ectory(DAT A_DIRECTOR Y, ".txt") ; | |
| 307 | asse rtTrue(ser verFileLis t.size() = = 3); | |
| 308 | ||
| 309 | asse rtTrue(ser verFileLis t.get(0).e quals(file name1)); | |
| 310 | asse rtTrue(ser verFileLis t.get(1).e quals(file name3)); | |
| 311 | asse rtTrue(ser verFileLis t.get(2).e quals(file name2)); | |
| 312 | ||
| 313 | // C leanup. | |
| 314 | asse rtTrue(sft pService.f tpRemoveFi leFromDire ctory(file name1, DAT A_DIRECTOR Y)); | |
| 315 | asse rtTrue(sft pService.f tpRemoveFi leFromDire ctory(file name2, DAT A_DIRECTOR Y)); | |
| 316 | asse rtTrue(sft pService.f tpRemoveFi leFromDire ctory(file name3, DAT A_DIRECTOR Y)); | |
| 317 | } | |
| 318 | ||
| 319 | @T est | |
| 320 | pu blic final void test Get() { | |
| 321 | ||
| 322 | fina l String f ilename = "CPSS-to-C CPC_succes sful.txt"; | |
| 323 | fina l String l ocalFilepa th = new F ile(this.g etClass(). getClassLo ader().get Resource(" fps/" + fi lename).ge tFile()) | |
| 324 | .getAbso lutePath() ; | |
| 325 | ||
| 326 | // E nsure test server is in expect ed initial state. | |
| 327 | asse rtFalse(sf tpService. ftpFileExi stsInDirec tory(filen ame, DATA_ DIRECTORY) ); | |
| 328 | ||
| 329 | // F TP test fi le to serv er. | |
| 330 | asse rtTrue(sft pService.f tpFileToSe rver(local Filepath, DATA_DIREC TORY)); | |
| 331 | ||
| 332 | // V erify file is in the target di rectory. | |
| 333 | asse rtTrue(sft pService.f tpFileExis tsInDirect ory(filena me, DATA_D IRECTORY)) ; | |
| 334 | ||
| 335 | // V erify the file is re ad as expe cted. | |
| 336 | Sftp StreamSess ion sss = null; | |
| 337 | try { | |
| 338 | sss = sftpServic e.openFile Stream(fil ename, DAT A_DIRECTOR Y); | |
| 339 | assert NotNull(ss s); | |
| 340 | List<S tring> fil eContentsL = new Arr ayList<>() ; | |
| 341 | Buffer edReader r eader = ne w Buffered Reader(new InputStre amReader(s ss.getInpu tStream(), "utf-8")) ; | |
| 342 | String line = re ader.readL ine(); | |
| 343 | // Loo p until th read is in terrupted or no more lines ava ilable. | |
| 344 | while (line != n ull) { | |
| 345 | fileCont entsL.add( line); | |
| 346 | line = r eader.read Line(); | |
| 347 | } | |
| 348 | assert NotNull(fi leContents L); | |
| 349 | assert False(file ContentsL. isEmpty()) ; | |
| 350 | assert Equals(28, fileConte ntsL.size( )); | |
| 351 | } ca tch (Excep tion e) { | |
| 352 | fail(" Unexpected exception : " + e.ge tMessage() ); | |
| 353 | } fi nally { | |
| 354 | if (ss s != null) { | |
| 355 | sss.clos e(); | |
| 356 | } | |
| 357 | } | |
| 358 | ||
| 359 | // C leanup. | |
| 360 | asse rtTrue(sft pService.f tpRemoveFi leFromDire ctory(file name, DATA _DIRECTORY )); | |
| 361 | } | |
| 362 | ||
| 363 | @T est | |
| 364 | pu blic final void test GetByExten sion() { | |
| 365 | ||
| 366 | fina l String d ataFilenam e = "CCPC- to-CPSS_em pty.txt"; | |
| 367 | fina l String i ndicatorFi lename = " CCPC-to-CP SS_empty.d on"; | |
| 368 | fina l String l ocalFilepa th = new F ile( | |
| 369 | this.get Class().ge tClassLoad er().getRe source("fp s/" + data Filename). getFile()) .getAbsolu tePath(); | |
| 370 | ||
| 371 | // E nsure test server is in expect ed initial state. | |
| 372 | asse rtFalse(sf tpService. ftpFileExi stsInDirec tory(dataF ilename, D ATA_DIRECT ORY)); | |
| 373 | asse rtFalse(sf tpService. ftpFileExi stsInDirec tory(indic atorFilena me, DATA_D IRECTORY)) ; | |
| 374 | ||
| 375 | // F TP test fi le to serv er. | |
| 376 | asse rtTrue(sft pService.f tpFileToSe rver(local Filepath, DATA_DIREC TORY)); | |
| 377 | asse rtTrue(sft pService.f tpFileToSe rverWithNa me(localFi lepath, in dicatorFil ename, DAT A_DIRECTOR Y)); | |
| 378 | ||
| 379 | // V erify file is in the target di rectory. | |
| 380 | asse rtTrue(sft pService.f tpFileExis tsInDirect ory(dataFi lename, DA TA_DIRECTO RY)); | |
| 381 | asse rtTrue(sft pService.f tpFileExis tsInDirect ory(indica torFilenam e, DATA_DI RECTORY)); | |
| 382 | ||
| 383 | List <String> f ileL = sft pService.f tpGetFileL istWithExt ensionInDi rectory(DA TA_DIRECTO RY, ".don" ); | |
| 384 | ||
| 385 | // V erify only one file. | |
| 386 | asse rtEquals(1 , fileL.si ze()); | |
| 387 | ||
| 388 | // V erify the file is re ad as expe cted. | |
| 389 | try { | |
| 390 | String filename = fileL.ge t(0); | |
| 391 | ||
| 392 | // Bui ld the inp ut file fr om the ind icator fil e. | |
| 393 | filena me = filen ame.substr ing(0, fil ename.last IndexOf(". don")) + " .txt"; | |
| 394 | ||
| 395 | // Onl y attempt to process if the fi lename is not null a nd not | |
| 396 | // emp ty. | |
| 397 | if ((f ilename != null) && !filename. isEmpty()) { | |
| 398 | assertEq uals(filen ame, dataF ilename); | |
| 399 | } else { | |
| 400 | fail("At tempted to process a n invalid filename t hat was nu ll or empt y string") ; | |
| 401 | } | |
| 402 | ||
| 403 | } ca tch (Excep tion e) { | |
| 404 | fail(" Unexpected exception : " + e.ge tMessage() ); | |
| 405 | } | |
| 406 | ||
| 407 | // C leanup. | |
| 408 | asse rtTrue(sft pService.f tpRemoveFi leFromDire ctory(data Filename, DATA_DIREC TORY)); | |
| 409 | asse rtTrue(sft pService.f tpRemoveFi leFromDire ctory(indi catorFilen ame, DATA_ DIRECTORY) ); | |
| 410 | } | |
| 411 | ||
| 412 | pr ivate Stri ng getArch iveDirecto ry() { | |
| 413 | retu rn DATA_DI RECTORY + "/" + "arc hive"; | |
| 414 | } | |
| 415 | ||
| 416 | pr ivate Stri ng getErro rDirectory () { | |
| 417 | retu rn DATA_DI RECTORY + "/" + "err or"; | |
| 418 | } | |
| 419 | ||
| 420 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.