예제 #1
0
  @Test
  public void testOverrideFileProperty() throws Exception {
    sm.register(SOURCE, testFile);
    Source source = sm.getSource(SOURCE);
    String fileProp = "testFileProp";
    associateFile(source, fileProp);

    File file = source.createFileProperty(fileProp);
    FileOutputStream fis = new FileOutputStream(file);
    fis.write("newcontent".getBytes());
    fis.close();

    source.deleteProperty(fileProp);
    File dir = sm.getSourceInfoDirectory();
    File[] content =
        dir.listFiles(
            new FilenameFilter() {

              @Override
              public boolean accept(File dir, String name) {
                return !name.startsWith(".");
              }
            });
    assertEquals(2, content.length);
    String[] res = new String[] {content[0].getName(), content[1].getName()};
    Arrays.sort(res);
    String[] comp = new String[] {"directory.xml", "spatial_ref_sys_extended.gdms"};
    assertArrayEquals(res, comp);
  }
예제 #2
0
  @Test
  public void testRemoveStringProperty() throws Exception {
    sm.register(SOURCE, testFile);
    Source source = sm.getSource(SOURCE);
    String stringProp = "testFileProp";
    associateString(source, stringProp);
    source.deleteProperty(stringProp);

    assertEquals(source.getStringPropertyNames().length, 0);
    assertEquals(source.getFilePropertyNames().length, 0);
  }
예제 #3
0
  private String associateFile(Source source, String propertyName) throws Exception {
    if (source.hasProperty(propertyName)) {
      source.deleteProperty(propertyName);
    }
    File stats = source.createFileProperty(propertyName);
    DataSource ds = dsf.getDataSource(source.getName());
    ds.open();
    long rc = ds.getRowCount();
    ds.close();

    FileOutputStream fis = new FileOutputStream(stats);
    String rcStr = Long.toString(rc);
    fis.write(rcStr.getBytes());
    fis.close();

    return rcStr;
  }