1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package org.apache.jdo.tck.api.persistencemanager.flags; 19 20 import javax.jdo.PersistenceManager; 21 import javax.jdo.Transaction; 22 23 import org.apache.jdo.tck.pc.mylib.PCPoint; 24 import org.apache.jdo.tck.util.BatchTestRunner; 25 import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; 26 27 /** 28 *<B>Title:</B> Set IgnoreCache To True 29 *<BR> 30 *<B>Keywords:cache 31 *<BR> 32 *<B>Assertion ID:</B> A12.5.3-2. 33 *<BR> 34 *<B>Assertion Description: </B> 35 The PersistenceManager.setIgnoreCache method called with a value of true is a hint to the 36 query engine that the user expects queries to be optimized to return approximate results by ignoring changed values in the 37 cache. This is not testable, except to see whether the get/set works. 38 39 40 */ 41 42 public class SetIgnoreCacheToTrue extends PersistenceManagerTest { 43 44 /** */ 45 private static final String ASSERTION_FAILED = 46 "Assertion A12.5.3-2 (SetIgnoreCacheToTrue) failed: "; 47 48 /** 49 * The <code>main</code> is called when the class 50 * is directly executed from the command line. 51 * @param args The arguments passed to the program. 52 */ 53 public static void main(String[] args) { 54 BatchTestRunner.run(SetIgnoreCacheToTrue.class); 55 } 56 57 /** */ 58 public void test() { 59 pm = getPM(); 60 61 runTestSetIgnoreCacheToTrue(pm); 62 63 pm.close(); 64 pm = null; 65 } 66 67 /** */ 68 public void runTestSetIgnoreCacheToTrue(PersistenceManager pm) { 69 Transaction tx = pm.currentTransaction(); 70 try { 71 PCPoint p1 = new PCPoint(); 72 tx.begin(); 73 pm.setIgnoreCache(true); 74 if (!pm.getIgnoreCache()) { 75 fail(ASSERTION_FAILED, 76 "pm.getIgnoreCache() should return true after setting the flag to true."); 77 } 78 tx.commit(); 79 tx = null; 80 } 81 finally { 82 if ((tx != null) && tx.isActive()) 83 tx.rollback(); 84 } 85 } 86 }