mirror of https://github.com/apache/openjpa.git
OPENJPA-1678: delete tests which write to log files
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@953182 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
323ebee840
commit
6b38f0cb8e
|
@ -107,79 +107,4 @@ public class TestParameterLogging extends PersistenceTestCase {
|
||||||
nested = nested.getCause();
|
nested = nested.getCause();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* If the EMF is created with PrintParameters=false and trace is enabled for SQL the parameter values will not be
|
|
||||||
* logged in exception text.
|
|
||||||
*/
|
|
||||||
public void testParamsDisbledWithLogging() throws Exception {
|
|
||||||
RollbackException e =
|
|
||||||
getRollbackException(PObject.class, CLEAR_TABLES, "openjpa.ConnectionFactoryProperties",
|
|
||||||
"PrintParameters=false", "openjpa.Log", "SQL=TRACE,File=temp.txt");
|
|
||||||
assertFalse(Pattern.matches(_regex, e.toString()));
|
|
||||||
Throwable nested = e.getCause();
|
|
||||||
assertNotNull(nested); // should be at least one nested exception
|
|
||||||
while (nested != null) {
|
|
||||||
if (Pattern.matches(".*INSERT.*", nested.toString())) {
|
|
||||||
// only check if the message contains the insert statement.
|
|
||||||
assertFalse(Pattern.matches(_regex, nested.toString()));
|
|
||||||
}
|
|
||||||
nested = nested.getCause();
|
|
||||||
}
|
|
||||||
checkAndDeleteLogFile("temp.txt", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If the EMF is created with PrintParameters=false and trace is enabled for SQL the parameter values will not be
|
|
||||||
* logged in exception text.
|
|
||||||
*/
|
|
||||||
public void testParamsEnabledWithLogging() throws Exception {
|
|
||||||
RollbackException e =
|
|
||||||
getRollbackException(PObject.class, CLEAR_TABLES, "openjpa.ConnectionFactoryProperties",
|
|
||||||
"PrintParameters=true", "openjpa.Log", "SQL=TRACE,File=temp.txt");
|
|
||||||
assertFalse(Pattern.matches(_regex, e.toString()));
|
|
||||||
Throwable nested = e.getCause();
|
|
||||||
assertNotNull(nested); // should be at least one nested exception
|
|
||||||
while (nested != null) {
|
|
||||||
if (Pattern.matches(".*INSERT.*", nested.toString())) {
|
|
||||||
// only check if the message contains the insert statement.
|
|
||||||
assertTrue(Pattern.matches(_regex, nested.toString()));
|
|
||||||
}
|
|
||||||
nested = nested.getCause();
|
|
||||||
}
|
|
||||||
checkAndDeleteLogFile("temp.txt", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkAndDeleteLogFile(String filename, boolean containsParams) throws Exception {
|
|
||||||
File f = null;
|
|
||||||
FileReader fr = null;
|
|
||||||
BufferedReader br = null;
|
|
||||||
try {
|
|
||||||
f = new File(filename);
|
|
||||||
fr = new FileReader(f);
|
|
||||||
br = new BufferedReader(fr);
|
|
||||||
|
|
||||||
String s = br.readLine();
|
|
||||||
while (s != null) {
|
|
||||||
if (Pattern.matches(".*INSERT.*", s)) {
|
|
||||||
if (containsParams) {
|
|
||||||
assertTrue(Pattern.matches(_regex, s));
|
|
||||||
} else {
|
|
||||||
assertFalse(Pattern.matches(_regex, s));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
s = br.readLine();
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (br != null) {
|
|
||||||
br.close();
|
|
||||||
}
|
|
||||||
if (fr != null) {
|
|
||||||
fr.close();
|
|
||||||
}
|
|
||||||
if (f != null) {
|
|
||||||
f.delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue