Search in sources :

Example 56 with TestData

use of com.sun.tck.lib.tgf.TestData in project jtharness by openjdk.

the class IteratorAsSupportedDataContainer method iteratorAsReturnType_ints_2.

@org.junit.Test
public void iteratorAsReturnType_ints_2() {
    final List<Integer> is = new ArrayList<Integer>();
    com.oracle.tck.lib.autd2.TestResult status = com.oracle.tck.lib.autd2.unittests.TU.runTestGroup(new BaseTestGroup() {

        Iterator<Integer[]> intIterator = Arrays.<Integer[]>asList(new Integer[] { 89898 }, new Integer[] { 34324 }, new Integer[] { 34 }).iterator();

        @TestCase
        @TestData("intIterator")
        public void test(int i) throws Throwable {
            is.add(i);
        }
    }, TU.EMPTY_ARGV);
    Assert.assertTrue(status.isOK());
    Assert.assertEquals(3, is.size());
    Assert.assertEquals(89898, (int) is.get(0));
    Assert.assertEquals(34324, (int) is.get(1));
    Assert.assertEquals(34, (int) is.get(2));
}
Also used : TestData(com.sun.tck.lib.tgf.TestData) ArrayList(java.util.ArrayList) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup) TestCase(com.sun.tck.test.TestCase) Test(org.junit.Test)

Example 57 with TestData

use of com.sun.tck.lib.tgf.TestData in project jtharness by openjdk.

the class IteratorAsSupportedDataContainer method test_04_IteratorOfIntegers_01.

@Test
public void test_04_IteratorOfIntegers_01() {
    @TestGroup
    class Test {

        Iterator<Integer> component = Arrays.asList(1, 2, 3, 4, 5).iterator();

        int counter = 0;

        @TestCase
        public void test(@TestData("component") int x) {
            counter++;
        }
    }
    Test tg = new Test();
    com.oracle.tck.lib.autd2.TestResult s = TU.runTestGroup(tg);
    Assert.assertTrue(s.isOK());
    Assert.assertEquals(5, tg.counter);
    Assert.assertEquals("test cases: 1; all passed", s.getMessage());
}
Also used : TestData(com.sun.tck.lib.tgf.TestData) Test(org.junit.Test) Iterator(java.util.Iterator) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup) TestGroup(com.sun.tck.test.TestGroup) Test(org.junit.Test)

Example 58 with TestData

use of com.sun.tck.lib.tgf.TestData in project jtharness by openjdk.

the class IteratorAsSupportedDataContainer method iteratorAsReturnType_ints.

@org.junit.Test
public void iteratorAsReturnType_ints() {
    final List<Integer> is = new ArrayList<Integer>();
    final List<Integer> js = new ArrayList<Integer>();
    com.oracle.tck.lib.autd2.TestResult status = com.oracle.tck.lib.autd2.unittests.TU.runTestGroup(new BaseTestGroup() {

        Iterator<Object[]> intIterator = Arrays.<Object[]>asList(new Integer[] { 89898, 176253 }, new Integer[] { 34324, 343424 }).iterator();

        @TestCase
        @TestData("intIterator")
        public void test(int i, int j) throws Throwable {
            is.add(i);
            js.add(j);
        }
    }, TU.EMPTY_ARGV);
    Assert.assertTrue(status.isOK());
    Assert.assertEquals(2, is.size());
    Assert.assertEquals(2, js.size());
    Assert.assertEquals(89898, (int) is.get(0));
    Assert.assertEquals(176253, (int) js.get(0));
    Assert.assertEquals(34324, (int) is.get(1));
    Assert.assertEquals(343424, (int) js.get(1));
}
Also used : TestData(com.sun.tck.lib.tgf.TestData) ArrayList(java.util.ArrayList) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup) TestCase(com.sun.tck.test.TestCase) Test(org.junit.Test)

Example 59 with TestData

use of com.sun.tck.lib.tgf.TestData in project jtharness by openjdk.

the class InvalidTestCases method noTestCaseAnn_onlyTestData_02.

@Test
public void noTestCaseAnn_onlyTestData_02() {
    try {
        com.oracle.tck.lib.autd2.TestResult status = com.oracle.tck.lib.autd2.unittests.TU.runTestGroup(new BaseTestGroup() {

            @TestData("something")
            private void myTest02() {
            }
        }, TU.EMPTY_ARGV);
        Assert.fail("IAE was not thrown");
    } catch (IllegalArgumentException e) {
        assertEquals(MARKING_METHOD_ONLY_WITH_TEST_DATA_IS_NOT_ALLOWED_PLEASE_ADD_TEST_CASE_ANNOTATION_TO_METHOD + "myTest02\".", e.getMessage());
    }
}
Also used : TestData(com.sun.tck.lib.tgf.TestData) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup) Test(org.junit.Test)

Example 60 with TestData

use of com.sun.tck.lib.tgf.TestData in project jtharness by openjdk.

the class InvalidTestCases method overLoaded_message.

@Test
public void overLoaded_message() {
    try {
        com.oracle.tck.lib.autd2.TestResult status = com.oracle.tck.lib.autd2.unittests.TU.runTestGroup(new BaseTestGroup() {

            @TestCase
            @TestData("something")
            public void myTest(int i) {
            }

            @TestCase
            @TestData("something")
            public void myTest(String s) {
            }
        }, TU.EMPTY_ARGV);
        Assert.fail("Exception was not thrown");
    } catch (IllegalArgumentException e) {
        assertEquals("Overloaded testcases are not supported. Method \"myTest\" is overloaded.", e.getMessage());
    }
}
Also used : TestData(com.sun.tck.lib.tgf.TestData) TestCase(com.sun.tck.test.TestCase) NonTestCase(com.oracle.tck.lib.autd2.NonTestCase) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup) Test(org.junit.Test)

Aggregations

TestData (com.sun.tck.lib.tgf.TestData)64 TestCase (com.sun.tck.test.TestCase)57 BaseTestGroup (com.oracle.tck.lib.autd2.unittests.BaseTestGroup)50 Test (org.junit.Test)37 ArrayList (java.util.ArrayList)30 Values (com.sun.tck.lib.tgf.Values)22 TestResult (com.oracle.tck.lib.autd2.TestResult)14 TestGroup (com.sun.tck.test.TestGroup)7 NonTestCase (com.oracle.tck.lib.autd2.NonTestCase)5 HashSet (java.util.HashSet)5 Color (java.awt.Color)4 List (java.util.List)4 ColorSpace (java.awt.color.ColorSpace)3 Collectors.toList (java.util.stream.Collectors.toList)3 Assert.assertEquals (com.sun.tck.lib.Assert.assertEquals)2 Assert.assertTrue (com.sun.tck.lib.Assert.assertTrue)2 ExpectedExceptions (com.sun.tck.lib.ExpectedExceptions)2 DataFactory (com.sun.tck.lib.tgf.DataFactory)2 DataFactory.createColumn (com.sun.tck.lib.tgf.DataFactory.createColumn)2 DataFactory.createRow (com.sun.tck.lib.tgf.DataFactory.createRow)2