1 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 31 public class TestSqlClasses extends SpeedoTestHelper { 32 33 public TestSqlClasses(String s) { 34 super(s); 35 } 36 37 protected String getLoggerName() { 38 return LOG_NAME + ".rt.basic.TestSqlClasses"; 39 } 40 41 public void test1() { 42 SqlClasses sql = new SqlClasses(1); 43 java.sql.Date d = new java.sql.Date (12345); 44 java.sql.Time t = new java.sql.Time (123450); 45 java.sql.Timestamp ts = new java.sql.Timestamp (1234500); 46 sql.setDate(d); 47 sql.setTime(t); 48 sql.setTimestamp(ts); 49 PersistenceManager pm = pmf.getPersistenceManager(); 50 pm.makePersistent(sql); 51 Object 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 |