コード例 #1
0
  public void test() {
    Test.forEach(
        new CascadeToExistingVectorMember(),
        new Visitor4() {
          public void visit(Object obj) {
            CascadeToExistingVectorMember cev = (CascadeToExistingVectorMember) obj;
            Atom atom = (Atom) cev.vec.elementAt(0);
            atom.name = "two";
            Test.store(cev);
            atom.name = "three";
            Test.store(cev);
          }
        });

    Test.reOpen();

    Test.forEach(
        new CascadeToExistingVectorMember(),
        new Visitor4() {
          public void visit(Object obj) {
            CascadeToExistingVectorMember cev = (CascadeToExistingVectorMember) obj;
            Atom atom = (Atom) cev.vec.elementAt(0);
            Test.ensure(atom.name.equals("three"));
            Test.ensureOccurrences(atom, 1);
          }
        });

    Test.forEach(
        new CascadeToExistingVectorMember(),
        new Visitor4() {
          public void visit(Object obj) {
            CascadeToExistingVectorMember cev = (CascadeToExistingVectorMember) obj;
            Atom atom = (Atom) cev.vec.elementAt(0);
            atom.name = "four";
            Test.store(cev);
          }
        });

    Test.reOpen();

    Test.forEach(
        new CascadeToExistingVectorMember(),
        new Visitor4() {
          public void visit(Object obj) {
            CascadeToExistingVectorMember cev = (CascadeToExistingVectorMember) obj;
            Atom atom = (Atom) cev.vec.elementAt(0);
            Test.ensure(atom.name.equals("four"));
            Test.ensureOccurrences(atom, 1);
          }
        });
  }
コード例 #2
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);
  }