From 6b38f0cb8eb9362b103b33c1f1b646876f872a92 Mon Sep 17 00:00:00 2001 From: Michael Dick Date: Wed, 9 Jun 2010 23:04:48 +0000 Subject: [PATCH] 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 --- .../exception/TestParameterLogging.java | 75 ------------------- 1 file changed, 75 deletions(-) diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/exception/TestParameterLogging.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/exception/TestParameterLogging.java index e3891951c..9267d7d3b 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/exception/TestParameterLogging.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/exception/TestParameterLogging.java @@ -107,79 +107,4 @@ public class TestParameterLogging extends PersistenceTestCase { 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(); - } - } - } }