Beispiel #1
0
 @Test
 public void getSnapshot() {
   BSONObject matcher = new BasicBSONObject();
   BSONObject selector = new BasicBSONObject();
   BSONObject orderBy = new BasicBSONObject();
   matcher.put("Name", Constants.TEST_CS_NAME_1 + "." + Constants.TEST_CL_NAME_1);
   selector.put("Name", 1);
   selector.put("Details", 1);
   orderBy.put("Details", 1);
   cursor = sdb.getSnapshot(4, matcher, selector, orderBy);
   assertTrue(cursor.hasNext());
   cursor = sdb.getSnapshot(0, "", "", "");
   assertTrue(cursor.hasNext());
   cursor = sdb.getSnapshot(1, "", "", "");
   assertTrue(cursor.hasNext());
   cursor = sdb.getSnapshot(2, "", "", "");
   assertTrue(cursor.hasNext());
   cursor = sdb.getSnapshot(3, "", "", "");
   assertTrue(cursor.hasNext());
   cursor = sdb.getSnapshot(5, "", "", "");
   assertTrue(cursor.hasNext());
   cursor = sdb.getSnapshot(6, "", "", "");
   assertTrue(cursor.hasNext());
   cursor = sdb.getSnapshot(7, "", "", "");
   assertTrue(cursor.hasNext());
   try {
     cursor = sdb.getSnapshot(8, "", "", "");
     assertTrue(cursor.hasNext());
   } catch (BaseException e) {
     if (!e.getErrorType().equals("SDB_RTN_COORD_ONLY")) assertTrue(false);
     return;
   }
 }
Beispiel #2
0
  @Test
  public void getList() {
    BSONObject matcher = new BasicBSONObject();
    BSONObject selector = new BasicBSONObject();
    BSONObject orderBy = new BasicBSONObject();
    matcher.put("Status", "Running");
    selector.put("SessionID", 1);
    selector.put("TID", 1);
    selector.put("Status", 1);
    selector.put("Type", 1);
    orderBy.put("TID", 1);
    cursor = sdb.getList(2, matcher, selector, orderBy);
    assertTrue(cursor.hasNext());
    cursor = sdb.getList(0, null, null, null);
    assertTrue(cursor.hasNext());
    cursor = sdb.getList(1, null, null, null);
    assertTrue(cursor.hasNext());
    cursor = sdb.getList(3, null, null, null);
    assertTrue(cursor.hasNext());
    cursor = sdb.getList(4, null, null, null);
    assertTrue(cursor.hasNext());
    cursor = sdb.getList(5, null, null, null);
    assertTrue(cursor.hasNext());
    if (!isCluster) {
      cl.insert(new BasicBSONObject("a", 1));
      cursor = sdb.getList(6, null, null, null);
      assertTrue(cursor.hasNext());
    }
    try {
      cursor = sdb.getList(7, null, null, null);
      assertTrue(cursor.hasNext());
    } catch (BaseException e) {
      if (!e.getErrorType().equals("SDB_RTN_COORD_ONLY")) assertTrue(false);
    }
    if (isCluster) {
      cursor = null;
      cursor = sdb.getList(8, null, null, null);
      assertTrue(null != cursor);
    }

    try {
      cursor = null;
      cursor = sdb.getList(9, null, null, null);
      assertTrue(null != cursor);
    } catch (BaseException e) {
      if (!e.getErrorType().equals("SDB_RTN_COORD_ONLY")) assertTrue(false);
    }
    if (isCluster) {
      cursor = null;
      cursor = sdb.getList(10, null, null, null);
      assertTrue(null != cursor);
    }
  }