public void testUnmarshall_Size_WaterfallFDO() throws Exception {
    String fdoFileName = WATERFALL_FILENAME;
    String fileDataObjectDoc = IOTools.readFileString(resourcePath + "/" + fdoFileName);

    FileDataObjectXMLParser parser = new FileDataObjectXMLParser(null);
    FileDataObject fileDataObject = parser.parse(fileDataObjectDoc);

    assertEquals(new Long(30124), fileDataObject.getSize());
  }
  public void testUnmarshall_Cttype_SimpleTextFDO() throws Exception {
    String fdoFileName = SIMPLETEXT_FILENAME;
    String fileDataObjectDoc = IOTools.readFileString(resourcePath + "/" + fdoFileName);

    FileDataObjectXMLParser parser = new FileDataObjectXMLParser(null);
    FileDataObject fileDataObject = parser.parse(fileDataObjectDoc);

    assertEquals("text/plain", fileDataObject.getContentType());
  }
  public void testUnmarshall_Modified_WaterfallFDO() throws Exception {
    String fdoFileName = WATERFALL_FILENAME;
    String fileDataObjectDoc = IOTools.readFileString(resourcePath + "/" + fdoFileName);

    FileDataObjectXMLParser parser = new FileDataObjectXMLParser(null);
    FileDataObject fileDataObject = parser.parse(fileDataObjectDoc);

    assertEquals("20030809T015500Z", fileDataObject.getModified());
  }
  public void testUnmarshall_Name_EmptyFDO() throws Exception {
    String fdoFileName = EMPTY_FILENAME;
    String fileDataObjectDoc = IOTools.readFileString(resourcePath + "/" + fdoFileName);

    FileDataObjectXMLParser parser = new FileDataObjectXMLParser(null);
    FileDataObject fileDataObject = parser.parse(fileDataObjectDoc);

    assertEquals("empty.jpg", fileDataObject.getName());
  }
  public void testUnmarshall_Accessed_WaterfallFDO() throws Exception {
    String fdoFileName = WATERFALL_FILENAME;
    String fileDataObjectDoc = IOTools.readFileString(resourcePath + "/" + fdoFileName);

    TimeZone berlinTZ = TimeZone.getTimeZone("Europe/Berlin");

    FileDataObjectXMLParser parser = new FileDataObjectXMLParser(berlinTZ);
    FileDataObject fileDataObject = parser.parse(fileDataObjectDoc);

    assertEquals("20030808T235800Z", fileDataObject.getAccessed());
  }
  public void test_InvalidXML_NoStartingTag() throws Exception {
    String fileDataObjectDoc =
        "<File><name>empty.jpg</name><body/><size>0</size></File>";

    FileDataObjectXMLParser parser = new FileDataObjectXMLParser(null);
    try {
      FileDataObject fileDataObject = parser.parse(fileDataObjectDoc);
    } catch (FileDataObjectParsingException ex) {

      assertEquals(FileDataObjectParsingException.MISSING_START_ELEMENT, ex.getMessage());
      return;
    }
    fail("Should have thrown a FileDataObjectParsingException");
  }
  public void test_InvalidXML_WrongStartingTag() throws Exception {
    String fileDataObjectDoc =
        "<foo><name>empty.jpg</name><body/><size>0</size></File><File><name>empty.jpg</name><body/><size>0</size></foo>";

    FileDataObjectXMLParser parser = new FileDataObjectXMLParser(null);
    try {
      FileDataObject fileDataObject = parser.parse(fileDataObjectDoc);
    } catch (FileDataObjectParsingException ex) {

      assertEquals(
          FileDataObjectParsingException.UNEXPECTED_ROOT_ELEMENT + " 'foo'", ex.getMessage());
      return;
    }
    fail("Should have thrown a FileDataObjectParsingException");
  }