@Override
  protected void setUp() throws Exception {
    ReadDriver.initialize();
    ReadDriver.isEditable = true;
    ReadDriver.pk = true;

    dsf = new DataSourceFactory();
    dsf.setTempDir("src/test/resources/backup");
    DriverManager dm = new DriverManager();
    dm.registerDriver(ReadAndWriteDriver.class);

    SourceManager sourceManager = dsf.getSourceManager();
    sourceManager.setDriverManager(dm);
    sourceManager.register("object", new ObjectSourceDefinition(new ReadAndWriteDriver()));
    sourceManager.register("writeFile", new FakeFileSourceDefinition(new ReadAndWriteDriver()));
    sourceManager.register("closeFile", new FakeFileSourceDefinition(new ReadAndWriteDriver()));
    sourceManager.register("copyFile", new FakeFileSourceDefinition(new ReadAndWriteDriver()));
    sourceManager.register(
        "executeDB",
        new FakeDBTableSourceDefinition(new ReadAndWriteDriver(), "jdbc:executefailing"));
    sourceManager.register(
        "closeDB", new FakeDBTableSourceDefinition(new ReadAndWriteDriver(), "jdbc:closefailing"));
    dsf.getIndexManager()
        .buildIndex("object", SPATIAL_FIELD_NAME, IndexManager.RTREE_SPATIAL_INDEX, null);
    dsf.getIndexManager()
        .buildIndex("writeFile", SPATIAL_FIELD_NAME, IndexManager.RTREE_SPATIAL_INDEX, null);
    dsf.getIndexManager()
        .buildIndex("executeDB", SPATIAL_FIELD_NAME, IndexManager.RTREE_SPATIAL_INDEX, null);
    dsf.getIndexManager()
        .buildIndex("closeDB", SPATIAL_FIELD_NAME, IndexManager.RTREE_SPATIAL_INDEX, null);
    dsf.getIndexManager()
        .buildIndex("copyFile", SPATIAL_FIELD_NAME, IndexManager.RTREE_SPATIAL_INDEX, null);
    dsf.getIndexManager()
        .buildIndex("closeFile", SPATIAL_FIELD_NAME, IndexManager.RTREE_SPATIAL_INDEX, null);
  }
Example #2
0
  @Test
  public void testListenCommits() throws Exception {
    DriverManager dm = new DriverManager();
    dm.registerDriver(ReadAndWriteDriver.class);

    sm.setDriverManager(dm);
    sm.register("object", new MemorySourceDefinition(new ReadAndWriteDriver(), "main"));
    sm.register("file", new FakeFileSourceDefinition(new ReadAndWriteDriver()));
    sm.register(
        "db", new FakeDBTableSourceDefinition(new ReadAndWriteDriver(), "jdbc:closefailing"));

    testListenCommits(dsf.getDataSource("object"));
    testListenCommits(dsf.getDataSource("file"));
    testListenCommits(dsf.getDataSource("db"));
  }
  public static ReadOnlyDriver getDriver(DriverManager dm, String prefix) {
    String[] names = dm.getDriverNames();
    for (int i = 0; i < names.length; i++) {
      Driver driver = dm.getDriver(names[i]);
      if (driver instanceof DBDriver) {
        DBDriver dbDriver = (DBDriver) driver;
        String[] prefixes = dbDriver.getPrefixes();
        for (String driverPrefix : prefixes) {
          if (driverPrefix.toLowerCase().equals(prefix.toLowerCase())) {
            return dbDriver;
          }
        }
      }
    }

    throw new DriverLoadException("No suitable driver for " + prefix);
  }
  public static ReadOnlyDriver getDriver(DriverManager dm, File file) {
    String[] names = dm.getDriverNames();
    for (int i = 0; i < names.length; i++) {
      Driver driver = dm.getDriver(names[i]);
      if (driver instanceof FileDriver) {
        FileDriver fileDriver = (FileDriver) driver;
        String[] extensions = fileDriver.getFileExtensions();
        for (String extension : extensions) {
          if (file.getAbsolutePath().toLowerCase().endsWith(extension.toLowerCase())) {
            return fileDriver;
          }
        }
      }
    }

    throw new DriverLoadException("No suitable driver for " + file.getAbsolutePath());
  }
  public OpenGdmsFilePanel(String title, DriverManager driverManager) {
    super(OPEN_GDMS_FILE_PANEL, title);

    Driver[] filtered = driverManager.getDrivers(new FileDriverFilter());
    for (int i = 0; i < filtered.length; i++) {
      FileDriver fileDriver = (FileDriver) filtered[i];
      String[] extensions = fileDriver.getFileExtensions();
      this.addFilter(extensions, fileDriver.getTypeDescription());
    }
  }