1 21 package com.db4o.db4ounit.common.soda.wrapper.untyped; 22 import java.io.*; 23 24 import com.db4o.*; 25 import com.db4o.query.*; 26 27 28 public class STByteWUTestCase extends com.db4o.db4ounit.common.soda.util.SodaBaseTestCase implements Serializable{ 29 30 final static String DESCENDANT = "i_byte"; 31 32 public Object i_byte; 33 34 public STByteWUTestCase(){ 35 } 36 37 private STByteWUTestCase(byte a_byte){ 38 i_byte = new Byte (a_byte); 39 } 40 41 public Object [] createData() { 42 return new Object []{ 43 new STByteWUTestCase((byte)0), 44 new STByteWUTestCase((byte)1), 45 new STByteWUTestCase((byte)99), 46 new STByteWUTestCase((byte)113), 47 }; 48 } 49 50 public void testEquals(){ 51 Query q = newQuery(); 52 q.constrain(new STByteWUTestCase((byte)0)); 53 com.db4o.db4ounit.common.soda.util.SodaTestUtil.expectOne(q, _array[0]); 54 } 55 56 public void testNotEquals(){ 57 Query q = newQuery(); 58 59 q.constrain(_array[0]); 60 q.descend(DESCENDANT).constraints().not(); 61 expect(q, new int[] {1, 2, 3}); 62 } 63 64 public void testGreater(){ 65 Query q = newQuery(); 66 q.constrain(new STByteWUTestCase((byte)9)); 67 q.descend(DESCENDANT).constraints().greater(); 68 69 expect(q, new int[] {2, 3}); 70 } 71 72 public void testSmaller(){ 73 Query q = newQuery(); 74 q.constrain(new STByteWUTestCase((byte)1)); 75 q.descend(DESCENDANT).constraints().smaller(); 76 com.db4o.db4ounit.common.soda.util.SodaTestUtil.expectOne(q, _array[0]); 77 } 78 79 public void testContains(){ 80 Query q = newQuery(); 81 q.constrain(new STByteWUTestCase((byte)9)); 82 q.descend(DESCENDANT).constraints().contains(); 83 84 expect(q, new int[] {2}); 85 } 86 87 public void testNotContains(){ 88 Query q = newQuery(); 89 q.constrain(new STByteWUTestCase((byte)0)); 90 q.descend(DESCENDANT).constraints().contains().not(); 91 92 expect(q, new int[] {1, 2, 3}); 93 } 94 95 public void testLike(){ 96 Query q = newQuery(); 97 q.constrain(new STByteWUTestCase((byte)11)); 98 q.descend(DESCENDANT).constraints().like(); 99 com.db4o.db4ounit.common.soda.util.SodaTestUtil.expectOne(q, new STByteWUTestCase((byte)113)); 100 q = newQuery(); 101 q.constrain(new STByteWUTestCase((byte)10)); 102 q.descend(DESCENDANT).constraints().like(); 103 expect(q, new int[] {}); 104 } 105 106 public void testNotLike(){ 107 Query q = newQuery(); 108 q.constrain(new STByteWUTestCase((byte)1)); 109 q.descend(DESCENDANT).constraints().like().not(); 110 111 expect(q, new int[] {0, 2}); 112 } 113 114 public void testIdentity(){ 115 Query q = newQuery(); 116 q.constrain(new STByteWUTestCase((byte)1)); 117 ObjectSet set = q.execute(); 118 STByteWUTestCase identityConstraint = (STByteWUTestCase)set.next(); 119 identityConstraint.i_byte = new Byte ((byte)102); 120 q = newQuery(); 121 q.constrain(identityConstraint).identity(); 122 identityConstraint.i_byte = new Byte ((byte)1); 123 com.db4o.db4ounit.common.soda.util.SodaTestUtil.expectOne(q,_array[1]); 124 } 125 126 public void testNotIdentity(){ 127 Query q = newQuery(); 128 q.constrain(new STByteWUTestCase((byte)1)); 129 ObjectSet set = q.execute(); 130 STByteWUTestCase identityConstraint = (STByteWUTestCase)set.next(); 131 identityConstraint.i_byte = new Byte ((byte)102); 132 q = newQuery(); 133 q.constrain(identityConstraint).identity().not(); 134 identityConstraint.i_byte = new Byte ((byte)1); 135 136 expect(q, new int[] {0, 2, 3}); 137 } 138 139 public void testConstraints(){ 140 Query q = newQuery(); 141 q.constrain(new STByteWUTestCase((byte)1)); 142 q.constrain(new STByteWUTestCase((byte)0)); 143 Constraints cs = q.constraints(); 144 Constraint[] csa = cs.toArray(); 145 if(csa.length != 2){ 146 db4ounit.Assert.fail("Constraints not returned"); 147 } 148 } 149 150 public void testNull(){ 151 152 } 153 154 public void testEvaluation(){ 155 Query q = newQuery(); 156 q.constrain(new STByteWUTestCase()); 157 q.constrain(new Evaluation() { 158 public void evaluate(Candidate candidate) { 159 STByteWUTestCase sts = (STByteWUTestCase)candidate.getObject(); 160 candidate.include((((Byte )sts.i_byte).byteValue() + 2) > 100); 161 } 162 }); 163 164 expect(q, new int[] {2, 3}); 165 } 166 167 } 168 169 | Popular Tags |