Removed AvoidStarImport Rule

Added JavaDocType Rule
This commit is contained in:
Mudit Porwal
2017-03-22 01:16:01 +08:00
parent 175e9f58c1
commit 09585c3874
105 changed files with 577 additions and 284 deletions

View File

@ -35,47 +35,50 @@ import org.junit.rules.ExpectedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Test for the mute-idiom pattern
*/
public class MuteTest {
private static final Logger LOGGER = LoggerFactory.getLogger(MuteTest.class);
private static final String MESSAGE = "should not occur";
@Rule public ExpectedException exception = ExpectedException.none();
@Test
public void muteShouldRunTheCheckedRunnableAndNotThrowAnyExceptionIfCheckedRunnableDoesNotThrowAnyException() {
Mute.mute(() -> methodNotThrowingAnyException());
}
@Test
public void muteShouldRethrowUnexpectedExceptionAsAssertionError() throws Exception {
exception.expect(AssertionError.class);
exception.expectMessage(MESSAGE);
Mute.mute(() -> methodThrowingException());
}
@Test
public void loggedMuteShouldRunTheCheckedRunnableAndNotThrowAnyExceptionIfCheckedRunnableDoesNotThrowAnyException() {
Mute.loggedMute(() -> methodNotThrowingAnyException());
}
@Test
public void loggedMuteShouldLogExceptionTraceBeforeSwallowingIt() throws IOException {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
System.setErr(new PrintStream(stream));
Mute.loggedMute(() -> methodThrowingException());
assertTrue(new String(stream.toByteArray()).contains(MESSAGE));
}
private void methodNotThrowingAnyException() {
LOGGER.info("Executed successfully");
}
private void methodThrowingException() throws Exception {
throw new Exception(MESSAGE);
}