1 21 package com.db4o.db4ounit.common.types.arrays; 22 23 import db4ounit.*; 24 import db4ounit.extensions.*; 25 26 27 public class NestedArraysTestCase extends AbstractDb4oTestCase { 28 29 private static final int DEPTH = 5; 30 private static final int ELEMENTS = 3; 31 32 public static class Data { 33 public Object _obj; 34 public Object [] _arr; 35 36 public Data(Object obj, Object [] arr) { 37 this._obj = obj; 38 _arr = arr; 39 } 40 } 41 42 protected void store(){ 43 Object [] obj = new Object [ELEMENTS]; 44 fill(obj, DEPTH); 45 Object [] arr = new Object [ELEMENTS]; 46 fill(arr, DEPTH); 47 db().set(new Data(obj,arr)); 48 } 49 50 private void fill(Object [] arr, int depth){ 51 if(depth <= 0){ 52 arr[0] = "somestring"; 53 arr[1] = new Integer (10); 54 return; 55 } 56 57 depth --; 58 59 for (int i = 0; i < ELEMENTS; i++) { 60 arr[i] = new Object [ELEMENTS]; 61 fill((Object [])arr[i], depth ); 62 } 63 } 64 65 public void testOne(){ 66 Data data=(Data)retrieveOnlyInstance(Data.class); 67 db().activate(data, Integer.MAX_VALUE); 68 check((Object [])data._obj, DEPTH); 69 check(data._arr, DEPTH); 70 } 71 72 private void check(Object [] arr, int depth){ 73 if(depth <= 0){ 74 Assert.areEqual("somestring",arr[0]); 75 Assert.areEqual(new Integer (10),arr[1]); 76 return; 77 } 78 79 depth --; 80 81 for (int i = 0; i < ELEMENTS; i++) { 82 check((Object [])arr[i], depth ); 83 } 84 85 } 86 87 } 88 | Popular Tags |