01: /**
02: * Copyright (C) 2001-2004 France Telecom R&D
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */package org.objectweb.speedo.runtime.basic;
18:
19: import org.objectweb.speedo.SpeedoTestHelper;
20: import org.objectweb.speedo.pobjects.basic.SqlClasses;
21:
22: import javax.jdo.PersistenceManager;
23:
24: import junit.framework.Assert;
25:
26: /**
27: *
28: * @author S.Chassande-Barrioz
29: */
30: public class TestSqlClasses extends SpeedoTestHelper {
31:
32: public TestSqlClasses(String s) {
33: super (s);
34: }
35:
36: protected String getLoggerName() {
37: return LOG_NAME + ".rt.basic.TestSqlClasses";
38: }
39:
40: public void test1() {
41: SqlClasses sql = new SqlClasses(1);
42: java.sql.Date d = new java.sql.Date(12345);
43: java.sql.Time t = new java.sql.Time(123450);
44: java.sql.Timestamp ts = new java.sql.Timestamp(1234500);
45: sql.setDate(d);
46: sql.setTime(t);
47: sql.setTimestamp(ts);
48: PersistenceManager pm = pmf.getPersistenceManager();
49: pm.makePersistent(sql);
50: Object sId = pm.getObjectId(sql);
51: Assert.assertNotNull("null object identifier", sId);
52: pm.close();
53: sql = null;
54: pm = pmf.getPersistenceManager();
55: sql = (SqlClasses) pm.getObjectById(sId, true);
56: Assert.assertNotNull("null instance returned by getObjectById",
57: sql);
58: Assert.assertEquals("Bad date value", d, sql.getDate());
59: Assert.assertEquals("Bad time value", t, sql.getTime());
60: Assert.assertEquals("Bad timestamp value", ts, sql
61: .getTimestamp());
62: pm.currentTransaction().begin();
63: pm.deletePersistent(sql);
64: pm.currentTransaction().commit();
65: pm.close();
66: }
67: }
|