Java 11 migraiton: mute-idiom

This commit is contained in:
Anurag Agarwal
2020-04-12 22:58:50 +00:00
parent 9b105d770d
commit 2fa938c02d
3 changed files with 20 additions and 26 deletions

View File

@ -27,12 +27,11 @@ import org.junit.jupiter.api.Test;
/**
* Tests that Mute idiom example runs without errors.
*
*/
public class AppTest {
@Test
public void test() throws Exception {
App.main(null);
public void test() {
App.main(new String[]{});
}
}

View File

@ -23,17 +23,15 @@
package com.iluwatar.mute;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test for the mute-idiom pattern
*/
@ -50,9 +48,7 @@ public class MuteTest {
@Test
public void muteShouldRethrowUnexpectedExceptionAsAssertionError() {
assertThrows(AssertionError.class, () -> {
Mute.mute(this::methodThrowingException);
});
assertThrows(AssertionError.class, () -> Mute.mute(this::methodThrowingException));
}
@Test
@ -62,7 +58,7 @@ public class MuteTest {
@Test
public void loggedMuteShouldLogExceptionTraceBeforeSwallowingIt() {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
var stream = new ByteArrayOutputStream();
System.setErr(new PrintStream(stream));
Mute.loggedMute(this::methodThrowingException);