Ejemplo n.º 1
0
 public void testQuery() {
   Query q = Test.query();
   ObjectSet objectSet = q.execute();
   Test.ensure(objectSet.size() >= 2);
   int i = 0;
   while (objectSet.hasNext()) {
     Object obj = objectSet.next();
     Test.ensure(obj != null);
     i++;
   }
   Test.ensure(i >= 2);
 }
Ejemplo n.º 2
0
  public void test() {
    Query q = Test.query();
    q.constrain(new TestStringBuffer("Vera"));
    q.descend("sb").constraints().contains();
    ObjectSet os = q.execute();
    Test.ensure(os.size() == 1);
    TestStringBuffer tbs = (TestStringBuffer) os.next();
    Test.ensure(tbs.sb.toString().equals("Aloe Vera"));

    //        q = Test.query();
    //        q.constrain(new TestStringBuffer("Yohaa"));
    //        os = q.execute();
    //        Test.ensure(os.size() == 1);
    //        tbs = (TestStringBuffer)os.next();
    //        Test.ensure(tbs.sb.toString().equals("Yohaa"));
  }
  public void test() {
    Query q = Test.query();
    q.constrain(TuningMemberFieldQuery.class);

    q.descend("member").descend("name").constrain("1");

    long start = System.currentTimeMillis();
    ObjectSet objectSet = q.execute();

    long stop = System.currentTimeMillis();

    Test.ensure(objectSet.size() == 1);
    TuningMemberFieldQuery tmf = (TuningMemberFieldQuery) objectSet.next();
    Test.ensure(tmf.member.name.equals("1"));

    long duration = stop - start;
    System.out.println("Querying " + COUNT + " objects for member identity: " + duration + "ms");
  }
Ejemplo n.º 4
0
  public void test() {

    Test.store(new Parent1(new Child1()));

    ObjectContainer container = Test.reOpen();
    container
        .ext()
        .configure()
        .addAlias(new TypeAlias("com.db4o.test.aliases.Parent1", "com.db4o.test.aliases.Parent2"));
    container
        .ext()
        .configure()
        .addAlias(new TypeAlias("com.db4o.test.aliases.Child1", "com.db4o.test.aliases.Child2"));

    ObjectSet os = container.query(Parent2.class);

    Test.ensure(os.size() > 0);

    Parent2 p2 = (Parent2) os.next();

    Test.ensure(p2.child != null);
  }
 public void test() {
   Query q = Test.query();
   q.constrain(getClass());
   q.descend("name")
       .constrain(
           new Evaluation() {
             public void evaluate(Candidate candidate) {
               boolean include =
                   ((String) candidate.getObject()).startsWith("h")
                       && ((String) candidate.getObject()).endsWith("o");
               candidate.include(include);
             }
           });
   ObjectSet objectSet = q.execute();
   Test.ensure(objectSet.size() == 1);
 }
Ejemplo n.º 6
0
  public void test() {

    ObjectContainer con = Test.objectContainer();
    Test.deleteAllInstances(this);

    IsStored isStored = new IsStored();
    isStored.myString = "isStored";
    con.store(isStored);
    Test.ensure(con.ext().isStored(isStored));
    Test.ensure(Test.occurrences(this) == 1);
    con.delete(isStored);
    Test.ensure(!con.ext().isStored(isStored));
    Test.ensure(Test.occurrences(this) == 0);
    con.commit();
    if (con.ext().isStored(isStored)) {

      // this will fail in CS due to locally cached references
      if (!Test.clientServer) {
        Test.error();
      }
    }
    Test.ensure(Test.occurrences(this) == 0);
    con.store(isStored);
    Test.ensure(con.ext().isStored(isStored));
    Test.ensure(Test.occurrences(this) == 1);
    con.commit();
    Test.ensure(con.ext().isStored(isStored));
    Test.ensure(Test.occurrences(this) == 1);
    con.delete(isStored);
    Test.ensure(!con.ext().isStored(isStored));
    Test.ensure(Test.occurrences(this) == 0);
    con.commit();
    if (con.ext().isStored(isStored)) {

      // this will fail in CS due to locally cached references
      if (!Test.clientServer) {
        Test.error();
      }
    }
    Test.ensure(Test.occurrences(this) == 0);
  }
Ejemplo n.º 7
0
 public boolean objectCanDelete(ObjectContainer container) {
   container.activate(this, Integer.MAX_VALUE);
   Test.ensure(_name.equals("p1"));
   Test.ensure(_next != null);
   return true;
 }