01: package test.dataprovider;
02:
03: import java.util.Iterator;
04:
05: import org.testng.Assert;
06:
07: public class IterableTest {
08: private boolean m_ok1 = false;
09: private boolean m_ok2 = false;
10:
11: public static final String FN2 = "Anne Marie";
12: public static final Integer LN2 = new Integer(37);
13: public static final String FN1 = "Cedric";
14: public static final Integer LN1 = new Integer(36);
15:
16: public static final Object[][] DATA = new Object[][] {
17: new Object[] { FN1, LN1 }, new Object[] { FN2, LN2 }, };
18:
19: /**
20: * @testng.data-provider name="test1"
21: */
22: public Iterator createData() {
23: return new MyIterator(DATA);
24: }
25:
26: /**
27: * @testng.test dataProvider="test1"
28: */
29: public void verifyNames(String firstName, Integer age) {
30: if (firstName.equals(FN1) && age.equals(LN1)) {
31: m_ok1 = true;
32: Assert.assertEquals(MyIterator.getCount(), 1);
33: }
34: if (firstName.equals(FN2) && age.equals(LN2)) {
35: m_ok2 = true;
36: Assert.assertEquals(MyIterator.getCount(), 2);
37: }
38: }
39:
40: /**
41: * @testng.test dependsOnMethods = "verifyNames"
42: */
43: public void verifyCount() {
44: Assert.assertTrue(m_ok1 && m_ok2);
45: }
46:
47: private static void ppp(String s) {
48: System.out.println("[IterableTest] " + s);
49: }
50: }
|