public void testChildCreation() throws Exception
{
final String text = "Writing to a source";
FileSource src = new FileSource("file", m_tempDir);
FileSource child = (FileSource) src.getChild("child.txt");
assertTrue("New file already exists", !child.exists());
// Should not have a validity, since it doesn't exist
assertNull("New file has a validity", child.getValidity());
// Test the name
assertEquals("Wrong name", "child.txt", child.getName());
// Feed with some content
fillSource(child, text);
// And test it
assertEquals(
"Wrong length",
text.length() + System.getProperty("line.separator").length(),
child.getContentLength());
assertEquals("Wrong content-type", "text/plain", child.getMimeType());
assertTrue("New file is traversable", !child.isCollection());
// Check that parent now has children
Collection children = src.getChildren();
assertEquals("Wrong number of children", 1, children.size());
// And also that crawling up the hierarchy is OK
Source parent = child.getParent();
assertEquals("Wrong parent URI", src.getURI(), parent.getURI());
}