예제 #1
0
 @Test
 public void testReturnNullWhenNoProperty() throws Exception {
   sm.register(SOURCE, testFile);
   Source source = sm.getSource(SOURCE);
   assertNull(source.getFileProperty("skjbnskb"));
   assertNull(source.getProperty("skjbnskb"));
 }
예제 #2
0
  @Test
  public void testAssociateFile() throws Exception {
    sm.register(SOURCE, testFile);
    String statistics = "statistics";
    Source source = sm.getSource(SOURCE);
    String rcStr = associateFile(source, statistics);

    assertEquals(sm.getSource(SOURCE).getFilePropertyNames().length, 1);

    sm.saveStatus();

    sm.shutdown();
    sm.init();

    assertEquals(sm.getSource(SOURCE).getFilePropertyNames().length, 1);

    String statsContent = source.getFilePropertyContentsAsString(statistics);
    assertEquals(statsContent, rcStr);

    File f = source.getFileProperty(statistics);
    DataInputStream dis = new DataInputStream(new FileInputStream(f));
    byte[] content = new byte[dis.available()];
    dis.readFully(content);
    assertEquals(new String(content), rcStr);
  }