/**
*
*/
public void testVersioningWithCreator() throws Exception
{
FileObject scratchFolder = createScratchFolder();
FileSystemOptions opts = scratchFolder.getFileSystem().getFileSystemOptions();
WebdavFileSystemConfigBuilder builder =
(WebdavFileSystemConfigBuilder)getManager().getFileSystemConfigBuilder("webdav");
builder.setVersioning(opts, true);
builder.setCreatorName(opts, "testUser");
FileObject file = getManager().resolveFile(scratchFolder, "file1.txt", opts);
FileSystemOptions newOpts = file.getFileSystem().getFileSystemOptions();
assertTrue(opts == newOpts);
assertTrue(builder.isVersioning(newOpts));
assertTrue(!file.exists());
file.createFile();
assertTrue(file.exists());
assertSame(FileType.FILE, file.getType());
assertEquals(0, file.getContent().getSize());
assertFalse(file.isHidden());
assertTrue(file.isReadable());
assertTrue(file.isWriteable());
Map<?, ?> map = file.getContent().getAttributes();
String name = ((URLFileName)file.getName()).getUserName();
assertTrue(map.containsKey(DeltaVConstants.CREATOR_DISPLAYNAME.toString()));
assertEquals(map.get(DeltaVConstants.CREATOR_DISPLAYNAME.toString()),"testUser");
if (name != null)
{
assertTrue(map.containsKey(DeltaVConstants.COMMENT.toString()));
assertEquals("Modified by user " + name, map.get(DeltaVConstants.COMMENT.toString()));
}
assertTrue(map.containsKey(VersionControlledResource.CHECKED_IN.toString()));
// Create the source file
final String content = "Here is some sample content for the file. Blah Blah Blah.";
final OutputStream os = file.getContent().getOutputStream();
try
{
os.write(content.getBytes("utf-8"));
}
finally
{
os.close();
}
assertSameContent(content, file);
map = file.getContent().getAttributes();
assertTrue(map.containsKey(DeltaVConstants.CREATOR_DISPLAYNAME.toString()));
assertEquals(map.get(DeltaVConstants.CREATOR_DISPLAYNAME.toString()),"testUser");
if (name != null)
{
assertTrue(map.containsKey(DeltaVConstants.COMMENT.toString()));