public class FileSpec implements ITestStep {
private String toDelete;
+
+ private String renameFrom;
+ private String renameTo;
// private String dir;
// private AjcTest test;
public FileSpec() {
}
+ public void setRenameFrom(String file) {
+ this.renameFrom = file;
+ }
+
+ public void setRenameTo(String file) {
+ this.renameTo = file;
+ }
+
public void setDeletefile(String file) {
this.toDelete = file;
}
+ @Override
public void addExpectedMessage(ExpectedMessageSpec message) {
}
+ @Override
public void execute(AjcTestCase inTestCase) {
File sandbox = inTestCase.getSandboxDirectory();
if (toDelete != null) {
recursiveDelete(targetForDeletion);
}
}
+ if (renameFrom != null) {
+ if (renameTo == null) {
+ throw new IllegalStateException("If setting renameFrom the renameTo should also be set");
+ }
+ File fileFrom = new File(sandbox, renameFrom);
+ File fileTo = new File(sandbox, renameTo);
+ fileFrom.renameTo(fileTo);
+ }
}
private void recursiveDelete(File toDelete) {
toDelete.delete();
}
+ @Override
public void setBaseDir(String dir) {
// this.dir = dir;
}
+ @Override
public void setTest(AjcTest test) {
// this.test = test;
}