Пример #1
0
  private void testHistoryIDCreate(String[] strArr) {
    HistoryID testNoSpecialCharsID = HistoryID.createFromRawID(strArr);
    HistoryID testNoSpecialCharsIDFSRead =
        HistoryID.createFromRawStrings(testNoSpecialCharsID.getID());

    assertEquals(
        "Wrong length",
        testNoSpecialCharsID.getID().length,
        testNoSpecialCharsIDFSRead.getID().length);

    for (int i = 0; i < testNoSpecialCharsID.getID().length; i++) {
      /*System.err.println(
      testNoSpecialCharsID.getID()[i] +
      " ? " +
      testNoSpecialCharsIDFSRead.getID()[i]);*/
      assertEquals(
          "Wrong id", testNoSpecialCharsID.getID()[i], testNoSpecialCharsIDFSRead.getID()[i]);
    }
  }
Пример #2
0
  @Override
  protected void setUp() throws Exception {
    BundleContext context = HistoryServiceLick.bc;

    historyServiceRef = context.getServiceReference(HistoryService.class.getName());
    this.historyService = (HistoryService) context.getService(historyServiceRef);

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

    this.history = this.historyService.createHistory(testID, recordStructure);
  }
Пример #3
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());
    }
  }