From: Andy Clement Date: Wed, 14 Feb 2018 20:38:59 +0000 (-0800) Subject: Add basic rename functionality to file step X-Git-Tag: V1_9_0_RC4~16 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=83bca73bb98e6e90a9ef2778f1654df2e21e70eb;p=aspectj.git Add basic rename functionality to file step --- 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; }