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.JDOFatalUserException;
   21   import javax.jdo.JDOUserException;
   22   
   23   import org.apache.jdo.tck.JDO_Test;
   24   import org.apache.jdo.tck.util.BatchTestRunner;
   25   
   26   /**
   27    *<B>Title:</B>AfterCloseGetPMThrowsException of PersistenceManagerFactory  
   28    *<BR>
   29    *<B>Keywords:</B> persistencemanagerfactory
   30    *<BR>
   31    *<B>Assertion IDs:</B> A11.4-9B.
   32    *<BR>
   33    *<B>Assertion Description: </B>
   34    * PersistenceManagerFactory.getPersistenceManager() throws
   35    * JDOUserException after the PersistenceManagerFactory is closed.
   36    */
   37   
   38   /* 
   39    * Revision History
   40    * ================
   41    * Author :  Craig Russell
   42    * Date   :  05/16/03
   43    *
   44    */
   45   
   46   public class AfterCloseGetPMThrowsException extends JDO_Test {
   47       
   48       /** */
   49       private static final String ASSERTION_FAILED = 
   50           "Assertion A11.4-9B (AfterCloseGetPMThrowsException) failed: ";
   51       
   52       /**
   53        * The <code>main</code> is called when the class
   54        * is directly executed from the command line.
   55        * @param args The arguments passed to the program.
   56        */
   57       public static void main(String[] args) {
   58           BatchTestRunner.run(AfterCloseGetPMThrowsException.class);
   59       }
   60   
   61       /** */
   62       public void test() {
   63           try {
   64               pmf = getPMF();
   65               closePMF(pmf); // don't use closePMF() because that sets pmf to null
   66               pm = pmf.getPersistenceManager();
   67               fail(ASSERTION_FAILED,
   68                   "pmf.getPersistenceManager should throw JDOUserException if pmf is closed.");
   69           } catch (JDOUserException ex) {
   70               // expected exception
   71               if (debug)
   72                   logger.debug("caught expected exception " + ex.toString());
   73           } catch (JDOFatalUserException ex) {
   74               // unexpected exception
   75               fail(ASSERTION_FAILED, 
   76                   "Wrong exception thrown from getPersistenceManager after close.\n" +
   77                       "Expected JDOUserException, got JDOFatalUserException.");
   78           } finally {
   79               if (pm != null) 
   80               pm.close();
   81           }
   82       }
   83   }

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