Remove assertions in error cases. They won't be executed.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1648924 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benedikt Ritter 2015-01-01 19:19:44 +00:00
parent 42728e8e53
commit d903279e44
1 changed files with 21 additions and 53 deletions

View File

@ -95,15 +95,13 @@ public class JsonToStringStyleTest {
final Integer i4 = Integer.valueOf(4); final Integer i4 = Integer.valueOf(4);
try { try {
assertEquals("{\"null\":null}", new ToStringBuilder(base).append((Object) null).toString();
new ToStringBuilder(base).append((Object) null).toString());
fail("Should have generated UnsupportedOperationException"); fail("Should have generated UnsupportedOperationException");
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
} }
try { try {
assertEquals("{\"null\":3}", new ToStringBuilder(base).append(i3) new ToStringBuilder(base).append(i3).toString();
.toString());
fail("Should have generated UnsupportedOperationException"); fail("Should have generated UnsupportedOperationException");
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
} }
@ -117,17 +115,13 @@ public class JsonToStringStyleTest {
.toString()); .toString());
try { try {
assertEquals("{\"a\":\"<Integer>\"}", new ToStringBuilder(base).append("a", i3, false).toString();
new ToStringBuilder(base).append("a", i3, false).toString());
fail("Should have generated UnsupportedOperationException"); fail("Should have generated UnsupportedOperationException");
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
} }
try { try {
assertEquals( new ToStringBuilder(base).append("a", new ArrayList<Object>(), false).toString();
"{\"a\":\"<size=0>\"}",
new ToStringBuilder(base).append("a", new ArrayList<Object>(),
false).toString());
fail("Should have generated UnsupportedOperationException"); fail("Should have generated UnsupportedOperationException");
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
} }
@ -138,10 +132,7 @@ public class JsonToStringStyleTest {
true).toString()); true).toString());
try { try {
assertEquals( new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), false).toString();
"{\"a\":\"<size=0>\"}",
new ToStringBuilder(base).append("a",
new HashMap<Object, Object>(), false).toString());
fail("Should have generated UnsupportedOperationException"); fail("Should have generated UnsupportedOperationException");
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
} }
@ -152,10 +143,7 @@ public class JsonToStringStyleTest {
new HashMap<Object, Object>(), true).toString()); new HashMap<Object, Object>(), true).toString());
try { try {
assertEquals( new ToStringBuilder(base).append("a", (Object) new String[0], false).toString();
"{\"a\":\"<size=0>\"}",
new ToStringBuilder(base).append("a", (Object) new String[0],
false).toString());
fail("Should have generated UnsupportedOperationException"); fail("Should have generated UnsupportedOperationException");
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
} }
@ -166,10 +154,7 @@ public class JsonToStringStyleTest {
true).toString()); true).toString());
try { try {
assertEquals( new ToStringBuilder(base).append("a", (Object) new int[]{1, 2, 3}, false).toString();
"{\"a\":\"<size=3>\"}",
new ToStringBuilder(base).append("a",
(Object) new int[]{1, 2, 3}, false).toString());
fail("Should have generated UnsupportedOperationException"); fail("Should have generated UnsupportedOperationException");
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
} }
@ -181,11 +166,7 @@ public class JsonToStringStyleTest {
(Object) new int[]{1, 2, 3}, true).toString()); (Object) new int[]{1, 2, 3}, true).toString());
try { try {
assertEquals( new ToStringBuilder(base).append("a", (Object) new String[]{"v", "x", "y", "z"}, false).toString();
"{\"a\":\"<size=4>\"}",
new ToStringBuilder(base).append("a",
(Object) new String[]{"v", "x", "y", "z"}, false)
.toString());
fail("Should have generated UnsupportedOperationException"); fail("Should have generated UnsupportedOperationException");
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
} }
@ -216,8 +197,7 @@ public class JsonToStringStyleTest {
public void testLong() { public void testLong() {
try { try {
assertEquals("{\"null\":3}", new ToStringBuilder(base).append(3L) new ToStringBuilder(base).append(3L).toString();
.toString());
fail("Should have generated UnsupportedOperationException"); fail("Should have generated UnsupportedOperationException");
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
} }
@ -234,30 +214,26 @@ public class JsonToStringStyleTest {
Object[] array = new Object[]{null, base, new int[]{3, 6}}; Object[] array = new Object[]{null, base, new int[]{3, 6}};
try { try {
assertEquals("{\"null\":[null,5,[3,6]]}", new ToStringBuilder(base) new ToStringBuilder(base).append(array).toString();
.append(array).toString());
fail("Should have generated UnsupportedOperationException"); fail("Should have generated UnsupportedOperationException");
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
} }
try { try {
assertEquals("{\"null\":[null,5,[3,6]]}", new ToStringBuilder(base) new ToStringBuilder(base).append((Object) array).toString();
.append((Object) array).toString());
fail("Should have generated UnsupportedOperationException"); fail("Should have generated UnsupportedOperationException");
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
} }
array = null; array = null;
try { try {
assertEquals("{\"null\":null}", new ToStringBuilder(base).append(array) new ToStringBuilder(base).append(array).toString();
.toString());
fail("Should have generated UnsupportedOperationException"); fail("Should have generated UnsupportedOperationException");
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
} }
try { try {
assertEquals("{\"null\":null}", new ToStringBuilder(base).append((Object) array).toString();
new ToStringBuilder(base).append((Object) array).toString());
fail("Should have generated UnsupportedOperationException"); fail("Should have generated UnsupportedOperationException");
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
} }
@ -268,15 +244,13 @@ public class JsonToStringStyleTest {
long[] array = new long[]{1, 2, -3, 4}; long[] array = new long[]{1, 2, -3, 4};
try { try {
assertEquals("{\"null\":[1,2,-3,4]}", new ToStringBuilder(base).append(array).toString();
new ToStringBuilder(base).append(array).toString());
fail("Should have generated UnsupportedOperationException"); fail("Should have generated UnsupportedOperationException");
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
} }
try { try {
assertEquals("{\"null\":[1,2,-3,4]}", new ToStringBuilder(base).append((Object) array).toString();
new ToStringBuilder(base).append((Object) array).toString());
fail("Should have generated UnsupportedOperationException"); fail("Should have generated UnsupportedOperationException");
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
} }
@ -284,15 +258,13 @@ public class JsonToStringStyleTest {
array = null; array = null;
try { try {
assertEquals("{\"null\":null}", new ToStringBuilder(base).append(array) new ToStringBuilder(base).append(array).toString();
.toString());
fail("Should have generated UnsupportedOperationException"); fail("Should have generated UnsupportedOperationException");
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
} }
try { try {
assertEquals("{\"null\":null}", new ToStringBuilder(base).append((Object) array).toString();
new ToStringBuilder(base).append((Object) array).toString());
fail("Should have generated UnsupportedOperationException"); fail("Should have generated UnsupportedOperationException");
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
} }
@ -303,15 +275,13 @@ public class JsonToStringStyleTest {
long[][] array = new long[][]{{1, 2}, null, {5}}; long[][] array = new long[][]{{1, 2}, null, {5}};
try { try {
assertEquals("{\"null\":[[1,2],null,[5]]}", new ToStringBuilder(base) new ToStringBuilder(base).append(array).toString();
.append(array).toString());
fail("Should have generated UnsupportedOperationException"); fail("Should have generated UnsupportedOperationException");
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
} }
try { try {
assertEquals("{\"null\":[[1,2],null,[5]]}", new ToStringBuilder(base) new ToStringBuilder(base).append((Object) array).toString();
.append((Object) array).toString());
fail("Should have generated UnsupportedOperationException"); fail("Should have generated UnsupportedOperationException");
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
} }
@ -319,15 +289,13 @@ public class JsonToStringStyleTest {
array = null; array = null;
try { try {
assertEquals("{\"null\":null}", new ToStringBuilder(base).append(array) new ToStringBuilder(base).append(array).toString();
.toString());
fail("Should have generated UnsupportedOperationException"); fail("Should have generated UnsupportedOperationException");
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
} }
try { try {
assertEquals("{\"null\":null}", new ToStringBuilder(base).append((Object) array).toString();
new ToStringBuilder(base).append((Object) array).toString());
fail("Should have generated UnsupportedOperationException"); fail("Should have generated UnsupportedOperationException");
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
} }