diff options
author | Benoit Lamarche <benoitlamarche@google.com> | 2015-02-04 16:15:50 +0100 |
---|---|---|
committer | Benoit Lamarche <benoitlamarche@google.com> | 2015-02-04 18:50:43 +0100 |
commit | 03bfa69e6dc826d0d7b16143d4f511e23d6168c3 (patch) | |
tree | d28c9abf3ac5231aa41d2e604b40fd303a479a51 /sched/tests | |
parent | c5557accf55a77edfc1cfb76a1f0b78dc71c857d (diff) | |
download | toolchain_jack-03bfa69e6dc826d0d7b16143d4f511e23d6168c3.zip toolchain_jack-03bfa69e6dc826d0d7b16143d4f511e23d6168c3.tar.gz toolchain_jack-03bfa69e6dc826d0d7b16143d4f511e23d6168c3.tar.bz2 |
Add new VFile delete API
And remove VDir delete API
Change-Id: I628b96ba1d51a3736bf996a611832c1a2c844af3
Diffstat (limited to 'sched/tests')
-rw-r--r-- | sched/tests/com/android/sched/vfs/VFSTest.java | 68 |
1 files changed, 39 insertions, 29 deletions
diff --git a/sched/tests/com/android/sched/vfs/VFSTest.java b/sched/tests/com/android/sched/vfs/VFSTest.java index 71643c8..80d8ec2 100644 --- a/sched/tests/com/android/sched/vfs/VFSTest.java +++ b/sched/tests/com/android/sched/vfs/VFSTest.java @@ -213,8 +213,7 @@ public class VFSTest { | Permission.WRITE))); testOutputVFS(directVFS); - // XXX: does not work, needs to be fixed - //testDelete(directVFS); + testDelete(directVFS); testInputVFS(directVFS); directVFS.close(); @@ -551,7 +550,6 @@ public class VFSTest { } } - private void testDelete(@Nonnull InputOutputVFS ioVFS) throws NoSuchFileException, CannotDeleteFileException, @@ -561,45 +559,57 @@ public class VFSTest { // let's delete "dirA/dirAA/dirAAB/fileAAB1" InputOutputVDir dirA = ioVFS.getRootInputOutputVDir().getInputVDir(new VPath("dirA", '/')); - dirA.delete(new VPath("dirAA/dirAAB/fileAAB1", '/')); - try { - ioVFS.getRootInputVDir().getInputVFile(new VPath("dirA/dirAA/dirAAB/fileAAB1", '/')); - Assert.fail(); - } catch (NoSuchFileException e) { - //expected + { + InputOutputVFile fileAAB1 = + (InputOutputVFile) dirA.getInputVFile(new VPath("dirAA/dirAAB/fileAAB1", '/')); + fileAAB1.delete(); + try { + ioVFS.getRootInputVDir().getInputVFile(new VPath("dirA/dirAA/dirAAB/fileAAB1", '/')); + Assert.fail(); + } catch (NoSuchFileException e) { + // expected + } } // let's delete "dirB/dirBB/fileBB1" InputOutputVDir dirBB = ioVFS.getRootInputOutputVDir().getInputVDir(new VPath("dirB/dirBB", '/')); - dirBB.delete(new VPath("fileBB1", '/')); - try { - ioVFS.getRootInputVDir().getInputVFile(new VPath("dirB/dirBB/fileBB1", '/')); - Assert.fail(); - } catch (NoSuchFileException e) { - //expected + { + InputOutputVFile fileBB1 = (InputOutputVFile) dirBB.getInputVFile(new VPath("fileBB1", '/')); + fileBB1.delete(); + try { + ioVFS.getRootInputVDir().getInputVFile(new VPath("dirB/dirBB/fileBB1", '/')); + Assert.fail(); + } catch (NoSuchFileException e) { + // expected + } } // let's delete "dirC/fileC1" - ioVFS.getRootInputOutputVDir().delete(new VPath("dirC/fileC1", '/')); - try { - ioVFS.getRootInputVDir().getInputVFile(new VPath("dirC/fileC1", '/')); - Assert.fail(); - } catch (NoSuchFileException e) { - //expected + { + InputOutputVFile fileC1 = (InputOutputVFile) ioVFS.getRootInputOutputVDir().getInputVFile( + new VPath("dirC/fileC1", '/')); + fileC1.delete(); + try { + ioVFS.getRootInputVDir().getInputVFile(new VPath("dirC/fileC1", '/')); + Assert.fail(); + } catch (NoSuchFileException e) { + // expected + } } // let's re-create the files we've deleted to leave the VFS in the same state as before. - OutputVFile fileAAB1 = dirA.createOutputVFile(new VPath("dirAA/dirAAB/fileAAB1", '/')); - writeToFile(fileAAB1, "dirA/dirAA/dirAAB/fileAAB1"); - OutputVFile fileBB1 = dirBB.createOutputVFile(new VPath("fileBB1", '/')); - writeToFile(fileBB1, "dirB/dirBB/fileBB1"); - OutputVFile fileC1 = - ioVFS.getRootInputOutputVDir().createOutputVFile(new VPath("dirC/fileC1", '/')); - writeToFile(fileC1, "dirC/fileC1"); + { + OutputVFile fileAAB1 = dirA.createOutputVFile(new VPath("dirAA/dirAAB/fileAAB1", '/')); + writeToFile(fileAAB1, "dirA/dirAA/dirAAB/fileAAB1"); + OutputVFile fileBB1 = dirBB.createOutputVFile(new VPath("fileBB1", '/')); + writeToFile(fileBB1, "dirB/dirBB/fileBB1"); + OutputVFile fileC1 = + ioVFS.getRootInputOutputVDir().createOutputVFile(new VPath("dirC/fileC1", '/')); + writeToFile(fileC1, "dirC/fileC1"); + } } - private boolean containsFile(@Nonnull Collection<? extends InputVElement> elements, @Nonnull String fileSimpleName, @Nonnull String fileContent) throws IOException { for (VElement element : elements) { |