diff options
author | Andy Clement <aclement@pivotal.io> | 2018-02-14 12:38:59 -0800 |
---|---|---|
committer | Andy Clement <aclement@pivotal.io> | 2018-02-14 12:38:59 -0800 |
commit | 83bca73bb98e6e90a9ef2778f1654df2e21e70eb (patch) | |
tree | 5cbd1eff2ee1f0555a1ec5390f487b884022eb9a /testing | |
parent | ed77301971aa745f2a37b4f7b9bf2f9cb4d20919 (diff) | |
download | aspectj-83bca73bb98e6e90a9ef2778f1654df2e21e70eb.tar.gz aspectj-83bca73bb98e6e90a9ef2778f1654df2e21e70eb.zip |
Add basic rename functionality to file step
Diffstat (limited to 'testing')
-rw-r--r-- | testing/newsrc/org/aspectj/testing/FileSpec.java | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/testing/newsrc/org/aspectj/testing/FileSpec.java b/testing/newsrc/org/aspectj/testing/FileSpec.java index f9876928b..2164f38f1 100644 --- a/testing/newsrc/org/aspectj/testing/FileSpec.java +++ b/testing/newsrc/org/aspectj/testing/FileSpec.java @@ -23,6 +23,9 @@ import org.aspectj.tools.ajc.AjcTestCase; public class FileSpec implements ITestStep { private String toDelete; + + private String renameFrom; + private String renameTo; // private String dir; // private AjcTest test; @@ -30,13 +33,23 @@ public class FileSpec implements ITestStep { 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) { @@ -47,6 +60,14 @@ public class FileSpec implements ITestStep { 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) { @@ -59,10 +80,12 @@ public class FileSpec implements ITestStep { toDelete.delete(); } + @Override public void setBaseDir(String dir) { // this.dir = dir; } + @Override public void setTest(AjcTest test) { // this.test = test; } |