FieldReaderTest.java revision 2637d96c202372854a7c71466ddcc6e90fc4fc53
1/* 2 * Copyright (c) 2007 Mockito contributors 3 * This program is made available under the terms of the MIT License. 4 */ 5package org.mockito.internal.util.reflection; 6 7import org.junit.Test; 8import org.mockitoutil.TestBase; 9 10import static junit.framework.TestCase.assertFalse; 11import static junit.framework.TestCase.assertTrue; 12 13@SuppressWarnings("unused") 14public class FieldReaderTest extends TestBase { 15 16 class Foo { 17 private final String isNull = null; 18 private final String notNull = ""; 19 } 20 21 @Test 22 public void shouldKnowWhenNull() throws Exception { 23 //when 24 FieldReader reader = new FieldReader(new Foo(), Foo.class.getDeclaredField("isNull")); 25 //then 26 assertTrue(reader.isNull()); 27 } 28 29 @Test 30 public void shouldKnowWhenNotNull() throws Exception { 31 //when 32 FieldReader reader = new FieldReader(new Foo(), Foo.class.getDeclaredField("notNull")); 33 //then 34 assertFalse(reader.isNull()); 35 } 36} 37