KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > speedo > runtime > basic > TestSqlClasses


1 /**
2  * Copyright (C) 2001-2004 France Telecom R&D
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * 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  */

18 package org.objectweb.speedo.runtime.basic;
19
20 import org.objectweb.speedo.SpeedoTestHelper;
21 import org.objectweb.speedo.pobjects.basic.SqlClasses;
22
23 import javax.jdo.PersistenceManager;
24
25 import junit.framework.Assert;
26
27 /**
28  *
29  * @author S.Chassande-Barrioz
30  */

31 public class TestSqlClasses extends SpeedoTestHelper {
32
33     public TestSqlClasses(String JavaDoc s) {
34         super(s);
35     }
36
37     protected String JavaDoc getLoggerName() {
38         return LOG_NAME + ".rt.basic.TestSqlClasses";
39     }
40
41     public void test1() {
42         SqlClasses sql = new SqlClasses(1);
43         java.sql.Date JavaDoc d = new java.sql.Date JavaDoc(12345);
44         java.sql.Time JavaDoc t = new java.sql.Time JavaDoc(123450);
45         java.sql.Timestamp JavaDoc ts = new java.sql.Timestamp JavaDoc(1234500);
46         sql.setDate(d);
47         sql.setTime(t);
48         sql.setTimestamp(ts);
49         PersistenceManager pm = pmf.getPersistenceManager();
50         pm.makePersistent(sql);
51         Object JavaDoc sId = pm.getObjectId(sql);
52         Assert.assertNotNull("null object identifier", sId);
53         pm.close();
54         sql = null;
55         pm = pmf.getPersistenceManager();
56         sql = (SqlClasses) pm.getObjectById(sId, true);
57         Assert.assertNotNull("null instance returned by getObjectById", 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.getTimestamp());
61         pm.currentTransaction().begin();
62         pm.deletePersistent(sql);
63         pm.currentTransaction().commit();
64         pm.close();
65     }
66 }
67
Popular Tags