Fix failing unit test of Contexted(Runtime)Exception, adjust formatted message.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@802569 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ad922624da
commit
7bd9b8ada1
|
@ -93,7 +93,9 @@ public class DefaultExceptionContext implements ExceptionContext {
|
|||
}
|
||||
|
||||
if (contextKeyList.size() > 0) {
|
||||
buffer.append(SystemUtils.LINE_SEPARATOR);
|
||||
if (buffer.length() > 0l) {
|
||||
buffer.append(SystemUtils.LINE_SEPARATOR);
|
||||
}
|
||||
buffer.append("Exception Context:");
|
||||
buffer.append(SystemUtils.LINE_SEPARATOR);
|
||||
buffer.append("\t");
|
||||
|
@ -120,8 +122,7 @@ public class DefaultExceptionContext implements ExceptionContext {
|
|||
buffer.append(SystemUtils.LINE_SEPARATOR);
|
||||
buffer.append("\t");
|
||||
}
|
||||
buffer.append(SystemUtils.LINE_SEPARATOR);
|
||||
buffer.append("\t---------------------------------");
|
||||
buffer.append("---------------------------------");
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
|
|
@ -102,10 +102,6 @@ public class ContextedExceptionTest extends TestCase {
|
|||
assertTrue(message.indexOf("5")>=0);
|
||||
assertTrue(message.indexOf("Crap")>=0);
|
||||
|
||||
String contextMessage = contextedException.getFormattedExceptionMessage("");
|
||||
assertTrue(contextMessage.indexOf(TEST_MESSAGE) == -1);
|
||||
assertTrue(message.contains(contextMessage));
|
||||
|
||||
assertTrue(contextedException.getLabeledValue("test1") == null);
|
||||
assertTrue(contextedException.getLabeledValue("test2").equals("some value"));
|
||||
assertTrue(contextedException.getLabeledValue("crap") == null);
|
||||
|
@ -119,6 +115,12 @@ public class ContextedExceptionTest extends TestCase {
|
|||
assertTrue(contextedException.getLabelSet().contains("test Poorly written obj"));
|
||||
|
||||
assertTrue(!contextedException.getLabelSet().contains("crap"));
|
||||
|
||||
contextedException.addLabeledValue("test Poorly written obj", "replacement");
|
||||
|
||||
String contextMessage = contextedException.getFormattedExceptionMessage(null);
|
||||
assertTrue(contextMessage.indexOf(TEST_MESSAGE) == -1);
|
||||
assertTrue(contextedException.getMessage().endsWith(contextMessage));
|
||||
}
|
||||
|
||||
public void testNullExceptionPassing() {
|
||||
|
|
|
@ -102,10 +102,6 @@ public class ContextedRuntimeExceptionTest extends TestCase {
|
|||
assertTrue(message.indexOf("5")>=0);
|
||||
assertTrue(message.indexOf("Crap")>=0);
|
||||
|
||||
String contextMessage = contextedRuntimeException.getFormattedExceptionMessage("");
|
||||
assertTrue(contextMessage.indexOf(TEST_MESSAGE) == -1);
|
||||
assertTrue(message.contains(contextMessage));
|
||||
|
||||
assertTrue(contextedRuntimeException.getLabeledValue("test1") == null);
|
||||
assertTrue(contextedRuntimeException.getLabeledValue("test2").equals("some value"));
|
||||
assertTrue(contextedRuntimeException.getLabeledValue("crap") == null);
|
||||
|
@ -119,6 +115,12 @@ public class ContextedRuntimeExceptionTest extends TestCase {
|
|||
assertTrue(contextedRuntimeException.getLabelSet().contains("test Poorly written obj"));
|
||||
|
||||
assertTrue(!contextedRuntimeException.getLabelSet().contains("crap"));
|
||||
|
||||
contextedRuntimeException.addLabeledValue("test Poorly written obj", "replacement");
|
||||
|
||||
String contextMessage = contextedRuntimeException.getFormattedExceptionMessage(null);
|
||||
assertTrue(contextMessage.indexOf(TEST_MESSAGE) == -1);
|
||||
assertTrue(contextedRuntimeException.getMessage().endsWith(contextMessage));
|
||||
}
|
||||
|
||||
public void testNullExceptionPassing() {
|
||||
|
|
Loading…
Reference in New Issue