* <li> try third time --> should select only the file with modified
* content </li>
*/
public void testScenario1() {
BFT bft = null;
ModifiedSelector s = null;
try {
//
// ***** initialize test environment (called "bed") *****
//
makeBed();
String results = null;
// Configure the selector - only defaults are used
s = (ModifiedSelector)getSelector();
//
// ***** First Run *****
// the first call should get all files, because nothing is in
// the cache
//
performTests(s, "TTTTTTTTTTTT");
//
// ***** Second Run *****
// the second call should get no files, because no content
// has changed
//
performTests(s, "TFFFFFFFFFFT");
//
// ***** make some files dirty *****
//
// these files are made dirty --> 3+4 with different content
String f2name = "tar/bz2/asf-logo-huge.tar.bz2";
String f3name = "asf-logo.gif.md5";
String f4name = "copy.filterset.filtered";
// AccessObject to the test-Ant-environment
bft = new BFT();
// give some values (via property file) to that environment
bft.writeProperties("f2name="+f2name);
bft.writeProperties("f3name="+f3name);
bft.writeProperties("f4name="+f4name);
// call the target for making the files dirty
bft.doTarget("modifiedselectortest-makeDirty");
//
// ***** Third Run *****
// third call should get only those files, which CONTENT changed
// (no timestamp changes required!)
results = selectionString(s);
//
// ***** Check the result *****
//
// Mark all files which should be selected as (T)rue and all others
// as (F)alse. Directories are always selected so they always are
// (T)rue.
StringBuffer expected = new StringBuffer();
for (int i=0; i<filenames.length; i++) {
String ch = "F";
if (files[i].isDirectory()) ch = "T";
// f2name shouldn't be selected: only timestamp has changed!
if (filenames[i].equalsIgnoreCase(f3name)) ch = "T";
if (filenames[i].equalsIgnoreCase(f4name)) ch = "T";
expected.append(ch);
}
assertEquals(
"Wrong files selected. Differing files: " // info text
+ resolve(diff(expected.toString(), results)), // list of files
expected.toString(), // expected result
results // result
);
} finally {
// cleanup the environment
cleanupBed();
if (s!=null) s.getCache().delete();
if (bft!=null) bft.deletePropertiesfile();
}
}