Oops; earlier refactoring was not complete.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@609825 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Patrick Linskey 2008-01-08 01:03:43 +00:00
parent 26ef9ddabb
commit 07c046a077
2 changed files with 97 additions and 37 deletions

View File

@ -44,28 +44,7 @@ public class MetaDataCacheMaintenance {
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();
@ -92,6 +71,31 @@ public class MetaDataCacheMaintenance {
}
}
/**
* @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() {
System.err.println("Usage: java MetaDataCacheMaintenance "
+ "[-scanDevPath t|f] store | dump");

View File

@ -31,6 +31,7 @@ import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
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 @@ public class TestCacheMarshallerEndToEnd
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);
@ -112,4 +104,68 @@ public class TestCacheMarshallerEndToEnd
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();
}
}
}