FileEntry extends VirtualFileEntry { public void rename(String newName, String newMediaType) throws ConflictException, ForbiddenException, ServerException { final VirtualFile rVf = getVirtualFile().rename(newName, newMediaType, null); setVirtualFile(rVf); } FileEntry(String workspace, VirtualFile virtualFile); @Override FileEntry copyTo(String newParent); @Override FileEntry copyTo(String newParent, String newName, boolean override); @Override void moveTo(String newParent); @Override void moveTo(String newParent, String name, boolean overWrite); String getMediaType(); void setMediaType(String mediaType); InputStream getInputStream(); byte[] contentAsBytes(); void updateContent(byte[] content, String mediaType); void updateContent(byte[] content); void updateContent(InputStream content); void updateContent(InputStream content, String mediaType); void rename(String newName, String newMediaType);  }
@Test public void testRename() throws Exception { String name = myFile.getName(); String newName = name + "_renamed"; String newPath = myVfProject.getVirtualFilePath().newPath(newName).toString(); byte[] b = myFile.contentAsBytes(); String mt = myFile.getMediaType(); myFile.rename(newName); Assert.assertNull(myVfProject.getChild(name)); Assert.assertNotNull(myVfProject.getChild(newName)); Assert.assertEquals(myFile.getName(), newName); Assert.assertEquals(myFile.getPath(), newPath); Assert.assertEquals(myFile.getMediaType(), mt); Assert.assertEquals(myFile.contentAsBytes(), b); }