public void test_foo() throws Exception {
    String emptyPict = IOTools.readFileString(resourcePath + "/" + EMPTY_FILENAME);
    String expected = "<File><name>empty.jpg</name><body/><size>0</size></File>";

    expected = expected.replaceAll("\\n", "").replaceAll("\\r", "").replaceAll(" ", "");
    emptyPict = emptyPict.replaceAll("\\n", "").replaceAll("\\r", "").replaceAll(" ", "");

    assertEquals(expected, emptyPict);
  }
Exemplo n.º 2
0
  /**
   * Returns the server bean configuration if there is any. If the bean name does not represents a
   * configuration but an instance, null is returned.
   *
   * @param beanName name of the bean - NOT NULL
   * @return the configuration file if found, NULL otherwise
   * @throws BeanInstantiationException if the bean cannot be istantiated
   * @throws BeanInitializationException if an initialization error occurred
   * @throws BeanNotFoundException if the bean does not exist
   */
  public static String getBeanConfig(String beanName)
      throws BeanInstantiationException, BeanInitializationException, BeanNotFoundException {

    try {
      return IOTools.readFileString(beanName);
    } catch (IOException e) {
      throw new BeanNotFoundException("The bean could not be read: " + e.toString());
    }
  }
  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());
  }