예제 #1
0
 public void testPurgeLocallyStoredHistory() {
   try {
     this.historyService.purgeLocallyStoredHistory(this.history.getID());
   } catch (Exception ex) {
     fail("Cannot delete local history with id " + this.history.getID() + " : " + ex.getMessage());
   }
 }
예제 #2
0
  public void testCreateDB() {
    ArrayList<String> al = new ArrayList<String>();

    Iterator<HistoryID> i = this.historyService.getExistingIDs();
    while (i.hasNext()) {
      HistoryID id = i.next();
      String[] components = id.getID();

      if (components.length == 2 && "test".equals(components[0])) {
        al.add(components[1]);
      }
    }

    int count = al.size();
    boolean unique = false;
    String lastComp = null;
    while (!unique) {
      lastComp = Integer.toHexString(random.nextInt());
      for (int j = 0; j < count; j++) {
        if (lastComp.equals(al.get(j))) {
          continue;
        }
      }
      unique = true;
    }

    HistoryID id = HistoryID.createFromRawID(new String[] {"test", lastComp});

    try {
      this.historyService.createHistory(id, recordStructure);
    } catch (Exception e) {
      fail("Could not create database with id " + id + " with error " + e);
    }

    try {
      // after creating, remove it - do not leave content
      this.historyService.purgeLocallyStoredHistory(id);
    } catch (Exception ex) {
      fail("Cannot delete local history with id " + this.history.getID() + " : " + ex.getMessage());
    }
  }