Port to JUnit 4. Not 100% done.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1142704 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
765297b79c
commit
e883181ff4
|
@ -93,20 +93,16 @@ public class FieldUtilsTest {
|
|||
assertNull(FieldUtils.getField(PrivatelyShadowedChild.class, "b"));
|
||||
assertNull(FieldUtils.getField(PrivatelyShadowedChild.class, "i"));
|
||||
assertNull(FieldUtils.getField(PrivatelyShadowedChild.class, "d"));
|
||||
}
|
||||
|
||||
try {
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testGetFieldIllegalArgumentException1() {
|
||||
FieldUtils.getField(null, "none");
|
||||
fail("null class should cause an IllegalArgumentException");
|
||||
} catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
}
|
||||
|
||||
try {
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testGetFieldIllegalArgumentException2() {
|
||||
FieldUtils.getField(PublicChild.class, null);
|
||||
fail("null field name should cause an IllegalArgumentException");
|
||||
} catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -134,20 +130,16 @@ public class FieldUtilsTest {
|
|||
.getDeclaringClass());
|
||||
assertEquals(PrivatelyShadowedChild.class, FieldUtils.getField(PrivatelyShadowedChild.class, "d", true)
|
||||
.getDeclaringClass());
|
||||
}
|
||||
|
||||
try {
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testGetFieldForceAccessIllegalArgumentException1() {
|
||||
FieldUtils.getField(null, "none", true);
|
||||
fail("null class should cause an IllegalArgumentException");
|
||||
} catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
}
|
||||
|
||||
try {
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testGetFieldForceAccessIllegalArgumentException2() {
|
||||
FieldUtils.getField(PublicChild.class, null, true);
|
||||
fail("null field name should cause an IllegalArgumentException");
|
||||
} catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -171,20 +163,16 @@ public class FieldUtilsTest {
|
|||
assertNull(FieldUtils.getDeclaredField(PrivatelyShadowedChild.class, "b"));
|
||||
assertNull(FieldUtils.getDeclaredField(PrivatelyShadowedChild.class, "i"));
|
||||
assertNull(FieldUtils.getDeclaredField(PrivatelyShadowedChild.class, "d"));
|
||||
}
|
||||
|
||||
try {
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testGetDeclaredFieldAccessIllegalArgumentException1() {
|
||||
FieldUtils.getDeclaredField(null, "none");
|
||||
fail("null class should cause an IllegalArgumentException");
|
||||
} catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
}
|
||||
|
||||
try {
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testGetDeclaredFieldAccessIllegalArgumentException2() {
|
||||
FieldUtils.getDeclaredField(PublicChild.class, null);
|
||||
fail("null field name should cause an IllegalArgumentException");
|
||||
} catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -213,64 +201,52 @@ public class FieldUtilsTest {
|
|||
.getDeclaringClass());
|
||||
assertEquals(PrivatelyShadowedChild.class, FieldUtils.getDeclaredField(PrivatelyShadowedChild.class, "d", true)
|
||||
.getDeclaringClass());
|
||||
}
|
||||
|
||||
try {
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testGetDeclaredFieldForceAccessIllegalArgumentException1() {
|
||||
FieldUtils.getDeclaredField(null, "none", true);
|
||||
fail("null class should cause an IllegalArgumentException");
|
||||
} catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
}
|
||||
|
||||
try {
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testGetDeclaredFieldForceAccessIllegalArgumentException2() {
|
||||
FieldUtils.getDeclaredField(PublicChild.class, null, true);
|
||||
fail("null field name should cause an IllegalArgumentException");
|
||||
} catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadStaticField() throws Exception {
|
||||
assertEquals(Foo.VALUE, FieldUtils.readStaticField(FieldUtils.getField(Foo.class, "VALUE")));
|
||||
|
||||
try {
|
||||
FieldUtils.readStaticField(null);
|
||||
fail("null field should cause an IllegalArgumentException");
|
||||
} catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
}
|
||||
|
||||
try {
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testReadStaticFieldIllegalArgumentException1() throws Exception {
|
||||
FieldUtils.readStaticField(null);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testReadStaticFieldIllegalArgumentException2() throws Exception {
|
||||
assertEquals(Foo.VALUE, FieldUtils.readStaticField(FieldUtils.getField(Foo.class, "VALUE")));
|
||||
Field nonStaticField = FieldUtils.getField(PublicChild.class, "s");
|
||||
assumeNotNull(nonStaticField);
|
||||
FieldUtils.readStaticField(nonStaticField);
|
||||
fail("non-static field should cause an IllegalArgumentException");
|
||||
} catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadStaticFieldForceAccess() throws Exception {
|
||||
assertEquals(Foo.VALUE, FieldUtils.readStaticField(FieldUtils.getField(Foo.class, "VALUE")));
|
||||
assertEquals(Foo.VALUE, FieldUtils.readStaticField(FieldUtils.getField(PublicChild.class, "VALUE")));
|
||||
|
||||
try {
|
||||
FieldUtils.readStaticField(null, true);
|
||||
fail("null field should cause an IllegalArgumentException");
|
||||
} catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
}
|
||||
|
||||
try {
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testReadStaticFieldForceAccessIllegalArgumentException1() throws Exception {
|
||||
FieldUtils.readStaticField(null, true);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testReadStaticFieldForceAccessIllegalArgumentException2() throws Exception {
|
||||
Field nonStaticField = FieldUtils.getField(PublicChild.class, "s", true);
|
||||
assumeNotNull(nonStaticField);
|
||||
FieldUtils.readStaticField(nonStaticField);
|
||||
fail("non-static field should cause an IllegalArgumentException");
|
||||
} catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue