/** * Test success of Rename EZ on a directory which is already an EZ. */ private void doRenameEncryptionZone(FSTestWrapper wrapper) throws Exception { final Path testRoot = new Path("/tmp/TestEncryptionZones"); final Path pathFoo = new Path(testRoot, "foo"); final Path pathFooBaz = new Path(pathFoo, "baz"); final Path pathFooBazFile = new Path(pathFooBaz, "file"); final Path pathFooBar = new Path(pathFoo, "bar"); final Path pathFooBarFile = new Path(pathFooBar, "file"); final int len = 8192; wrapper.mkdir(pathFoo, FsPermission.getDirDefault(), true); dfsAdmin.createEncryptionZone(pathFoo, TEST_KEY); wrapper.mkdir(pathFooBaz, FsPermission.getDirDefault(), true); DFSTestUtil.createFile(fs, pathFooBazFile, len, (short) 1, 0xFEED); String contents = DFSTestUtil.readFile(fs, pathFooBazFile); try { wrapper.rename(pathFooBaz, testRoot); } catch (IOException e) { assertExceptionContains(pathFooBaz.toString() + " can't be moved from" + " an encryption zone.", e ); } // Verify that we can rename dir and files within an encryption zone. assertTrue(fs.rename(pathFooBaz, pathFooBar)); assertTrue("Rename of dir and file within ez failed", !wrapper.exists(pathFooBaz) && wrapper.exists(pathFooBar)); assertEquals("Renamed file contents not the same", contents, DFSTestUtil.readFile(fs, pathFooBarFile)); }