| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 
 |  
import static org.junit.Assert.assertEquals;
 
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
 
import org.junit.Test;
 
public class ManyGetterTest {
 
	@Test
	public void testGetters() {
		ManyGetter foo = new ManyGetter();
		Class fooClass = foo.getClass();
		String methodName = "setJour";
		Method method = null;
 
		try {
			for (int i = 1; i <= 2; i++){
				method = fooClass.getMethod(methodName + i, Integer.class);
				method.invoke(foo, 1);
			}
		} catch (SecurityException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NoSuchMethodException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
 
		assertEquals(1, foo.getJour1());
		assertEquals(1, foo.getJour1());
 
	}
 
} | 
Partager