KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jorm > runtime > gcbasictypeelem > TestGcBasicTypeElem


1 /**
2  * JORM: an implementation of a generic mapping system for persistent Java
3  * objects. Two mapping are supported: to RDBMS and to binary files.
4  * Copyright (C) 2001-2003 France Telecom R&D - INRIA
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  * Contact: jorm-team@objectweb.org
21  *
22  */

23
24 package org.objectweb.jorm.runtime.gcbasictypeelem;
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 import org.objectweb.jorm.api.PBinding;
32 import org.objectweb.jorm.type.api.PType;
33 import org.objectweb.util.monolog.api.BasicLevel;
34
35 import java.util.Map JavaDoc;
36 import java.util.HashMap JavaDoc;
37
38 /**
39  * @author P. Dechamboux
40  */

41 public class TestGcBasicTypeElem extends TestRuntimeHelper {
42     private final static String JavaDoc LOGGER_NAME
43             = "test.org.objectweb.jorm.gcbasictypeelem";
44     private Map JavaDoc cn2Binder = new HashMap JavaDoc();
45
46     public TestGcBasicTypeElem(String JavaDoc name) throws Exception JavaDoc {
47         super(name);
48     }
49
50     protected String JavaDoc getLoggerName() {
51         return LOGGER_NAME;
52     }
53
54     protected PBinder getBinder(String JavaDoc className) throws Exception JavaDoc {
55         try {
56             PBinder pb = (PBinder) cn2Binder.get(className);
57             if (pb == null) {
58                 pb = new BasidBinder(mapper, className, PClassMapping.CLEANUP_REMOVEALL);
59                 cn2Binder.put(className, pb);
60             }
61             return pb;
62         } catch (PException e) {
63             Exception JavaDoc current = e;
64             while (current instanceof PException
65                     && ((PException) current).getNestedException() != null) {
66                 current = ((PException) current).getNestedException();
67             }
68             throw current;
69         }
70     }
71
72     // Definition of test units
73

74     public void commonTestSet(GcBasicTypeAccessor gcacc1,
75                               String JavaDoc classname,
76                               String JavaDoc loggername) throws Exception JavaDoc {
77         GcBasicTypeAccessor gcacc2 = new GcBasicTypeAccessor(
78                 gcacc1.getTypeCode(), gcacc1.paGetNbElem());
79         changeLogger(loggername);
80         logger.log(BasicLevel.DEBUG, "export the genClassRef");
81         PBinding bind = export(classname, null);
82         logger.log(BasicLevel.DEBUG, "export the genClass");
83         PBinding gcbind = export(classname + "/mygc", null);
84         GcRefAccessor acc1 = new GcRefAccessor(gcbind.getPName());
85         GcRefAccessor acc2 = new GcRefAccessor(null);
86         logger.log(BasicLevel.DEBUG, "write and read the genClassRef");
87         writeRead(bind, acc1, acc2);
88         assertEquals("Cannot read the GC reference", acc1, acc2);
89         logger.log(BasicLevel.DEBUG, "write and read the genClass");
90         writeRead(gcbind, gcacc1, gcacc2);
91         assertEquals("Cannot read the boolean GC value", gcacc1, gcacc2);
92         logger.log(BasicLevel.DEBUG, "unexport GenClassRef");
93         unexport(bind, acc1);
94         logger.log(BasicLevel.DEBUG, "unexport GenClass");
95         unexport(gcbind, gcacc1);
96     }
97
98     // ============================= boolean =============================== //
99

100     private final static String JavaDoc CNBOOLEAN
101             = "org.objectweb.jorm.pobject.gcbasictypeelem.BooleanSet";
102
103     public void commonTestBooleanSet(GcBasicTypeAccessor gcacc1)
104             throws Exception JavaDoc {
105         commonTestSet(gcacc1, CNBOOLEAN, LOGGER_NAME + ".boolean");
106     }
107     public void testBooleanSetEmpty() throws Exception JavaDoc {
108         commonTestBooleanSet(
109                 new GcBasicTypeAccessor(PType.TYPECODE_BOOLEAN, 0));
110     }
111     public void testBooleanSetOne() throws Exception JavaDoc {
112         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_BOOLEAN, 1);
113         gcacc1.setElem(0, true);
114         commonTestBooleanSet(gcacc1);
115     }
116     public void testBooleanSetSeveral() throws Exception JavaDoc {
117         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_BOOLEAN, 2);
118         gcacc1.setElem(0, false);
119         gcacc1.setElem(1, true);
120         commonTestBooleanSet(gcacc1);
121     }
122
123     // ============================= Boolean =============================== //
124

125     private final static String JavaDoc CNOBOOLEAN
126             = "org.objectweb.jorm.pobject.gcbasictypeelem.ObooleanSet";
127
128     public void commonTestObooleanSet(GcBasicTypeAccessor gcacc1)
129             throws Exception JavaDoc {
130         commonTestSet(gcacc1, CNOBOOLEAN, LOGGER_NAME + ".oboolean");
131     }
132     public void testObooleanSetEmpty() throws Exception JavaDoc {
133         commonTestObooleanSet(
134                 new GcBasicTypeAccessor(PType.TYPECODE_OBJBOOLEAN, 0));
135     }
136     public void testObooleanSetOne() throws Exception JavaDoc {
137         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJBOOLEAN, 1);
138         gcacc1.setElem(0, Boolean.TRUE);
139         commonTestObooleanSet(gcacc1);
140     }
141     public void __testObooleanSetNull() throws Exception JavaDoc {
142         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJBOOLEAN, 1);
143         gcacc1.setElem(0, null);
144         commonTestObooleanSet(gcacc1);
145     }
146     public void testObooleanSetSeveral() throws Exception JavaDoc {
147         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJBOOLEAN, 2);
148         gcacc1.setElem(0, Boolean.FALSE);
149         gcacc1.setElem(1, Boolean.TRUE);
150         commonTestObooleanSet(gcacc1);
151     }
152     // ============================= byte =============================== //
153

154     private final static String JavaDoc CNBYTE
155             = "org.objectweb.jorm.pobject.gcbasictypeelem.ByteSet";
156
157     public void commonTestByteSet(GcBasicTypeAccessor gcacc1)
158             throws Exception JavaDoc {
159         commonTestSet(gcacc1, CNBYTE, LOGGER_NAME + ".byte");
160     }
161     public void testByteSetEmpty() throws Exception JavaDoc {
162         commonTestByteSet(
163                 new GcBasicTypeAccessor(PType.TYPECODE_BYTE, 0));
164     }
165     public void testByteSetOne() throws Exception JavaDoc {
166         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_BYTE, 1);
167         gcacc1.setElem(0, (byte) 23);
168         commonTestByteSet(gcacc1);
169     }
170     public void testByteSetSeveral() throws Exception JavaDoc {
171         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_BYTE, 2);
172         gcacc1.setElem(0, (byte) 45);
173         gcacc1.setElem(1, (byte) 67);
174         commonTestByteSet(gcacc1);
175     }
176
177     // ============================= Byte =============================== //
178

179     private final static String JavaDoc CNOBYTE
180             = "org.objectweb.jorm.pobject.gcbasictypeelem.ObyteSet";
181
182     public void commonTestObyteSet(GcBasicTypeAccessor gcacc1)
183             throws Exception JavaDoc {
184         commonTestSet(gcacc1, CNOBYTE, LOGGER_NAME + ".obyte");
185     }
186     public void testObyteSetEmpty() throws Exception JavaDoc {
187         commonTestObyteSet(
188                 new GcBasicTypeAccessor(PType.TYPECODE_OBJBYTE, 0));
189     }
190     public void testObyteSetOne() throws Exception JavaDoc {
191         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJBYTE, 1);
192         gcacc1.setElem(0, new Byte JavaDoc((byte)23));
193         commonTestObyteSet(gcacc1);
194     }
195     public void __testObyteSetNull() throws Exception JavaDoc {
196         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJBYTE, 1);
197         gcacc1.setElem(0, null);
198         commonTestObyteSet(gcacc1);
199     }
200     public void testObyteSetSeveral() throws Exception JavaDoc {
201         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJBYTE, 2);
202         gcacc1.setElem(0, new Byte JavaDoc((byte) 45));
203         gcacc1.setElem(1, new Byte JavaDoc((byte) 67));
204         commonTestObyteSet(gcacc1);
205     }
206     // ============================= short =============================== //
207

208     private final static String JavaDoc CNSHORT
209             = "org.objectweb.jorm.pobject.gcbasictypeelem.ShortSet";
210
211     public void commonTestShortSet(GcBasicTypeAccessor gcacc1)
212             throws Exception JavaDoc {
213         commonTestSet(gcacc1, CNSHORT, LOGGER_NAME + ".short");
214     }
215     public void testShortSetEmpty() throws Exception JavaDoc {
216         commonTestShortSet(
217                 new GcBasicTypeAccessor(PType.TYPECODE_SHORT, 0));
218     }
219     public void testShortSetOne() throws Exception JavaDoc {
220         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_SHORT, 1);
221         gcacc1.setElem(0, (short) 23);
222         commonTestShortSet(gcacc1);
223     }
224     public void testShortSetSeveral() throws Exception JavaDoc {
225         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_SHORT, 2);
226         gcacc1.setElem(0, (short) 45);
227         gcacc1.setElem(1, (short) 67);
228         commonTestShortSet(gcacc1);
229     }
230
231     // ============================= Short =============================== //
232

233     private final static String JavaDoc CNOSHORT
234             = "org.objectweb.jorm.pobject.gcbasictypeelem.OshortSet";
235
236     public void commonTestOshortSet(GcBasicTypeAccessor gcacc1)
237             throws Exception JavaDoc {
238         commonTestSet(gcacc1, CNOSHORT, LOGGER_NAME + ".oshort");
239     }
240     public void testOshortSetEmpty() throws Exception JavaDoc {
241         commonTestOshortSet(
242                 new GcBasicTypeAccessor(PType.TYPECODE_OBJSHORT, 0));
243     }
244     public void testOshortSetOne() throws Exception JavaDoc {
245         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJSHORT, 1);
246         gcacc1.setElem(0, new Short JavaDoc((short)23));
247         commonTestOshortSet(gcacc1);
248     }
249     public void __testOshortSetNull() throws Exception JavaDoc {
250         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJSHORT, 1);
251         gcacc1.setElem(0, null);
252         commonTestOshortSet(gcacc1);
253     }
254     public void testOshortSetSeveral() throws Exception JavaDoc {
255         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJSHORT, 2);
256         gcacc1.setElem(0, new Short JavaDoc((short) 45));
257         gcacc1.setElem(1, new Short JavaDoc((short) 67));
258         commonTestOshortSet(gcacc1);
259     }
260     // ============================= int =============================== //
261

262     private final static String JavaDoc CNINT
263             = "org.objectweb.jorm.pobject.gcbasictypeelem.IntSet";
264
265     public void commonTestIntSet(GcBasicTypeAccessor gcacc1)
266             throws Exception JavaDoc {
267         commonTestSet(gcacc1, CNINT, LOGGER_NAME + ".int");
268     }
269     public void testIntSetEmpty() throws Exception JavaDoc {
270         commonTestIntSet(
271                 new GcBasicTypeAccessor(PType.TYPECODE_INT, 0));
272     }
273     public void testIntSetOne() throws Exception JavaDoc {
274         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_INT, 1);
275         gcacc1.setElem(0, 23);
276         commonTestIntSet(gcacc1);
277     }
278     public void testIntSetSeveral() throws Exception JavaDoc {
279         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_INT, 2);
280         gcacc1.setElem(0, 45);
281         gcacc1.setElem(1, 67);
282         commonTestIntSet(gcacc1);
283     }
284
285     // ============================= Int =============================== //
286

287     private final static String JavaDoc CNOINT
288             = "org.objectweb.jorm.pobject.gcbasictypeelem.OintSet";
289
290     public void commonTestOintSet(GcBasicTypeAccessor gcacc1)
291             throws Exception JavaDoc {
292         commonTestSet(gcacc1, CNOINT, LOGGER_NAME + ".oint");
293     }
294     public void testOintSetEmpty() throws Exception JavaDoc {
295         commonTestOintSet(
296                 new GcBasicTypeAccessor(PType.TYPECODE_OBJINT, 0));
297     }
298     public void testOintSetOne() throws Exception JavaDoc {
299         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJINT, 1);
300         gcacc1.setElem(0, new Integer JavaDoc(23));
301         commonTestOintSet(gcacc1);
302     }
303     public void __testOintSetNull() throws Exception JavaDoc {
304         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJINT, 1);
305         gcacc1.setElem(0, null);
306         commonTestOintSet(gcacc1);
307     }
308     public void testOintSetSeveral() throws Exception JavaDoc {
309         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJINT, 2);
310         gcacc1.setElem(0, new Integer JavaDoc(45));
311         gcacc1.setElem(1, new Integer JavaDoc(67));
312         commonTestOintSet(gcacc1);
313     }
314     // ============================= long =============================== //
315

316     private final static String JavaDoc CNLONG
317             = "org.objectweb.jorm.pobject.gcbasictypeelem.LongSet";
318
319     public void commonTestLongSet(GcBasicTypeAccessor gcacc1)
320             throws Exception JavaDoc {
321         commonTestSet(gcacc1, CNLONG, LOGGER_NAME + ".long");
322     }
323     public void testLongSetEmpty() throws Exception JavaDoc {
324         commonTestLongSet(
325                 new GcBasicTypeAccessor(PType.TYPECODE_LONG, 0));
326     }
327     public void testLongSetOne() throws Exception JavaDoc {
328         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_LONG, 1);
329         gcacc1.setElem(0, (long) 23);
330         commonTestLongSet(gcacc1);
331     }
332     public void testLongSetSeveral() throws Exception JavaDoc {
333         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_LONG, 2);
334         gcacc1.setElem(0, (long) 45);
335         gcacc1.setElem(1, (long) 67);
336         commonTestLongSet(gcacc1);
337     }
338
339     // ============================= Long =============================== //
340

341     private final static String JavaDoc CNOLONG
342             = "org.objectweb.jorm.pobject.gcbasictypeelem.OlongSet";
343
344     public void commonTestOlongSet(GcBasicTypeAccessor gcacc1)
345             throws Exception JavaDoc {
346         commonTestSet(gcacc1, CNOLONG, LOGGER_NAME + ".olong");
347     }
348     public void testOlongSetEmpty() throws Exception JavaDoc {
349         commonTestOlongSet(
350                 new GcBasicTypeAccessor(PType.TYPECODE_OBJLONG, 0));
351     }
352     public void testOlongSetOne() throws Exception JavaDoc {
353         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJLONG, 1);
354         gcacc1.setElem(0, new Long JavaDoc((long)23));
355         commonTestOlongSet(gcacc1);
356     }
357     public void __testOlongSetNull() throws Exception JavaDoc {
358         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJLONG, 1);
359         gcacc1.setElem(0, null);
360         commonTestOlongSet(gcacc1);
361     }
362     public void testOlongSetSeveral() throws Exception JavaDoc {
363         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJLONG, 2);
364         gcacc1.setElem(0, new Long JavaDoc((long) 45));
365         gcacc1.setElem(1, new Long JavaDoc((long) 67));
366         commonTestOlongSet(gcacc1);
367     }
368     // ============================= float =============================== //
369

370     private final static String JavaDoc CNFLOAT
371             = "org.objectweb.jorm.pobject.gcbasictypeelem.FloatSet";
372
373     public void commonTestFloatSet(GcBasicTypeAccessor gcacc1)
374             throws Exception JavaDoc {
375         commonTestSet(gcacc1, CNFLOAT, LOGGER_NAME + ".float");
376     }
377     public void testFloatSetEmpty() throws Exception JavaDoc {
378         commonTestFloatSet(
379                 new GcBasicTypeAccessor(PType.TYPECODE_FLOAT, 0));
380     }
381     public void testFloatSetOne() throws Exception JavaDoc {
382         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_FLOAT, 1);
383         gcacc1.setElem(0, (float) 23);
384         commonTestFloatSet(gcacc1);
385     }
386     public void testFloatSetSeveral() throws Exception JavaDoc {
387         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_FLOAT, 2);
388         gcacc1.setElem(0, (float) 45);
389         gcacc1.setElem(1, (float) 67);
390         commonTestFloatSet(gcacc1);
391     }
392
393     // ============================= Float =============================== //
394

395     private final static String JavaDoc CNOFLOAT
396             = "org.objectweb.jorm.pobject.gcbasictypeelem.OfloatSet";
397
398     public void commonTestOfloatSet(GcBasicTypeAccessor gcacc1)
399             throws Exception JavaDoc {
400         commonTestSet(gcacc1, CNOFLOAT, LOGGER_NAME + ".ofloat");
401     }
402     public void testOfloatSetEmpty() throws Exception JavaDoc {
403         commonTestOfloatSet(
404                 new GcBasicTypeAccessor(PType.TYPECODE_OBJFLOAT, 0));
405     }
406     public void testOfloatSetOne() throws Exception JavaDoc {
407         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJFLOAT, 1);
408         gcacc1.setElem(0, new Float JavaDoc((float)23));
409         commonTestOfloatSet(gcacc1);
410     }
411     public void __testOfloatSetNull() throws Exception JavaDoc {
412         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJFLOAT, 1);
413         gcacc1.setElem(0, null);
414         commonTestOfloatSet(gcacc1);
415     }
416     public void testOfloatSetSeveral() throws Exception JavaDoc {
417         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJFLOAT, 2);
418         gcacc1.setElem(0, new Float JavaDoc((float) 45));
419         gcacc1.setElem(1, new Float JavaDoc((float) 67));
420         commonTestOfloatSet(gcacc1);
421     }
422     // ============================= double =============================== //
423

424     private final static String JavaDoc CNDOUBLE
425             = "org.objectweb.jorm.pobject.gcbasictypeelem.DoubleSet";
426
427     public void commonTestDoubleSet(GcBasicTypeAccessor gcacc1)
428             throws Exception JavaDoc {
429         commonTestSet(gcacc1, CNDOUBLE, LOGGER_NAME + ".double");
430     }
431     public void testDoubleSetEmpty() throws Exception JavaDoc {
432         commonTestDoubleSet(
433                 new GcBasicTypeAccessor(PType.TYPECODE_DOUBLE, 0));
434     }
435     public void testDoubleSetOne() throws Exception JavaDoc {
436         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_DOUBLE, 1);
437         gcacc1.setElem(0, (double) 23);
438         commonTestDoubleSet(gcacc1);
439     }
440     public void testDoubleSetSeveral() throws Exception JavaDoc {
441         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_DOUBLE, 2);
442         gcacc1.setElem(0, (double) 45);
443         gcacc1.setElem(1, (double) 67);
444         commonTestDoubleSet(gcacc1);
445     }
446
447     // ============================= Double =============================== //
448

449     private final static String JavaDoc CNODOUBLE
450             = "org.objectweb.jorm.pobject.gcbasictypeelem.OdoubleSet";
451
452     public void commonTestOdoubleSet(GcBasicTypeAccessor gcacc1)
453             throws Exception JavaDoc {
454         commonTestSet(gcacc1, CNODOUBLE, LOGGER_NAME + ".odouble");
455     }
456     public void testOdoubleSetEmpty() throws Exception JavaDoc {
457         commonTestOdoubleSet(
458                 new GcBasicTypeAccessor(PType.TYPECODE_OBJDOUBLE, 0));
459     }
460     public void testOdoubleSetOne() throws Exception JavaDoc {
461         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJDOUBLE, 1);
462         gcacc1.setElem(0, new Double JavaDoc((double)23));
463         commonTestOdoubleSet(gcacc1);
464     }
465     public void __testOdoubleSetNull() throws Exception JavaDoc {
466         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJDOUBLE, 1);
467         gcacc1.setElem(0, null);
468         commonTestOdoubleSet(gcacc1);
469     }
470     public void testOdoubleSetSeveral() throws Exception JavaDoc {
471         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJDOUBLE, 2);
472         gcacc1.setElem(0, new Double JavaDoc((double) 45));
473         gcacc1.setElem(1, new Double JavaDoc((double) 67));
474         commonTestOdoubleSet(gcacc1);
475     }
476     // ============================= char =============================== //
477

478     private final static String JavaDoc CNCHAR
479             = "org.objectweb.jorm.pobject.gcbasictypeelem.CharSet";
480
481     public void commonTestCharSet(GcBasicTypeAccessor gcacc1)
482             throws Exception JavaDoc {
483         commonTestSet(gcacc1, CNCHAR, LOGGER_NAME + ".char");
484     }
485     public void testCharSetEmpty() throws Exception JavaDoc {
486         commonTestCharSet(
487                 new GcBasicTypeAccessor(PType.TYPECODE_CHAR, 0));
488     }
489     public void testCharSetOne() throws Exception JavaDoc {
490         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_CHAR, 1);
491         gcacc1.setElem(0, 'e');
492         commonTestCharSet(gcacc1);
493     }
494     public void testCharSetSeveral() throws Exception JavaDoc {
495         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_CHAR, 2);
496         gcacc1.setElem(0, 'a');
497         gcacc1.setElem(1, 'b');
498         commonTestCharSet(gcacc1);
499     }
500
501     // ============================= Char =============================== //
502

503     private final static String JavaDoc CNOCHAR
504             = "org.objectweb.jorm.pobject.gcbasictypeelem.OcharSet";
505
506     public void commonTestOcharSet(GcBasicTypeAccessor gcacc1)
507             throws Exception JavaDoc {
508         commonTestSet(gcacc1, CNOCHAR, LOGGER_NAME + ".ochar");
509     }
510     public void testOcharSetEmpty() throws Exception JavaDoc {
511         commonTestOcharSet(
512                 new GcBasicTypeAccessor(PType.TYPECODE_OBJCHAR, 0));
513     }
514     public void testOcharSetOne() throws Exception JavaDoc {
515         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJCHAR, 1);
516         gcacc1.setElem(0, new Character JavaDoc('e'));
517         commonTestOcharSet(gcacc1);
518     }
519     public void __testOcharSetNull() throws Exception JavaDoc {
520         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJCHAR, 1);
521         gcacc1.setElem(0, null);
522         commonTestOcharSet(gcacc1);
523     }
524     public void testOcharSetSeveral() throws Exception JavaDoc {
525         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJCHAR, 2);
526         gcacc1.setElem(0, new Character JavaDoc('a'));
527         gcacc1.setElem(1, new Character JavaDoc('b'));
528         commonTestOcharSet(gcacc1);
529     }
530     // ============================= String =============================== //
531

532     private final static String JavaDoc CNSTRING
533             = "org.objectweb.jorm.pobject.gcbasictypeelem.StringSet";
534
535     public void commonTestStringSet(GcBasicTypeAccessor gcacc1)
536             throws Exception JavaDoc {
537         commonTestSet(gcacc1, CNSTRING, LOGGER_NAME + ".string");
538     }
539     public void testStringSetEmpty() throws Exception JavaDoc {
540         commonTestStringSet(
541                 new GcBasicTypeAccessor(PType.TYPECODE_STRING, 0));
542     }
543     public void testStringSetOne() throws Exception JavaDoc {
544         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_STRING, 1);
545         gcacc1.setElem(0, new String JavaDoc("azerty"));
546         commonTestStringSet(gcacc1);
547     }
548     public void __testStringSetNull() throws Exception JavaDoc {
549         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_STRING, 1);
550         gcacc1.setElem(0, null);
551         commonTestStringSet(gcacc1);
552     }
553     public void testStringSetSeveral() throws Exception JavaDoc {
554         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_STRING, 2);
555         gcacc1.setElem(0, new String JavaDoc("qsdfgh"));
556         gcacc1.setElem(1, new String JavaDoc("wxcvbn"));
557         commonTestStringSet(gcacc1);
558     }
559
560     // ============================= Date =============================== //
561

562     private final static String JavaDoc CNDATE
563             = "org.objectweb.jorm.pobject.gcbasictypeelem.DateSet";
564
565     public void commonTestDateSet(GcBasicTypeAccessor gcacc1)
566             throws Exception JavaDoc {
567         commonTestSet(gcacc1, CNDATE, LOGGER_NAME + ".date");
568     }
569     public void testDateSetEmpty() throws Exception JavaDoc {
570         commonTestDateSet(
571                 new GcBasicTypeAccessor(PType.TYPECODE_DATE, 0));
572     }
573     public void testDateSetOne() throws Exception JavaDoc {
574         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_DATE, 1);
575         gcacc1.setElem(0, getTime());
576         commonTestDateSet(gcacc1);
577     }
578     public void __testDateSetNull() throws Exception JavaDoc {
579         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_DATE, 1);
580         gcacc1.setElem(0, null);
581         commonTestDateSet(gcacc1);
582     }
583     public void testDateSetSeveral() throws Exception JavaDoc {
584         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_DATE, 2);
585         gcacc1.setElem(0, getTime());
586         Thread.sleep(1000);
587         gcacc1.setElem(1, getTime());
588         commonTestDateSet(gcacc1);
589     }
590
591     // ============================= byte[] =============================== //
592

593     private final static String JavaDoc CNBYTEARRAY
594             = "org.objectweb.jorm.pobject.gcbasictypeelem.BytearraySet";
595
596     public void commonTestByteArraySet(GcBasicTypeAccessor gcacc1)
597             throws Exception JavaDoc {
598         commonTestSet(gcacc1, CNBYTEARRAY, LOGGER_NAME + ".bytearray");
599     }
600     public void testByteArraySetEmpty() throws Exception JavaDoc {
601         commonTestByteArraySet(
602                 new GcBasicTypeAccessor(PType.TYPECODE_BYTEARRAY, 0));
603     }
604     public void testByteArraySetOne() throws Exception JavaDoc {
605         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_BYTEARRAY, 1);
606         gcacc1.setElem(0, new byte[]{1,2,3});
607         commonTestByteArraySet(gcacc1);
608     }
609     public void __testByteArraySetNull() throws Exception JavaDoc {
610         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_BYTEARRAY, 1);
611         gcacc1.setElem(0, null);
612         commonTestByteArraySet(gcacc1);
613     }
614     public void testByteArraySetSeveral() throws Exception JavaDoc {
615         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_BYTEARRAY, 2);
616         gcacc1.setElem(0, new byte[]{4,5,6});
617         gcacc1.setElem(1, new byte[]{7,8,9});
618         commonTestByteArraySet(gcacc1);
619     }
620
621     // ============================= char[] =============================== //
622

623     private final static String JavaDoc CNCHARARRAY
624             = "org.objectweb.jorm.pobject.gcbasictypeelem.ChararraySet";
625
626     public void commonTestCharArraySet(GcBasicTypeAccessor gcacc1)
627             throws Exception JavaDoc {
628         commonTestSet(gcacc1, CNCHARARRAY, LOGGER_NAME + ".chararray");
629     }
630     public void testCharArraySetEmpty() throws Exception JavaDoc {
631         commonTestCharArraySet(
632                 new GcBasicTypeAccessor(PType.TYPECODE_CHARARRAY, 0));
633     }
634     public void testCharArraySetOne() throws Exception JavaDoc {
635         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_CHARARRAY, 1);
636         gcacc1.setElem(0, new char[]{'w','x','c','v','b','n'});
637         commonTestCharArraySet(gcacc1);
638     }
639     public void __testCharArraySetNull() throws Exception JavaDoc {
640         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_CHARARRAY, 1);
641         gcacc1.setElem(0, null);
642         commonTestCharArraySet(gcacc1);
643     }
644     public void testCharArraySetSeveral() throws Exception JavaDoc {
645         GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_CHARARRAY, 2);
646         gcacc1.setElem(0, new char[]{'a','z','e','r','t','y'});
647         gcacc1.setElem(1, new char[]{'q','s','d','f','g','h'});
648         commonTestCharArraySet(gcacc1);
649     }
650 }
651
Popular Tags