1 21 package com.db4o.test.test2; 22 23 import java.util.*; 24 25 import com.db4o.*; 26 import com.db4o.foundation.*; 27 import com.db4o.test.*; 28 import com.db4o.test.types.*; 29 30 31 public abstract class RMap implements RTestable{ 32 33 abstract public Object newInstance(); 34 35 TEntry entry(){ 36 return new TEntry(); 37 } 38 39 public Object set(Object obj, int ver){ 40 TEntry[] arr = entry().test(ver); 41 Map map = (Map)obj; 42 map.clear(); 43 for(int i = 0; i < arr.length; i ++){ 44 map.put(arr[i].key, arr[i].value); 45 } 46 return obj; 47 } 48 49 public void compare(ObjectContainer con, Object obj, int ver){ 50 Map map = (Map)obj; 51 TEntry[] entries = new TEntry[map.size()]; 52 Iterator it = map.keySet().iterator(); 53 int i = 0; 54 while(it.hasNext()){ 55 entries[i] = new TEntry(); 56 entries[i].key = it.next(); 57 i++; 58 } 59 for(i = 0; i < entries.length; i ++){ 60 entries[i].value = map.get(entries[i].key); 61 } 62 entry().compare(entries, ver, false); 63 } 64 65 public void specific(ObjectContainer con, int step){ 66 TEntry entry = entry().firstElement(); 67 Map map = (Map)newInstance(); 68 if(step > 0){ 69 map.put(entry.key, entry.value); 70 ObjectSet set = con.get(map); 71 Collection4 col = new Collection4(); 72 while(set.hasNext()){ 73 Object obj = set.next(); 74 if(obj.getClass() == map.getClass()){ 75 col.add(obj); 76 } 77 } 78 if(col.size() != step){ 79 Regression.addError("Map member query not found" ); 80 } 81 } 82 entry = entry().noElement(); 83 map.put(entry.key, entry.value); 84 if(con.get(map).size() != 0){ 85 Regression.addError("Map member query found too many"); 86 } 87 } 88 89 90 public boolean jdk2(){ 91 return true; 92 } 93 94 95 public boolean ver3(){ 96 return false; 97 } 98 } | Popular Tags |