Close opened resources

- Add BufferedReader instantiation into try-with-resources statement
- Close scanner that was opened
- Create utility class to format a caught exception
This commit is contained in:
ljacqu
2015-11-25 22:51:30 +01:00
parent 5f9ba208de
commit c83e983dea
4 changed files with 40 additions and 11 deletions
@@ -2,6 +2,7 @@ package fr.xephi.authme.util;
import org.junit.Test;
import java.net.MalformedURLException;
import java.util.Arrays;
import java.util.List;
@@ -84,4 +85,16 @@ public class StringUtilsTest {
// then
assertThat(result, equalTo("hello"));
}
@Test
public void shouldFormatException() {
// given
MalformedURLException ex = new MalformedURLException("Unrecognized URL format");
// when
String result = StringUtils.formatException(ex);
// then
assertThat(result, equalTo("[MalformedURLException]: Unrecognized URL format"));
}
}