1 23 24 package org.objectweb.jorm.runtime.basictype; 25 26 import org.objectweb.jorm.runtime.TestRuntimeHelper; 27 import org.objectweb.jorm.naming.api.PBinder; 28 import org.objectweb.jorm.facility.naming.basidir.BasidBinder; 29 import org.objectweb.jorm.api.PClassMapping; 30 import org.objectweb.jorm.api.PException; 31 32 36 public class TestAllTypes extends TestRuntimeHelper { 37 38 private final static String LOGGER_NAME 39 = "test.org.objectweb.jorm.basictype.alltypes"; 40 41 private final static String CN_ALL_TYPES = "org.objectweb.jorm.pobject.basictype.AllTypes"; 42 43 public TestAllTypes(String name) throws Exception { 44 super(name); 45 } 46 47 protected String getLoggerName() { 48 return LOGGER_NAME; 49 } 50 51 protected PBinder getBinder(String className) throws Exception { 52 try { 53 return new BasidBinder(mapper, 54 "org.objectweb.jorm.runtime.basictype.TestBasicType", 55 PClassMapping.CLEANUP_REMOVEALL); 56 } catch (PException e) { 57 Exception current = e; 58 while (current instanceof PException 59 && ((PException) current).getNestedException() != null) { 60 current = ((PException) current).getNestedException(); 61 } 62 throw current; 63 } 64 } 65 66 public void test1() { 67 AllTypesAcc acc1 = new AllTypesAcc(); 68 acc1.booleanValue1 = true; 69 acc1.booleanValue2 = false; 70 acc1.obooleanValue1 = Boolean.TRUE; 71 acc1.obooleanValue2 = Boolean.FALSE; 72 acc1.byteValue1 = 1; 73 acc1.byteValue2 = 2; 74 acc1.obyteValue1 = new Byte ((byte) 1); 75 acc1.obyteValue2 = new Byte ((byte) 2); 76 acc1.charValue1 = 'a'; 77 acc1.charValue2 = 'b'; 78 acc1.ocharValue1 = new Character ('a'); 79 acc1.ocharValue2 = new Character ('b'); 80 acc1.shortValue1 = 1; 81 acc1.shortValue2 = 2; 82 acc1.oshortValue1 = new Short ((short) 1); 83 acc1.oshortValue2 = new Short ((short) 2); 84 acc1.intValue1 = 1; 85 acc1.intValue2 = 2; 86 acc1.ointValue1 = new Integer (1); 87 acc1.ointValue2 = new Integer (2); 88 acc1.longValue1 = 1; 89 acc1.longValue2 = 2; 90 acc1.olongValue1 = new Long (1); 91 acc1.olongValue2 = new Long (2); 92 acc1.floatValue1 = 1; 93 acc1.floatValue2 = 2; 94 acc1.ofloatValue1 = new Float (1); 95 acc1.ofloatValue2 = new Float (2); 96 acc1.doubleValue1 = 1; 97 acc1.doubleValue2 = 2; 98 acc1.odoubleValue1 = new Double (1); 99 acc1.odoubleValue2 = new Double (2); 100 acc1.chararrayValue1 = new char[]{'a', 'z', 'e', 'r', 't', 'y'}; 101 acc1.chararrayValue2 = new char[]{'q', 's', 'd', 'f', 'g', 'h'}; 102 acc1.bytearrayValue1 = "azerty".getBytes(); 103 acc1.bytearrayValue2 = "qsdfgh".getBytes(); 104 acc1.stringValue1 = "azerty"; 105 acc1.stringValue2 = "qsdfgh"; 106 acc1.dateValue1 = getTime(); 107 try { 108 Thread.sleep(1000); 109 } catch (InterruptedException e) { 110 } 111 acc1.dateValue2 = getTime(); 112 113 AllTypesAcc acc2 = new AllTypesAcc(); 114 performIO(CN_ALL_TYPES, acc1, acc2); 115 assertEquals("Bad booleanValue1", acc1.booleanValue1, acc2.booleanValue1); 116 assertEquals("Bad booleanValue2", acc1.booleanValue2, acc2.booleanValue2); 117 assertEquals("Bad obooleanValue1", acc1.obooleanValue1, acc2.obooleanValue1); 118 assertEquals("Bad obooleanValue2", acc1.obooleanValue2, acc2.obooleanValue2); 119 120 assertEquals("Bad byteValue1", acc1.byteValue1, acc2.byteValue1); 121 assertEquals("Bad byteValue1", acc1.byteValue1, acc2.byteValue1); 122 assertEquals("Bad obyteValue1", acc1.obyteValue1, acc2.obyteValue1); 123 assertEquals("Bad obyteValue1", acc1.obyteValue1, acc2.obyteValue1); 124 125 assertEquals("Bad charValue1", acc1.charValue1, acc2.charValue1); 126 assertEquals("Bad charValue2", acc1.charValue2, acc2.charValue2); 127 assertEquals("Bad ocharValue1", acc1.ocharValue1, acc2.ocharValue1); 128 assertEquals("Bad ocharValue2", acc1.ocharValue2, acc2.ocharValue2); 129 130 assertEquals("Bad shortValue1", acc1.shortValue1, acc2.shortValue1); 131 assertEquals("Bad shortValue2", acc1.shortValue2, acc2.shortValue2); 132 assertEquals("Bad oshortValue1", acc1.oshortValue1, acc2.oshortValue1); 133 assertEquals("Bad oshortValue2", acc1.oshortValue2, acc2.oshortValue2); 134 135 assertEquals("Bad intValue1", acc1.intValue1, acc2.intValue1); 136 assertEquals("Bad intValue2", acc1.intValue2, acc2.intValue2); 137 assertEquals("Bad ointValue1", acc1.ointValue1, acc2.ointValue1); 138 assertEquals("Bad ointValue2", acc1.ointValue2, acc2.ointValue2); 139 140 assertEquals("Bad longValue1", acc1.longValue1, acc2.longValue1); 141 assertEquals("Bad longValue2", acc1.longValue2, acc2.longValue2); 142 assertEquals("Bad olongValue1", acc1.olongValue1, acc2.olongValue1); 143 assertEquals("Bad olongValue2", acc1.olongValue2, acc2.olongValue2); 144 145 assertEquals("Bad floatValue1", acc1.floatValue1, acc2.floatValue1, (float) 0); 146 assertEquals("Bad floatValue2", acc1.floatValue2, acc2.floatValue2, (float) 0); 147 assertEquals("Bad ofloatValue1", acc1.ofloatValue1, acc2.ofloatValue1); 148 assertEquals("Bad ofloatValue2", acc1.ofloatValue2, acc2.ofloatValue2); 149 150 assertEquals("Bad doubleValue1", acc1.doubleValue1, acc2.doubleValue1, (double) 0); 151 assertEquals("Bad doubleValue2", acc1.doubleValue2, acc2.doubleValue2, (double) 0); 152 assertEquals("Bad odoubleValue1", acc1.odoubleValue1, acc2.odoubleValue1); 153 assertEquals("Bad odoubleValue2", acc1.odoubleValue2, acc2.odoubleValue2); 154 155 assertEqual("chararrayValue1 ", acc1.chararrayValue1, acc2.chararrayValue1); 156 assertEqual("chararrayValue2 ", acc1.chararrayValue2, acc2.chararrayValue2); 157 assertEqual("bytearrayValue1 ", acc1.bytearrayValue1, acc2.bytearrayValue1); 158 assertEqual("bytearrayValue2 ", acc1.bytearrayValue2, acc2.bytearrayValue2); 159 160 assertEquals("Bad stringValue1", acc1.stringValue1, acc2.stringValue1); 161 assertEquals("Bad stringValue1", acc1.stringValue2, acc2.stringValue2); 162 163 if (acc1.dateValue1 == null) { 164 assertNull("dateValue1 must be null", acc2.dateValue1); 165 } else { 166 assertNotNull("dateValue1 must not be null", acc2.dateValue1); 167 assertEquals("Bad dateValue1", 168 acc1.dateValue1.getTime(), acc2.dateValue1.getTime()); 169 } 170 if (acc1.dateValue2 == null) { 171 assertNull("dateValue2 must be null", acc2.dateValue2); 172 } else { 173 assertNotNull("dateValue2 must not be null", acc2.dateValue2); 174 assertEquals("Bad dateValue2", 175 acc1.dateValue2.getTime(), acc2.dateValue2.getTime()); 176 } 177 } 178 } 179 | Popular Tags |