aboutsummaryrefslogtreecommitdiff
path: root/gson/src/test/java/com/google/gson/FieldAttributesTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'gson/src/test/java/com/google/gson/FieldAttributesTest.java')
-rw-r--r--gson/src/test/java/com/google/gson/FieldAttributesTest.java20
1 files changed, 15 insertions, 5 deletions
diff --git a/gson/src/test/java/com/google/gson/FieldAttributesTest.java b/gson/src/test/java/com/google/gson/FieldAttributesTest.java
index 31be3e28..2cc362d2 100644
--- a/gson/src/test/java/com/google/gson/FieldAttributesTest.java
+++ b/gson/src/test/java/com/google/gson/FieldAttributesTest.java
@@ -16,11 +16,17 @@
package com.google.gson;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Modifier;
import java.lang.reflect.Type;
import java.util.List;
-import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
/**
* Unit tests for the {@link FieldAttributes} class.
@@ -28,16 +34,16 @@ import junit.framework.TestCase;
* @author Inderjeet Singh
* @author Joel Leitch
*/
-public class FieldAttributesTest extends TestCase {
+public class FieldAttributesTest {
private FieldAttributes fieldAttributes;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
fieldAttributes = new FieldAttributes(Foo.class.getField("bar"));
}
@SuppressWarnings("unused")
+ @Test
public void testNullField() throws Exception {
try {
new FieldAttributes(null);
@@ -45,10 +51,12 @@ public class FieldAttributesTest extends TestCase {
} catch (NullPointerException expected) { }
}
+ @Test
public void testDeclaringClass() throws Exception {
assertEquals(Foo.class, fieldAttributes.getDeclaringClass());
}
+ @Test
public void testModifiers() throws Exception {
assertFalse(fieldAttributes.hasModifier(Modifier.STATIC));
assertFalse(fieldAttributes.hasModifier(Modifier.FINAL));
@@ -60,10 +68,12 @@ public class FieldAttributesTest extends TestCase {
assertTrue(fieldAttributes.hasModifier(Modifier.TRANSIENT));
}
+ @Test
public void testName() throws Exception {
assertEquals("bar", fieldAttributes.getName());
}
+ @Test
public void testDeclaredTypeAndClass() throws Exception {
Type expectedType = new TypeToken<List<String>>() {}.getType();
assertEquals(expectedType, fieldAttributes.getDeclaredType());