Save This Page
Home » jdo2-tck-2.3-ea-src » org.apache.jdo.tck.api.persistencemanagerfactory » [javadoc | source]
    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.persistencemanagerfactory;
   19   
   20   import javax.jdo.PersistenceManagerFactory;
   21   
   22   import org.apache.jdo.tck.JDO_Test;
   23   import org.apache.jdo.tck.util.BatchTestRunner;
   24   
   25   /**
   26    *<B>Title:</B>Set IgnoreCache of persistencemanagerfactory  
   27    *<BR>
   28    *<B>Keywords:</B> persistencemanagerfactory
   29    *<BR>
   30    *<B>Assertion IDs:</B> A11.1-5.
   31    *<BR>
   32    *<B>Assertion Description: </B>
   33    * PersistenceManagerFactory.setIgnoreCache(boolean flag) sets the value of
   34    * the IgnoreCache property (the query mode that specifies whether cached
   35    * instances are considered when evaluating the filter expression).
   36    */
   37   
   38   public class SetIgnoreCache extends JDO_Test {
   39       
   40       /** */
   41       private static final String ASSERTION_FAILED = 
   42           "Assertion A11.1-5 (SetIgnoreCache) failed: ";
   43       
   44       /**
   45        * The <code>main</code> is called when the class
   46        * is directly executed from the command line.
   47        * @param args The arguments passed to the program.
   48        */
   49       public static void main(String[] args) {
   50           BatchTestRunner.run(SetIgnoreCache.class);
   51       }
   52   
   53       /** */
   54       protected void localSetUp() {
   55           closePMF();
   56           pmf = getUnconfiguredPMF();
   57       }
   58   
   59       /** 
   60        * Set IgnoreCache to true or false and use getIgnoreCache value to verify.
   61        */ 
   62       public void test() {
   63           try {
   64               setIgnoreCache(false);
   65               setIgnoreCache(true);
   66           } finally {
   67               closePMF();
   68           }
   69       }
   70   
   71       /** */
   72       private void setIgnoreCache(boolean newValue) {
   73           pmf.setIgnoreCache(newValue);
   74           boolean current = pmf.getIgnoreCache();
   75           if (current != newValue) {
   76               fail(ASSERTION_FAILED, "IgnoreCache set to " + newValue + 
   77                    ", value returned by PMF is " + current);
   78           }
   79       }
   80   }

Save This Page
Home » jdo2-tck-2.3-ea-src » org.apache.jdo.tck.api.persistencemanagerfactory » [javadoc | source]