You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by bu...@apache.org on 2012/03/14 19:10:43 UTC
svn commit: r1300670 - in
/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima:
analysis_engine/impl/ util/ util/impl/
Author: burn
Date: Wed Mar 14 18:10:43 2012
New Revision: 1300670
URL: http://svn.apache.org/viewvc?rev=1300670&view=rev
Log:
[UIMA-2381] Avoid putting stack traces for expected exceptions in the console log
Modified:
uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/AnalysisEngine_implTest.java
uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/CasCreationUtilsTest.java
uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/TypeSystemUtilTest.java
uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/impl/JSR47Logger_implTest.java
uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/impl/TestLog4jLogger_impl.java
Modified: uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/AnalysisEngine_implTest.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/AnalysisEngine_implTest.java?rev=1300670&r1=1300669&r2=1300670&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/AnalysisEngine_implTest.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/AnalysisEngine_implTest.java Wed Mar 14 18:10:43 2012
@@ -81,6 +81,7 @@ import org.apache.uima.resource.metadata
import org.apache.uima.resource.metadata.impl.TypeSystemDescription_impl;
import org.apache.uima.test.junit_extension.JUnitExtension;
import org.apache.uima.util.InvalidXMLException;
+import org.apache.uima.util.Level;
import org.apache.uima.util.XMLInputSource;
import org.apache.uima.util.impl.ProcessTrace_impl;
@@ -1143,11 +1144,12 @@ public class AnalysisEngine_implTest ext
assertEquals("Line two", outCas.getDocumentText());
outCas.release();
try {
+ UIMAFramework.getLogger().setLevel(Level.OFF); // Suppress logging of expected exception
assertTrue(iter.hasNext());
outCas = iter.next();
fail(); // the above should throw an exception
} catch (AnalysisEngineProcessException e) {
- //do nothing
+ UIMAFramework.getLogger().setLevel(Level.INFO); // Restore to apparent default of INFO
}
//check that FlowController was notified twice, once for the
//segment's flow and once for the complete document's flow
@@ -1181,11 +1183,12 @@ public class AnalysisEngine_implTest ext
assertEquals("Line two", outCas.getDocumentText());
outCas.release();
try {
+ UIMAFramework.getLogger().setLevel(Level.OFF); // Suppress logging of expected exception
assertTrue(iter.hasNext());
outCas = iter.next();
fail(); // the above should throw an exception
} catch (AnalysisEngineProcessException e) {
- //do nothing
+ UIMAFramework.getLogger().setLevel(Level.INFO); // Restore to apparent default of INFO
}
//check that FlowController was notified three times, once for the
//segment's flow and twice for the complete document's flow (once
@@ -1226,11 +1229,12 @@ public class AnalysisEngine_implTest ext
assertEquals("Three", outCas.getDocumentText());
outCas.release();
try {
+ UIMAFramework.getLogger().setLevel(Level.OFF); // Suppress logging of expected exception
assertTrue(iter.hasNext());
outCas = iter.next();
fail(); // the above should throw an exception
} catch (AnalysisEngineProcessException e) {
- //do nothing
+ UIMAFramework.getLogger().setLevel(Level.INFO); // Restore to apparent default of INFO
}
//check that FlowController was notified three times, once for each level of granularity
assertEquals(3, FlowControllerForErrorTest.abortedDocuments.size());
@@ -1256,10 +1260,11 @@ public class AnalysisEngine_implTest ext
assertTrue(iter.hasNext());
// next call should fail with AnalysisEngineProcessException
try {
+ UIMAFramework.getLogger().setLevel(Level.OFF); // Suppress logging of expected exception
iter.next();
fail(); // should not get here
} catch (AnalysisEngineProcessException e) {
- // should get here
+ UIMAFramework.getLogger().setLevel(Level.INFO); // Restore to apparent default of INFO
}
// bad segmenter in an aggregate
@@ -1279,12 +1284,13 @@ public class AnalysisEngine_implTest ext
assertTrue(FlowControllerForErrorTest.failedAEs.isEmpty());
// next call should fail with AnalysisEngineProcessException
try {
+ UIMAFramework.getLogger().setLevel(Level.OFF); // Suppress logging of expected exception
if (iter.hasNext()) {
iter.next();
}
fail(); // should not get here
} catch (AnalysisEngineProcessException e) {
- // should get here
+ UIMAFramework.getLogger().setLevel(Level.INFO); // Restore to apparent default of INFO
}
assertEquals(1, FlowControllerForErrorTest.abortedDocuments.size());
assertTrue(FlowControllerForErrorTest.abortedDocuments.contains("Line one\nLine two\nLine three"));
@@ -1308,7 +1314,9 @@ public class AnalysisEngine_implTest ext
//next call should not have aborted, but FC should have been notified of the failiure,
// and no CAS should come back
+ UIMAFramework.getLogger().setLevel(Level.OFF); // Suppress logging of expected exception
assertFalse(iter.hasNext());
+ UIMAFramework.getLogger().setLevel(Level.INFO); // Restore to apparent default of INFO
assertEquals(0, FlowControllerForErrorTest.abortedDocuments.size());
assertEquals(1, FlowControllerForErrorTest.failedAEs.size());
assertTrue(FlowControllerForErrorTest.failedAEs.contains("Segmenter"));
@@ -1412,11 +1420,12 @@ public class AnalysisEngine_implTest ext
cas.reset();
cas.setDocumentText("ERROR");
try {
+ UIMAFramework.getLogger().setLevel(Level.OFF); // Suppress logging of expected exception
ae.process(cas);
fail();
}
catch(AnalysisEngineProcessException e) {
- //expected
+ UIMAFramework.getLogger().setLevel(Level.INFO); // Restore to apparent default of INFO
}
assertEquals(1, FlowControllerForErrorTest.abortedDocuments.size());
assertTrue(FlowControllerForErrorTest.abortedDocuments.contains("ERROR"));
@@ -1436,7 +1445,9 @@ public class AnalysisEngine_implTest ext
ae.reconfigure();
cas.reset();
cas.setDocumentText("ERROR");
+ UIMAFramework.getLogger().setLevel(Level.OFF); // Suppress logging of expected exception
ae.process(cas); //should not throw exception now
+ UIMAFramework.getLogger().setLevel(Level.INFO); // Restore to apparent default of INFO
//document should not have aborted, but FC should have been notified of the failiure
assertEquals(0, FlowControllerForErrorTest.abortedDocuments.size());
Modified: uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/CasCreationUtilsTest.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/CasCreationUtilsTest.java?rev=1300670&r1=1300669&r2=1300670&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/CasCreationUtilsTest.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/CasCreationUtilsTest.java Wed Mar 14 18:10:43 2012
@@ -656,7 +656,7 @@ public class CasCreationUtilsTest extend
.mergeDelegateAnalysisEngineMetaData(desc2, resMgr,
mergedTypes2, failedRemotes);
assertTrue(failedRemotes.containsKey("/RemoteDelegate"));
- ((Exception)failedRemotes.get("/RemoteDelegate")).printStackTrace();
+ // ((Exception)failedRemotes.get("/RemoteDelegate")).printStackTrace();
assertTrue(mergedMetaData2.getTypeSystem().getTypes().length > 0);
} catch (Exception e) {
Modified: uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/TypeSystemUtilTest.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/TypeSystemUtilTest.java?rev=1300670&r1=1300669&r2=1300670&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/TypeSystemUtilTest.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/TypeSystemUtilTest.java Wed Mar 14 18:10:43 2012
@@ -19,6 +19,9 @@
package org.apache.uima.util;
import java.io.File;
+import java.io.StringWriter;
+
+import junit.framework.TestCase;
import org.apache.uima.UIMAFramework;
import org.apache.uima.cas.CAS;
@@ -26,8 +29,6 @@ import org.apache.uima.resource.metadata
import org.apache.uima.resource.metadata.TypeSystemDescription;
import org.apache.uima.test.junit_extension.JUnitExtension;
-import junit.framework.TestCase;
-
public class TypeSystemUtilTest extends TestCase {
public void testTypeSystem2TypeSystemDescription() throws Exception {
//create a CAS with example type system
@@ -45,8 +46,11 @@ public class TypeSystemUtilTest extends
CAS cas = CasCreationUtils.createCas(tsDesc, null, null);
//convert that CAS's type system back to a TypeSystemDescription
TypeSystemDescription tsDesc2 = TypeSystemUtil.typeSystem2TypeSystemDescription(cas.getTypeSystem());
- tsDesc2.toXML(System.out);
//test that this is valid by creating a new CAS
CasCreationUtils.createCas(tsDesc2, null, null);
+
+ // Check that can be written (without cluttering up the console)
+ StringWriter out = new StringWriter();
+ tsDesc2.toXML(out);
}
}
Modified: uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/impl/JSR47Logger_implTest.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/impl/JSR47Logger_implTest.java?rev=1300670&r1=1300669&r2=1300670&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/impl/JSR47Logger_implTest.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/impl/JSR47Logger_implTest.java Wed Mar 14 18:10:43 2012
@@ -194,6 +194,7 @@ public class JSR47Logger_implTest extend
logger.log(Level.INFO, null, "");
// log test with method log(Level,String,Throwable)
+ logger.setLevel(Level.WARNING); // Don't log the expected exceptions
Throwable thrown = new Throwable();
logger.log(Level.INFO, "My fourth test message", thrown);
logger.log(Level.INFO, "", thrown);
@@ -262,6 +263,7 @@ public class JSR47Logger_implTest extend
// test method logrb(Level, String, String, String, String, thrown)
Throwable thrown = new Throwable();
+ logger.setLevel(Level.WARNING); // Don't log the expected exceptions
logger.logrb(Level.INFO, null, null, bundle, msgKey, thrown);
logger.logrb(Level.INFO, null, null, bundle, null, thrown);
logger.logrb(Level.INFO, null, null, null, msgKey, thrown);
Modified: uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/impl/TestLog4jLogger_impl.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/impl/TestLog4jLogger_impl.java?rev=1300670&r1=1300669&r2=1300670&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/impl/TestLog4jLogger_impl.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/impl/TestLog4jLogger_impl.java Wed Mar 14 18:10:43 2012
@@ -208,11 +208,13 @@ public class TestLog4jLogger_impl extend
// log test with method log(Level,String,Throwable)
Throwable thrown = new Throwable();
+ logger.setLevel(Level.WARNING); // Don't log the expected exceptions
logger.log(Level.INFO, "My fourth test message", thrown);
logger.log(Level.INFO, "", thrown);
logger.log(Level.INFO, null, thrown);
thrown = null;
logger.log(Level.INFO, "My fourth test message", thrown);
+ logger.setLevel(Level.INFO);
// test deprecated log method
logger.log("My fifth test message");
@@ -221,6 +223,7 @@ public class TestLog4jLogger_impl extend
// test deprecated logException method
Exception ex = new Exception("My sixth test message");
+ logger.setLevel(Level.WARNING); // Don't log the expected exceptions
logger.logException(ex);
logger.logException(null);
}
@@ -276,6 +279,7 @@ public class TestLog4jLogger_impl extend
logger.logrb(Level.INFO, "testClass", "testMethod", null, null, objects);
// test method logrb(Level, String, String, String, String, thrown)
+ logger.setLevel(Level.WARNING); // Don't log the expected exceptions
Throwable thrown = new Throwable();
logger.logrb(Level.INFO, null, null, bundle, msgKey, thrown);
logger.logrb(Level.INFO, null, null, bundle, null, thrown);