mirror of https://github.com/apache/openjpa.git
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:
parent
26ef9ddabb
commit
07c046a077
|
@ -44,28 +44,7 @@ public class MetaDataCacheMaintenance {
|
||||||
private final BrokerFactory factory;
|
private final BrokerFactory factory;
|
||||||
private final OpenJPAConfiguration conf;
|
private final OpenJPAConfiguration conf;
|
||||||
private final boolean devpath;
|
private final boolean devpath;
|
||||||
private final Log log;
|
private 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Options opts = new Options();
|
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() {
|
private static int usage() {
|
||||||
System.err.println("Usage: java MetaDataCacheMaintenance "
|
System.err.println("Usage: java MetaDataCacheMaintenance "
|
||||||
+ "[-scanDevPath t|f] store | dump");
|
+ "[-scanDevPath t|f] store | dump");
|
||||||
|
|
|
@ -31,6 +31,7 @@ import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
|
||||||
import org.apache.openjpa.persistence.query.NamedQueryEntity;
|
import org.apache.openjpa.persistence.query.NamedQueryEntity;
|
||||||
import org.apache.openjpa.persistence.simple.AllFieldTypes;
|
import org.apache.openjpa.persistence.simple.AllFieldTypes;
|
||||||
import org.apache.openjpa.persistence.test.PersistenceTestCase;
|
import org.apache.openjpa.persistence.test.PersistenceTestCase;
|
||||||
|
import org.apache.openjpa.lib.log.Log;
|
||||||
|
|
||||||
public class TestCacheMarshallerEndToEnd
|
public class TestCacheMarshallerEndToEnd
|
||||||
extends PersistenceTestCase {
|
extends PersistenceTestCase {
|
||||||
|
@ -75,22 +76,13 @@ public class TestCacheMarshallerEndToEnd
|
||||||
emf.getConfiguration(), MetaDataCacheMaintenance.class.getName());
|
emf.getConfiguration(), MetaDataCacheMaintenance.class.getName());
|
||||||
cm.getOutputFile().delete();
|
cm.getOutputFile().delete();
|
||||||
MetaDataCacheMaintenance maint = new MetaDataCacheMaintenance(
|
MetaDataCacheMaintenance maint = new MetaDataCacheMaintenance(
|
||||||
JPAFacadeHelper.toBrokerFactory(emf), false, true);
|
JPAFacadeHelper.toBrokerFactory(emf), false);
|
||||||
final List<String> lines = new ArrayList<String>();
|
LogImpl log = new LogImpl();
|
||||||
PrintStream out = new PrintStream(new ByteArrayOutputStream()) {
|
maint.setLog(log);
|
||||||
public void println(String line) {
|
|
||||||
lines.add(line);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void println(Object line) {
|
|
||||||
println(line.toString());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
maint.setOutputStream(out);
|
|
||||||
maint.store();
|
maint.store();
|
||||||
assertContains(lines, " " + AllFieldTypes.class.getName());
|
assertContains(log.lines, " " + AllFieldTypes.class.getName());
|
||||||
assertContains(lines, " " + NamedQueryEntity.class.getName());
|
assertContains(log.lines, " " + NamedQueryEntity.class.getName());
|
||||||
assertContains(lines, " NamedQueryEntity.namedQuery");
|
assertContains(log.lines, " NamedQueryEntity.namedQuery");
|
||||||
emf.close();
|
emf.close();
|
||||||
|
|
||||||
emf = createEMF(LOAD_PROPS);
|
emf = createEMF(LOAD_PROPS);
|
||||||
|
@ -112,4 +104,68 @@ public class TestCacheMarshallerEndToEnd
|
||||||
fail("should contain a line starting with " + prefix
|
fail("should contain a line starting with " + prefix
|
||||||
+ ": " + lines);
|
+ ": " + 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue