Save This Page
Home » jdo2-tck-2.3-ea-src » org.apache.jdo.tck.api.persistencemanager.flags » [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.persistencemanager.flags;
   19   
   20   import javax.jdo.PersistenceManager;
   21   import javax.jdo.Transaction;
   22   
   23   import org.apache.jdo.tck.util.BatchTestRunner;
   24   import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest;
   25   
   26   /**
   27    *<B>Title:</B> Set Multithreaded True
   28    *<BR>
   29    *<B>Keywords:</B> multithreaded
   30    *<BR>
   31    *<B>Assertion ID:</B> A12.7-1.
   32    *<BR>
   33    *<B>Assertion Description: </B>
   34   If PersistenceManager.setMultithreaded is called with a value of true, then the JDO
   35   implementation must perform synchronizations to support multiple application threads. A value of true will be returned
   36   when getMultithreaded is called. In testing, multi-threading should be turned on and then multi-threading tests should
   37   be run.
   38    */
   39   
   40   public class SetMultithreadedTrue extends PersistenceManagerTest {
   41       
   42       /** */
   43       private static final String ASSERTION_FAILED = 
   44           "Assertion A12.7-1 (SetMultithreadedTrue) failed: ";
   45       
   46       /**
   47        * The <code>main</code> is called when the class
   48        * is directly executed from the command line.
   49        * @param args The arguments passed to the program.
   50        */
   51       public static void main(String[] args) {
   52           BatchTestRunner.run(SetMultithreadedTrue.class);
   53       }
   54   
   55       /** */
   56       public void test() {
   57           pm = getPM();
   58           
   59           runTestSetMultithreadedTrue(pm);
   60           
   61           pm.close();
   62           pm = null;
   63       }
   64       
   65       /** */
   66       public void runTestSetMultithreadedTrue(PersistenceManager pm) {
   67           Transaction tx = pm.currentTransaction();
   68           try {
   69               tx.begin();
   70               pm.setMultithreaded(true);
   71               if (!pm.getMultithreaded()) {
   72                   fail(ASSERTION_FAILED,
   73                        "pm.getMultithreaded() should true true after setting the flag to true.");
   74               }
   75               tx.commit();
   76               tx = null;
   77           }
   78           finally {
   79               if ((tx != null) && tx.isActive())
   80                   tx.rollback();
   81           }
   82       }
   83   }

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