1 21 package com.db4o.test; 22 23 import com.db4o.*; 24 import com.db4o.ext.*; 25 import com.db4o.query.*; 26 27 28 public class TestDescend { 29 30 public TestDescend _child; 31 32 public String _name; 33 34 public TestDescend(){ 35 36 } 37 38 public TestDescend(TestDescend child, String name){ 39 _child = child; 40 _name = name; 41 } 42 43 public void storeOne(){ 44 _child = new TestDescend(new TestDescend(new TestDescend(null, "3"), "2"), "1"); 45 _name = "0"; 46 } 47 48 public void test(){ 49 Query q = Test.query(); 50 q.constrain(this.getClass()); 51 q.descend("_name").constrain("0"); 52 ObjectSet objectSet = q.execute(); 53 TestDescend res = (TestDescend)objectSet.next(); 54 55 ExtObjectContainer oc = Test.objectContainer(); 56 57 Object obj = oc.descend(res, new String []{"_name"}); 58 Test.ensure(obj.equals("0")); 59 60 obj = oc.descend(res, new String []{"_child", "_child", "_name"}); 61 Test.ensure(obj.equals("2")); 62 63 obj = oc.descend(res, new String []{"_child", "_child", "_child", "_name"}); 64 Test.ensure(obj.equals("3")); 65 66 obj = oc.descend(res, new String []{"_child", "CRAP", "_child", "_name"}); 67 Test.ensure(obj == null); 68 } 69 70 } 71 | Popular Tags |