Skip to content

Commit aa21e39

Browse files
committed
Configure test logging globally for all subprojects. (#407)
``` org.metafacture.flowcontrol.ObjectExceptionCatcherTest > shouldCatchException STANDARD_ERROR [Test worker] ERROR org.metafacture.flowcontrol.ObjectExceptionCatcher - 'Exception Message' while processing object: data org.metafacture.flowcontrol.ObjectThreaderTest > shouldSplitAllObjectsToAllThreadedDownStreamReceivers STANDARD_ERROR [Test worker] INFO org.metafacture.flowcontrol.ObjectThreader - Adding thread 1 [Test worker] INFO org.metafacture.flowcontrol.ObjectThreader - Adding thread 2 org.metafacture.json.JsonDecoderTest > testShouldProcessRecordsInArrayRoot STANDARD_ERROR SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. org.metafacture.monitoring.StreamLoggerTest > shouldActAsSinkIfNoReceiverIsSet STANDARD_ERROR [Test worker] DEBUG org.metafacture.monitoring.StreamLogger - start record 1 [Test worker] DEBUG org.metafacture.monitoring.StreamLogger - start entity entity [Test worker] DEBUG org.metafacture.monitoring.StreamLogger - literal literal=value [Test worker] DEBUG org.metafacture.monitoring.StreamLogger - end entity [Test worker] DEBUG org.metafacture.monitoring.StreamLogger - end record [Test worker] DEBUG org.metafacture.monitoring.StreamLogger - resetStream [Test worker] DEBUG org.metafacture.monitoring.StreamLogger - closeStream org.metafacture.monitoring.StreamLoggerTest > shouldForwardAllReceivedEvents STANDARD_ERROR [Test worker] DEBUG org.metafacture.monitoring.StreamLogger - start record 1 [Test worker] DEBUG org.metafacture.monitoring.StreamLogger - start entity entity [Test worker] DEBUG org.metafacture.monitoring.StreamLogger - literal literal=value [Test worker] DEBUG org.metafacture.monitoring.StreamLogger - end entity [Test worker] DEBUG org.metafacture.monitoring.StreamLogger - end record [Test worker] DEBUG org.metafacture.monitoring.StreamLogger - resetStream [Test worker] DEBUG org.metafacture.monitoring.StreamLogger - closeStream org.metafacture.monitoring.ObjectTimerTest > testShouldHandleImmediateCloseStreamWithNoProcessing STANDARD_ERROR [Test worker] INFO org.metafacture.monitoring.TimerBase - Executions: 0; Cumulative duration: 0s; Average duration: 0s [Test worker] INFO org.metafacture.monitoring.TimerBase - Time to close stream: 14µs 965ns org.metafacture.monitoring.ObjectTimerTest > testShouldMeasureExecutionTime STANDARD_ERROR [Test worker] INFO org.metafacture.monitoring.TimerBase - Execution 1: 150ms 138µs [Test worker] INFO org.metafacture.monitoring.TimerBase - Execution 2: 20ms 82µs [Test worker] INFO org.metafacture.monitoring.TimerBase - Execution 3: 30ms 130µs [Test worker] INFO org.metafacture.monitoring.TimerBase - Execution 4: 202ms 164µs [Test worker] INFO org.metafacture.monitoring.TimerBase - Executions: 4; Cumulative duration: 402ms 515µs; Average duration: 100ms 629µs [Test worker] INFO org.metafacture.monitoring.TimerBase - Time to close stream: 6µs 170ns org.metafacture.monitoring.StreamTimerTest > testShouldHandleImmediateCloseStreamWithNoProcessing STANDARD_ERROR [Test worker] INFO org.metafacture.monitoring.TimerBase - Executions: 0; Cumulative duration: 0s; Average duration: 0s [Test worker] INFO org.metafacture.monitoring.TimerBase - Time to close stream: 1µs 470ns org.metafacture.monitoring.StreamTimerTest > testShouldMeasureExecutionTime STANDARD_ERROR [Test worker] INFO org.metafacture.monitoring.TimerBase - Execution 1: 150ms 242µs [Test worker] INFO org.metafacture.monitoring.TimerBase - Execution 2: 20ms 149µs [Test worker] INFO org.metafacture.monitoring.TimerBase - Execution 3: 30ms 123µs [Test worker] INFO org.metafacture.monitoring.TimerBase - Execution 4: 202ms 170µs [Test worker] INFO org.metafacture.monitoring.TimerBase - Executions: 4; Cumulative duration: 402ms 685µs; Average duration: 100ms 671µs [Test worker] INFO org.metafacture.monitoring.TimerBase - Time to close stream: 5µs 111ns org.metafacture.metamorph.test.validators.StreamValidatorTest > shouldFailIfEndRecordEventIsMissing STANDARD_ERROR [Test worker] INFO org.metafacture.metamorph.test.validators.StreamValidator - Event Stream: 1{} ```
1 parent 00533c5 commit aa21e39

File tree

10 files changed

+19
-43
lines changed

10 files changed

+19
-43
lines changed

build.gradle

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,15 @@ subprojects {
104104
checkstyleTest.enabled = false
105105
}
106106

107+
test {
108+
systemProperties['org.slf4j.simpleLogger.defaultLogLevel'] = 'warn'
109+
110+
testLogging {
111+
showStandardStreams = true
112+
exceptionFormat = 'full'
113+
}
114+
}
115+
107116
signing {
108117
required {
109118
scmInfo.isRelease() && gradle.taskGraph.hasTask(tasks.uploadArchives)

metafacture-biblio/build.gradle

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,3 @@ dependencies {
3131
testImplementation 'junit:junit:4.12'
3232
testImplementation 'org.mockito:mockito-core:2.5.5'
3333
}
34-
35-
test {
36-
testLogging {
37-
showStandardStreams = true
38-
exceptionFormat = 'full'
39-
}
40-
}

metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/ObjectExceptionCatcher.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public final class ObjectExceptionCatcher<T> extends
5252

5353
private String logPrefix;
5454
private boolean logStackTrace;
55+
private boolean logExceptionMessage = true;
5556

5657
/**
5758
* Creates an instance of {@link ObjectExceptionCatcher} without a log message
@@ -108,13 +109,19 @@ public boolean isLogStackTrace() {
108109
return logStackTrace;
109110
}
110111

112+
/*package-private*/ void setLogExceptionMessage(final boolean logExceptionMessage) {
113+
this.logExceptionMessage = logExceptionMessage;
114+
}
115+
111116
@Override
112117
public void process(final T obj) {
113118
try {
114119
getReceiver().process(obj);
115120
}
116121
catch (final Exception e) { // checkstyle-disable-line IllegalCatch
117-
LOG.error("{}'{}' while processing object: {}", logPrefix, e.getMessage(), obj);
122+
if (logExceptionMessage) {
123+
LOG.error("{}'{}' while processing object: {}", logPrefix, e.getMessage(), obj);
124+
}
118125

119126
if (logStackTrace) {
120127
final StringWriter stackTraceWriter = new StringWriter();

metafacture-flowcontrol/src/test/java/org/metafacture/flowcontrol/ObjectExceptionCatcherTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public void setup() {
4545
.when(exceptionThrowingModule).process(anyString());
4646
exceptionCatcher = new ObjectExceptionCatcher<>();
4747
exceptionCatcher.setReceiver(exceptionThrowingModule);
48+
exceptionCatcher.setLogExceptionMessage(false);
4849
}
4950

5051
@Test

metafacture-json/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ dependencies {
2424
implementation 'com.jayway.jsonpath:json-path:2.6.0'
2525
testImplementation 'junit:junit:4.12'
2626
testImplementation 'org.mockito:mockito-core:2.5.5'
27+
testRuntimeOnly 'org.slf4j:slf4j-simple:1.7.21'
2728
}

metafacture-mangling/build.gradle

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,3 @@ dependencies {
2323
testImplementation 'junit:junit:4.12'
2424
testImplementation 'org.mockito:mockito-core:2.5.5'
2525
}
26-
27-
test {
28-
testLogging {
29-
showStandardStreams = true
30-
exceptionFormat = 'full'
31-
}
32-
}

metafacture-triples/build.gradle

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,3 @@ dependencies {
2424
testImplementation 'junit:junit:4.12'
2525
testImplementation 'org.mockito:mockito-core:2.5.5'
2626
}
27-
28-
test {
29-
testLogging {
30-
showStandardStreams = true
31-
exceptionFormat = 'full'
32-
}
33-
}

metafacture-xml/build.gradle

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,3 @@ dependencies {
2626
testImplementation 'org.mockito:mockito-core:2.5.5'
2727
testRuntimeOnly 'org.slf4j:slf4j-simple:1.7.21'
2828
}
29-
30-
test {
31-
testLogging {
32-
showStandardStreams = true
33-
exceptionFormat = 'full'
34-
}
35-
}

metafacture-yaml/build.gradle

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,3 @@ dependencies {
2323
testImplementation 'junit:junit:4.12'
2424
testImplementation 'org.mockito:mockito-core:2.5.5'
2525
}
26-
27-
test {
28-
testLogging {
29-
showStandardStreams = true
30-
exceptionFormat = 'full'
31-
}
32-
}

metamorph/build.gradle

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,3 @@ sourceSets {
3939
output.resourcesDir = sourceSets.test.java.outputDir
4040
}
4141
}
42-
43-
test {
44-
testLogging {
45-
showStandardStreams = true
46-
exceptionFormat = 'full'
47-
}
48-
}

0 commit comments

Comments
 (0)