public void conc2(ExtObjectContainer oc) {
   oc.store(new CreateIndexFor("d"));
   tQueryB(oc);
   tUpdateB(oc);
   oc.store(new CreateIndexFor("z"));
   oc.store(new CreateIndexFor("y"));
 }
 private void tUpdateB(ExtObjectContainer oc) {
   ObjectSet res = query(oc, "b");
   CreateIndexFor ci = (CreateIndexFor) res.next();
   ci.i_name = "j";
   oc.store(ci);
   res = query(oc, "b");
   Assert.areEqual(0, res.size());
   res = query(oc, "j");
   Assert.areEqual(1, res.size());
   ci.i_name = "b";
   oc.store(ci);
   tQueryB(oc);
 }
  public void testRefresh() {
    ExtObjectContainer client1 = openNewSession();
    ExtObjectContainer client2 = openNewSession();
    TAItem item1 = (TAItem) retrieveInstance(client1);
    TAItem item2 = (TAItem) retrieveInstance(client2);

    assertDescendingRange(10, item1);

    assertDescendingRange(10, item2);

    item1.value(100);
    item1.next().value(200);
    client1.store(item1, 2);
    client1.commit();

    Assert.areEqual(100, item1.value());
    Assert.areEqual(200, item1.next().value());

    Assert.areEqual(10, item2.value());
    Assert.areEqual(9, item2.next().value());

    // refresh 0
    client2.refresh(item2, 0);
    Assert.areEqual(10, item2.value());
    Assert.areEqual(9, item2.next().value());

    // refresh 1
    client2.refresh(item2, 1);
    Assert.areEqual(100, item2.value());
    Assert.areEqual(9, item2.next().value());

    // refresh 2
    client2.refresh(item2, 2);
    Assert.areEqual(100, item2.value());
    Assert.areEqual(200, item2.next().value());

    updateAscendingWithRange(item1, 1000);
    client1.store(item1, 5);
    client1.commit();

    client2.refresh(item2, 5);
    TAItem next2 = item2;
    for (int i = 1000; i < 1005; i++) {
      Assert.areEqual(i, next2.value());
      next2 = next2.next();
    }
    client1.close();
    client2.close();
  }
 public void concUpdateSameObject(ExtObjectContainer oc, int seq) throws Exception {
   Query query = oc.query();
   query.descend("_s").constrain(testString + COUNT / 2);
   ObjectSet result = query.execute();
   Assert.areEqual(1, result.size());
   SimpleObject o = (SimpleObject) result.next();
   o.setI(COUNT + seq);
   oc.store(o);
 }
 public void concUpdateDifferentObject(ExtObjectContainer oc, int seq) throws Exception {
   Query query = oc.query();
   query
       .descend("_s")
       .constrain(testString + seq)
       .and(query.descend("_i").constrain(new Integer(seq)));
   ObjectSet result = query.execute();
   Assert.areEqual(1, result.size());
   SimpleObject o = (SimpleObject) result.next();
   o.setI(seq + COUNT);
   oc.store(o);
 }
 public void concUpdate(ExtObjectContainer oc, int seq) throws Exception {
   Query q = oc.query();
   q.constrain(IndexedByIdentityTestCase.class);
   ObjectSet os = q.execute();
   Assert.areEqual(COUNT, os.size());
   while (os.hasNext()) {
     IndexedByIdentityTestCase idi = (IndexedByIdentityTestCase) os.next();
     idi.atom.name = "updated" + seq;
     oc.store(idi);
     Thread.sleep(100);
   }
 }
  public void testRefresh() {
    ExtObjectContainer client1 = openNewSession();
    ExtObjectContainer client2 = openNewSession();
    Item item1 = retrieveInstance(client1);
    Item item2 = retrieveInstance(client2);

    Item next1 = item1;
    int value = 10;
    while (next1 != null) {
      Assert.areEqual(value, next1.getValue());
      next1 = next1.next();
      value--;
    }

    Item next2 = item2;
    value = 10;
    while (next2 != null) {
      Assert.areEqual(value, next2.getValue());
      next2 = next2.next();
      value--;
    }

    item1.setValue(100);
    item1.next().setValue(200);
    client1.store(item1, 2);
    client1.commit();

    Assert.areEqual(100, item1.getValue());
    Assert.areEqual(200, item1.next().getValue());

    Assert.areEqual(10, item2.getValue());
    Assert.areEqual(9, item2.next().getValue());

    // refresh 0
    client2.refresh(item2, 0);
    Assert.areEqual(10, item2.getValue());
    Assert.areEqual(9, item2.next().getValue());

    // refresh 1
    client2.refresh(item2, 1);
    Assert.areEqual(100, item2.getValue());
    Assert.areEqual(9, item2.next().getValue());

    // refresh 2
    client2.refresh(item2, 2);
    Assert.areEqual(100, item2.getValue());
    // FIXME: maybe a bug
    // Assert.areEqual(200, item2.next().getValue());

    next1 = item1;
    value = 1000;
    while (next1 != null) {
      next1.setValue(value);
      next1 = next1.next();
      value++;
    }
    client1.store(item1, 5);
    client1.commit();

    client2.refresh(item2, 5);
    next2 = item2;
    for (int i = 1000; i < 1005; i++) {
      Assert.areEqual(i, next2.getValue());
      next2 = next2.next();
    }

    client1.close();
    client2.close();
  }