@Test public void rmrTest() throws IOException { StringBuilder toCompare = new StringBuilder(); mFsShell.mkdir(new String[] {"mkdir", "/testFolder1/testFolder2"}); toCompare.append(getCommandOutput(new String[] {"mkdir", "/testFolder1/testFolder2"})); mFsShell.touch(new String[] {"touch", "/testFolder1/testFolder2/testFile2"}); toCompare.append( getCommandOutput(new String[] {"touch", "/testFolder1/testFolder2/testFile2"})); TachyonURI testFolder1 = new TachyonURI("/testFolder1"); TachyonURI testFolder2 = new TachyonURI("/testFolder1/testFolder2"); TachyonURI testFile2 = new TachyonURI("/testFolder1/testFolder2/testFile2"); Assert.assertNotNull(mTfs.getFile(testFolder1)); Assert.assertNotNull(mTfs.getFile(testFolder2)); Assert.assertNotNull(mTfs.getFile(testFile2)); mFsShell.rmr(new String[] {"rmr", "/testFolder1/testFolder2/testFile2"}); toCompare.append(getCommandOutput(new String[] {"rm", "/testFolder1/testFolder2/testFile2"})); Assert.assertEquals(toCompare.toString(), mOutput.toString()); Assert.assertNotNull(mTfs.getFile(testFolder1)); Assert.assertNotNull(mTfs.getFile(testFolder2)); Assert.assertNull(mTfs.getFile(testFile2)); mFsShell.rmr(new String[] {"rmr", "/testFolder1"}); toCompare.append(getCommandOutput(new String[] {"rmr", "/testFolder1"})); Assert.assertEquals(toCompare.toString(), mOutput.toString()); Assert.assertNull(mTfs.getFile(testFolder1)); Assert.assertNull(mTfs.getFile(testFolder2)); Assert.assertNull(mTfs.getFile(testFile2)); }
@Test public void touchTest() throws IOException { String[] argv = new String[] {"touch", "/testFile"}; mFsShell.touch(argv); TachyonFile tFile = mTfs.getFile(new TachyonURI("/testFile")); Assert.assertNotNull(tFile); Assert.assertEquals(getCommandOutput(argv), mOutput.toString()); Assert.assertTrue(tFile.isFile()); }
@Test public void touchTestWithFullURI() throws IOException { String tachyonURI = "tachyon://" + mLocalTachyonCluster.getMasterHostname() + ":" + mLocalTachyonCluster.getMasterPort() + "/destFileURI"; // when String[] argv = new String[] {"touch", tachyonURI}; mFsShell.touch(argv); // then TachyonFile tFile = mTfs.getFile(new TachyonURI("/destFileURI")); Assert.assertThat(tFile, CoreMatchers.notNullValue()); Assert.assertThat(getCommandOutput(argv), CoreMatchers.equalTo(mOutput.toString())); Assert.assertThat(tFile.isFile(), CoreMatchers.equalTo(true)); }