Beispiel #1
0
  /** Set up a clean database before we do the testing on it. */
  @Before
  public void setup() {
    // create workding dir
    (new File(this.path)).mkdirs();

    // make sure the old file is deleted
    new File(this.dbFile).delete();
    arff.delete();
    csv.delete();

    try {
      this.database = new Database(this.dbFile);
      this.selCon = new SelectionController();
      this.subCon = new SubspaceController(database);
      this.grCon = new GroupController(database, subCon);
      this.daHub = new DataHub(database, grCon, subCon);
      arff.createNewFile();
      csv.createNewFile();
    } catch (IllegalArgumentException e) {
      Assert.fail("Database setup failed; path is invalid: " + e.getMessage());
    } catch (InvalidDriverException e) {
      Assert.fail("Database setup failed; SQL driver is invalid: " + e.getMessage());
    } catch (DatabaseAccessException e) {
      Assert.fail("Database setup failed; connection could not be created: " + e.getMessage());
    } catch (IncompatibleVersionException e) {
      Assert.fail("Database setup failed; connection could not be created: " + e.getMessage());
    } catch (IOException e) {
      Assert.fail(e.getClass().toString());
    }
  }
Beispiel #2
0
  /** Test the correct behavior of a in-memory database. */
  @Test
  public void inMemoryTest() {
    Database database = null;
    String path = ":memory:";

    try {
      database = new Database(path);
    } catch (InvalidDriverException e) {
      fail(e.getMessage());
    } catch (IncompatibleVersionException e) {
      fail(e.getMessage());
    } catch (DatabaseAccessException e) {
      fail(e.getMessage());
    }

    // path should be :memory: only
    if (database != null) {
      assertEquals(database.getPath(), path);
    }

    // all other tests have to work on a in-memory database as well
    String[] features = {"dim0", "dim1", "dim2"};
    boolean[] outlierFlags = {false, false, true};

    float[][] objects = {{1.1f, 1.2f, 1.3f}, {2.1f, 2.2f, 2.3f}, {3.1f, 3.2f, 3.3f}};

    try {
      this.database.initFeatures(features, outlierFlags);
      this.database.pushSubspace(1, new int[] {2, 3}, "testSubspace");
      this.database.pushObject(objects);
      this.database.updateFeaturesMinMax();
    } catch (DatabaseAccessException e) {
      fail("In-memory database is not working correctly.");
    }
  }
Beispiel #3
0
  /** Clean up, after testing. */
  @After
  public void tearDown() {
    // shutdown
    try {
      this.database.shutdown();
    } catch (DatabaseAccessException e) {
      fail(e.getMessage());
    }

    // clean up database
    if (this.database != null) {
      assertEquals(true, (new File(this.dbFile)).delete());
    }
  }
Beispiel #4
0
  /** Clean up, after testing. */
  @After
  public void tearDown() {
    // shutdown
    try {
      this.database.shutdown();
    } catch (DatabaseAccessException ex) {
      Assert.fail("Databus shutdown fail: " + ex.getMessage());
    }

    // clean up database
    if (this.database != null) {
      Assert.assertEquals(true, new File(this.dbFile).delete());
    }
    if (arff.exists()) arff.delete();
    if (csv.exists()) csv.delete();
    if (ssd.exists()) ssd.delete();
  }
Beispiel #5
0
  /** Set up a clean database before we do the testing on it. */
  @Before
  public void setup() {
    // create working directory
    (new File(this.path)).mkdirs();

    // make sure the old file is deleted
    (new File(this.dbFile)).delete();

    try {
      this.database = new Database(this.dbFile);
    } catch (InvalidDriverException e) {
      fail(e.getMessage());
    } catch (IncompatibleVersionException e) {
      fail(e.getMessage());
    } catch (DatabaseAccessException e) {
      fail(e.getMessage());
    }
  }