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 java.io.File;
   21   
   22   import javax.jdo.JDOHelper;
   23   import javax.jdo.PersistenceManagerFactory;
   24   
   25   import org.apache.jdo.tck.util.BatchTestRunner;
   26   
   27   /**
   28    *<B>Title:</B>GetPMFByFileAndClassLoader of PersistenceManagerFactory  
   29    *<BR>
   30    *<B>Keywords:</B> persistencemanagerfactory
   31    *<BR>
   32    *<B>Assertion IDs:</B> A8.6-14.
   33    *<BR>
   34    *<B>Assertion Description: </B>
   35    * Uses the parameter(s) passed as arguments to construct a Properties 
   36    * instance, and then delegates to the static method 
   37    * getPersistenceManagerFactory in the class named in the property 
   38    * javax.jdo.PersistenceManagerFactoryClass. 
   39    * If there are any exceptions while trying to construct the Properties
   40    * instance or to call the static method, 
   41    * then either A8.6-4 [JDOFatalUserException] or 
   42    * A8.6-5 [JDOFatalInternalException is thrown], 
   43    * depending on whether the exception is due to the user 
   44    * or the implementation. 
   45    * The nested exception indicates the cause of the exception.
   46    * 
   47    * @author Michael Watzek
   48    */
   49   
   50   public class GetPMFByFileAndClassLoader extends AbstractGetPMF {
   51       
   52       /** */
   53       private static final String ASSERTION_FAILED = 
   54           "Assertion A8.6-14 (GetPMFByFileAndClassLoader) failed: ";
   55       
   56       private static final String propertiesFileDoesNotExist = 
   57           "FileDoesNotExist.properties";
   58       private static final String propertiesFileExists = 
   59           System.getProperty("PMFProperties");
   60       
   61       /**
   62        * The <code>main</code> is called when the class
   63        * is directly executed from the command line.
   64        * @param args The arguments passed to the program.
   65        */
   66       public static void main(String[] args) {
   67           BatchTestRunner.run(GetPMFByFileAndClassLoader.class);
   68       }
   69   
   70       /** */
   71       public void testInvalidGetPMF() {
   72           checkGetPMFWithInvalidProperties(ASSERTION_FAILED);
   73       }
   74   
   75       /** */
   76       public void testValidGetPMF() {
   77           checkGetPMFWithValidProperties();
   78       }
   79   
   80       /** */
   81       protected PersistenceManagerFactory getPMF(String name) {
   82           return JDOHelper.getPersistenceManagerFactory(new File(name), 
   83                   Thread.currentThread().getContextClassLoader());
   84       }
   85   }

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