Skip to content

Commit

Permalink
{WIP} fail even if only getMessage() and no cause (fixes KengoTODA#69)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Vorburger <mike@vorburger.ch>
  • Loading branch information
vorburger committed Mar 14, 2018
1 parent 55693e4 commit ef09fd0
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions test-case/src/main/java/pkg/UsingGetLocalizedMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public class UsingGetLocalizedMessage {
private final Logger logger = LoggerFactory.getLogger(getClass());

void method(Throwable t) {
logger.info("My message is {}", t.getLocalizedMessage());
logger.info("My message is {}", t.getLocalizedMessage(), t);
logger.info("My {} is {}", new Object[]{ "message", t.getLocalizedMessage(), t });
logger.info("My {} {} {}", new Object[]{ "message", "is", t.getLocalizedMessage(), t });
Expand Down
1 change: 1 addition & 0 deletions test-case/src/main/java/pkg/UsingGetMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public class UsingGetMessage {
private final Logger logger = LoggerFactory.getLogger(getClass());

void method(Throwable t) {
logger.info("My message is {}", t.getMessage());
logger.info("My message is {}", t.getMessage(), t);
logger.info("My {} is {}", new Object[]{ "message", t.getMessage(), t });
logger.info("My {} {} {}", new Object[]{ "message", "is", t.getMessage(), t });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
public class UsingGetLocalizedMessageTest {
@Test
public void test() {
Map<String, Integer> expected = Collections.singletonMap("SLF4J_MANUALLY_PROVIDED_MESSAGE", 3);
Map<String, Integer> expected = Collections.singletonMap("SLF4J_MANUALLY_PROVIDED_MESSAGE", 4);
Multimap<String, String> longMessages = new XmlParser().expect(pkg.UsingGetLocalizedMessage.class, expected);
assertThat(longMessages).containsEntry("SLF4J_MANUALLY_PROVIDED_MESSAGE",
"Do not have to use message returned from Throwable#getMessage and Throwable#getLocalizedMessage. It is enough to provide throwable instance as the last argument, then binding will log its message.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
public class UsingGetMessageTest {
@Test
public void test() {
Map<String, Integer> expected = Collections.singletonMap("SLF4J_MANUALLY_PROVIDED_MESSAGE", 3);
Map<String, Integer> expected = Collections.singletonMap("SLF4J_MANUALLY_PROVIDED_MESSAGE", 4);
Multimap<String, String> longMessages = new XmlParser().expect(pkg.UsingGetMessage.class, expected);
assertThat(longMessages).containsEntry("SLF4J_MANUALLY_PROVIDED_MESSAGE",
"Do not have to use message returned from Throwable#getMessage and Throwable#getLocalizedMessage. It is enough to provide throwable instance as the last argument, then binding will log its message.");
Expand Down

0 comments on commit ef09fd0

Please sign in to comment.