You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-commits@db.apache.org by mb...@apache.org on 2006/03/12 23:42:12 UTC

svn commit: r385380 - in /db/jdo/trunk/tck20/src/java/org/apache/jdo/tck: JDO_Test.java util/BatchTestRunner.java

Author: mbo
Date: Sun Mar 12 14:42:12 2006
New Revision: 385380

URL: http://svn.apache.org/viewcvs?rev=385380&view=rev
Log:
Store pmf.supportedOptions in a file pmf_supported_options.txt in the log configuration directory

Modified:
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/JDO_Test.java
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/util/BatchTestRunner.java

Modified: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/JDO_Test.java
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/JDO_Test.java?rev=385380&r1=385379&r2=385380&view=diff
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/JDO_Test.java (original)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/JDO_Test.java Sun Mar 12 14:42:12 2006
@@ -17,9 +17,13 @@
 
 package org.apache.jdo.tck;
 
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.PrintStream;
 
 import java.lang.reflect.Field;
 import java.lang.reflect.Modifier;
@@ -168,6 +172,12 @@
     /** The PersistenceManagerFactory. */
     protected static PersistenceManagerFactory pmf;
     
+    /** The collection of supported options of the pmf. */
+    private static Collection supportedOptions;
+
+    /** The name of the pmf supported options summary file. */
+    private static final String PMF_SUPPORTED_OPTIONS_FILE_NAME = "pmf_supported_options.txt";
+
     /** The PersistenceManager. */
     protected PersistenceManager pm;
     
@@ -441,6 +451,9 @@
         if (pmf == null) {
             PMFPropertiesObject = loadProperties(PMFProperties); // will exit here if no properties
             pmf = JDOHelper.getPersistenceManagerFactory(PMFPropertiesObject);
+            if (supportedOptions == null) {
+                supportedOptions = pmf.supportedOptions();
+            }
         }
         return pmf;
     }
@@ -571,7 +584,32 @@
     }
 
     // Helper methods to check for supported options
-    
+
+    /**
+     * Dump the supportedOptions to the a file in the specified directory.
+     */
+    public static void dumpSupportedOptions(String directory) {
+        if (supportedOptions == null)
+            return;
+        File file = new File(directory, PMF_SUPPORTED_OPTIONS_FILE_NAME);
+        if (file.exists())
+            // PMF supported options have been dumped before => return
+            return;
+        PrintStream resultStream = null;
+        try {
+            resultStream = new PrintStream(new FileOutputStream(file));
+            for (Iterator it = supportedOptions.iterator(); it.hasNext();) {
+                resultStream.println((String)it.next());
+            }
+        } catch (FileNotFoundException e) {
+            throw new JDOFatalException(
+                "dumpSupportedOptions: cannot create file " + file.getName(), e);
+        } finally {
+            if (resultStream != null)
+                resultStream.close();
+        }
+    }
+     
     /** 
      * Prints a message (if debug is true) saying the test with the
      * specified name is not executed, because the JDO implementation under

Modified: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/util/BatchTestRunner.java
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/util/BatchTestRunner.java?rev=385380&r1=385379&r2=385380&view=diff
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/util/BatchTestRunner.java (original)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/util/BatchTestRunner.java Sun Mar 12 14:42:12 2006
@@ -55,6 +55,19 @@
     /** Default of the system property ResultPrinterClass. */
     public static final String RESULTPRINTER_DEFAULT = BatchResultPrinter.class.getName();
 
+    /** */
+    public static final String LOG_DIRECTORY;
+
+    static {
+        String directory = System.getProperty("jdo.tck.log.directory");
+        if (directory!=null &&
+            !directory.endsWith(File.separator)) {
+            directory += File.separator;
+        }
+        LOG_DIRECTORY = directory;
+    }
+    
+
     /** 
      * Constructor. 
      * It creates a result printer instance based on the system property
@@ -90,6 +103,7 @@
     /** Runs the specified test and close the pmf. */
     public TestResult doRun(Test test) {
         TestResult result = doRun(test, false);
+        JDO_Test.dumpSupportedOptions(LOG_DIRECTORY + "configuration");
         JDO_Test.closePMF();
         return result;
     }
@@ -258,12 +272,7 @@
      * @return the changed file name
      */
     public static String changeFileName(String fileName) {
-        String directory = System.getProperty("jdo.tck.log.directory");
-        if (directory!=null &&
-            !directory.endsWith(File.separator)) {
-            directory += File.separator;
-        }
-
+        String directory = LOG_DIRECTORY;
         String db = System.getProperty("jdo.tck.database");
         
         String identityType = System.getProperty("jdo.tck.identitytype");