1 18 package org.objectweb.speedo.runtime.tck; 19 20 import java.util.ArrayList ; 21 import java.util.Collection ; 22 23 import javax.jdo.JDOHelper; 24 import javax.jdo.PersistenceManager; 25 import javax.jdo.Query; 26 import javax.jdo.Transaction; 27 28 import junit.framework.Assert; 29 30 import org.objectweb.speedo.SpeedoTestHelper; 31 import org.objectweb.speedo.pobjects.basic.BasicA; 32 import org.objectweb.util.monolog.api.BasicLevel; 33 34 35 36 public class QueryTck extends SpeedoTestHelper { 37 38 private PersistenceManager pm; 39 private PersistenceManager pm1; 40 private Transaction transaction; 41 42 43 public QueryTck(String s) { 44 super(s); 45 pm = pmf.getPersistenceManager(); 46 } 47 48 protected String getLoggerName() { 49 return LOG_NAME + ".rt.tck.QueryTck"; 50 } 51 52 public void testGetObjectId() { 53 logger.log(BasicLevel.INFO, "testGetObjectId"); 54 try { 55 Transaction tx = pm.currentTransaction(); 56 tx.begin(); 57 BasicA nba1 = new BasicA(); 58 pm.makePersistent(nba1); 59 60 Object p2 = JDOHelper.getObjectId(nba1); 61 tx.commit(); 62 63 Assert.assertNotNull("bad getObjectId value", p2); 64 65 } catch (Exception ex) { 66 logger.log(BasicLevel.ERROR, "Unexception caught in testGetObjectId", ex); 67 fail(ex.getMessage()); 68 } 69 70 } 71 72 public void testDeclareVariables() { 73 logger.log(BasicLevel.INFO, "testDeclareVariables"); 74 Transaction tx = pm.currentTransaction(); 75 tx.begin(); 76 77 Query query = pm.newQuery(); 78 79 if(query == null) { 80 logger.log(BasicLevel.ERROR, "query is null"); 81 } 82 83 query.setClass(BasicA.class); 84 query.setCandidates(pm.getExtent(BasicA.class, false)); 85 query.declareParameters("Integer param1, Integer param2"); 86 query.setFilter("f1 == param1 && f2 == param2"); 87 88 Object results = query.execute(new String (""), new java.lang.Integer (0)); 89 90 Collection expected = new ArrayList (); 92 Object p3 = new BasicA(); 93 expected.add(p3); 94 106 tx.commit(); 107 108 } 109 } 110 111 | Popular Tags |