openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p..@apache.org
Subject svn commit: r609825 - in /openjpa/trunk: openjpa-kernel/src/main/java/org/apache/openjpa/conf/MetaDataCacheMaintenance.java openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestCacheMarshallerEndToEnd.java
Date Tue, 08 Jan 2008 01:03:45 GMT
Author: pcl
Date: Mon Jan  7 17:03:43 2008
New Revision: 609825

URL: http://svn.apache.org/viewvc?rev=609825&view=rev
Log:
Oops; earlier refactoring was not complete.

Modified:
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/MetaDataCacheMaintenance.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestCacheMarshallerEndToEnd.java

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/MetaDataCacheMaintenance.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/MetaDataCacheMaintenance.java?rev=609825&r1=609824&r2=609825&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/MetaDataCacheMaintenance.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/MetaDataCacheMaintenance.java
Mon Jan  7 17:03:43 2008
@@ -44,28 +44,7 @@
     private final BrokerFactory factory;
     private final OpenJPAConfiguration conf;
     private final boolean devpath;
-    private final Log log;
-
-    /**
-     * @deprecated logging is routed to the logging system now.
-     */
-    public MetaDataCacheMaintenance(BrokerFactory factory, boolean devpath,
-        boolean verbose) {
-        this(factory, devpath);
-    }
-
-    /**
-     * @param factory The {@link BrokerFactory} for which cached metadata
-     * should be built.
-     * @param devpath Whether or not to scan the development environment paths
-     * to find persistent types to store.
-     */
-    public MetaDataCacheMaintenance(BrokerFactory factory, boolean devpath) {
-        this.factory = factory;
-        this.conf = factory.getConfiguration();
-        this.devpath = devpath;
-        this.log = conf.getLog(OpenJPAConfiguration.LOG_TOOL);
-    }
+    private Log log;
 
     public static void main(String[] args) {
         Options opts = new Options();
@@ -90,6 +69,31 @@
         } finally {
             factory.close();
         }
+    }
+
+    /**
+     * @deprecated logging is routed to the logging system now.
+     */
+    public MetaDataCacheMaintenance(BrokerFactory factory, boolean devpath,
+        boolean verbose) {
+        this(factory, devpath);
+    }
+
+    /**
+     * @param factory The {@link BrokerFactory} for which cached metadata
+     * should be built.
+     * @param devpath Whether or not to scan the development environment paths
+     * to find persistent types to store.
+     */
+    public MetaDataCacheMaintenance(BrokerFactory factory, boolean devpath) {
+        this.factory = factory;
+        this.conf = factory.getConfiguration();
+        this.devpath = devpath;
+        this.log = conf.getLog(OpenJPAConfiguration.LOG_TOOL);
+    }
+
+    public void setLog(Log log) {
+        this.log = log;
     }
 
     private static int usage() {

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestCacheMarshallerEndToEnd.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestCacheMarshallerEndToEnd.java?rev=609825&r1=609824&r2=609825&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestCacheMarshallerEndToEnd.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestCacheMarshallerEndToEnd.java
Mon Jan  7 17:03:43 2008
@@ -31,6 +31,7 @@
 import org.apache.openjpa.persistence.query.NamedQueryEntity;
 import org.apache.openjpa.persistence.simple.AllFieldTypes;
 import org.apache.openjpa.persistence.test.PersistenceTestCase;
+import org.apache.openjpa.lib.log.Log;
 
 public class TestCacheMarshallerEndToEnd
     extends PersistenceTestCase {
@@ -75,22 +76,13 @@
             emf.getConfiguration(), MetaDataCacheMaintenance.class.getName());
         cm.getOutputFile().delete();
         MetaDataCacheMaintenance maint = new MetaDataCacheMaintenance(
-            JPAFacadeHelper.toBrokerFactory(emf), false, true);
-        final List<String> lines = new ArrayList<String>();
-        PrintStream out = new PrintStream(new ByteArrayOutputStream()) {
-            public void println(String line) {
-                lines.add(line);
-            }
-
-            public void println(Object line) {
-                println(line.toString());
-            }
-        };
-        maint.setOutputStream(out);
+            JPAFacadeHelper.toBrokerFactory(emf), false);
+        LogImpl log = new LogImpl();
+        maint.setLog(log);
         maint.store();
-        assertContains(lines, "    " + AllFieldTypes.class.getName());
-        assertContains(lines, "    " + NamedQueryEntity.class.getName());
-        assertContains(lines, "    NamedQueryEntity.namedQuery");
+        assertContains(log.lines, "    " + AllFieldTypes.class.getName());
+        assertContains(log.lines, "    " + NamedQueryEntity.class.getName());
+        assertContains(log.lines, "    NamedQueryEntity.namedQuery");
         emf.close();
 
         emf = createEMF(LOAD_PROPS);
@@ -111,5 +103,69 @@
                 return;
         fail("should contain a line starting with " + prefix
             + ": " + lines);
+    }
+
+    private class LogImpl implements Log {
+        private List<String> lines = new ArrayList<String>();
+
+        public boolean isTraceEnabled() {
+            return true;
+        }
+
+        public boolean isInfoEnabled() {
+            return true;
+        }
+
+        public boolean isWarnEnabled() {
+            throw new UnsupportedOperationException();
+        }
+
+        public boolean isErrorEnabled() {
+            throw new UnsupportedOperationException();
+        }
+
+        public boolean isFatalEnabled() {
+            throw new UnsupportedOperationException();
+        }
+
+        public void trace(Object o) {
+            lines.add(o.toString());
+        }
+
+        public void trace(Object o, Throwable t) {
+            throw new UnsupportedOperationException();
+        }
+
+        public void info(Object o) {
+            lines.add(o.toString());
+        }
+
+        public void info(Object o, Throwable t) {
+            throw new UnsupportedOperationException();
+        }
+
+        public void warn(Object o) {
+            throw new UnsupportedOperationException();
+        }
+
+        public void warn(Object o, Throwable t) {
+            throw new UnsupportedOperationException();
+        }
+
+        public void error(Object o) {
+            throw new UnsupportedOperationException();
+        }
+
+        public void error(Object o, Throwable t) {
+            throw new UnsupportedOperationException();
+        }
+
+        public void fatal(Object o) {
+            throw new UnsupportedOperationException();
+        }
+
+        public void fatal(Object o, Throwable t) {
+            throw new UnsupportedOperationException();
+        }
     }
 }



Mime
View raw message