Suppress warnings for unread/unused fields

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@754493 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sebastian Bazley 2009-03-14 17:01:21 +00:00
parent 1c224cbdd2
commit d744105cdb
5 changed files with 15 additions and 0 deletions

View File

@ -356,6 +356,7 @@ public class CharRangeTest extends TestCase {
public void testContainsNullArg() {
CharRange range = new CharRange('a');
try {
@SuppressWarnings("unused")
boolean contains = range.contains(null);
} catch(IllegalArgumentException e) {
assertEquals("The Range must not be null", e.getMessage());

View File

@ -1651,12 +1651,14 @@ public class StringUtilsTest extends TestCase {
assertEquals(8, StringUtils.getLevenshteinDistance("zzzzzzzz", "hippo") );
assertEquals(1, StringUtils.getLevenshteinDistance("hello", "hallo") );
try {
@SuppressWarnings("unused")
int d = StringUtils.getLevenshteinDistance("a", null);
fail("expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
// empty
}
try {
@SuppressWarnings("unused")
int d = StringUtils.getLevenshteinDistance(null, "a");
fail("expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {

View File

@ -126,6 +126,7 @@ public class EqualsBuilderTest extends TestCase {
}
static class TestTSubObject extends TestObject {
@SuppressWarnings("unused")
private transient int t;
public TestTSubObject(int a, int t) {
super(a);
@ -134,6 +135,7 @@ public class EqualsBuilderTest extends TestCase {
}
static class TestTTSubObject extends TestTSubObject {
@SuppressWarnings("unused")
private transient int tt;
public TestTTSubObject(int a, int t, int tt) {
super(a, t);
@ -142,6 +144,7 @@ public class EqualsBuilderTest extends TestCase {
}
static class TestTTLeafObject extends TestTTSubObject {
@SuppressWarnings("unused")
private int leafValue;
public TestTTLeafObject(int a, int t, int tt, int leafValue) {
super(a, t, tt);
@ -998,8 +1001,11 @@ public class EqualsBuilderTest extends TestCase {
}
static class TestObjectWithMultipleFields {
@SuppressWarnings("unused")
private TestObject one;
@SuppressWarnings("unused")
private TestObject two;
@SuppressWarnings("unused")
private TestObject three;
public TestObjectWithMultipleFields(int one, int two, int three) {

View File

@ -33,8 +33,10 @@ import org.apache.commons.lang.ArrayUtils;
public class ReflectionToStringBuilderExcludeTest extends TestCase {
class TestFixture {
@SuppressWarnings("unused")
private String secretField = SECRET_VALUE;
@SuppressWarnings("unused")
private String showField = NOT_SECRET_VALUE;
}

View File

@ -169,6 +169,7 @@ public abstract class AbstractNestableTest extends TestCase
// Test for index out of bounds
try
{
@SuppressWarnings("unused")
String msg = ne.getMessage(-1);
fail("getMessage(-1) should have thrown IndexOutOfBoundsException");
}
@ -177,6 +178,7 @@ public abstract class AbstractNestableTest extends TestCase
}
try
{
@SuppressWarnings("unused")
String msg = ne.getMessage(msgs.length + 100);
fail("getMessage(999) should have thrown IndexOutOfBoundsException");
}
@ -429,6 +431,7 @@ public abstract class AbstractNestableTest extends TestCase
// Test for index out of bounds
try
{
@SuppressWarnings("unused")
int index = n.indexOfThrowable(getTester1Class(), -1);
fail("method should have thrown IndexOutOfBoundsException");
}
@ -437,6 +440,7 @@ public abstract class AbstractNestableTest extends TestCase
}
try
{
@SuppressWarnings("unused")
int index = n.indexOfThrowable(getTester1Class(), 5);
fail("method should have thrown IndexOutOfBoundsException");
}