Search in sources :

Example 36 with TestData

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

the class DataQueriesFromFields method test_5.

@org.junit.Test
public void test_5() {
    final Set<Integer> set = new HashSet<Integer>();
    com.oracle.tck.lib.autd2.TestResult status = com.oracle.tck.lib.autd2.unittests.TU.runTestGroup(new BaseTestGroup() {

        private ValuesHolder4 holder4 = new ValuesHolder4();

        @TestCase
        @TestData("holder4.ints")
        public void test(int i) throws Throwable {
            set.add(i);
        }
    }, TU.EMPTY_ARGV);
    Assert.assertTrue(status.isOK());
    Assert.assertEquals(4, set.size());
    Assert.assertTrue(set.contains(344));
    Assert.assertTrue(set.contains(556));
    Assert.assertTrue(set.contains(655));
    Assert.assertTrue(set.contains(33));
}
Also used : TestData(com.sun.tck.lib.tgf.TestData) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup) TestCase(com.sun.tck.test.TestCase) HashSet(java.util.HashSet)

Example 37 with TestData

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

the class DataQueriesFromFields method test_2.

@org.junit.Test
public void test_2() {
    final Set<Integer> set = new HashSet<Integer>();
    com.oracle.tck.lib.autd2.TestResult status = com.oracle.tck.lib.autd2.unittests.TU.runTestGroup(new BaseTestGroup() {

        private ValuesHolder2 holder2 = new ValuesHolder2();

        @TestCase
        @TestData("holder2.holder.setup")
        public void test(int i) throws Throwable {
            set.add(i);
        }
    }, TU.EMPTY_ARGV);
    Assert.assertTrue(status.isOK());
    Assert.assertEquals(4, set.size());
    Assert.assertTrue(set.contains(1));
    Assert.assertTrue(set.contains(3));
    Assert.assertTrue(set.contains(7));
    Assert.assertTrue(set.contains(9));
}
Also used : TestData(com.sun.tck.lib.tgf.TestData) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup) TestCase(com.sun.tck.test.TestCase) HashSet(java.util.HashSet)

Example 38 with TestData

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

the class IteratorAsSupportedDataContainer method iteratorAsReturnType_strings.

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

        Iterator<Object[]> stringITerator = Arrays.<Object[]>asList(new String[] { "a", "b" }, new String[] { "v", "n" }).iterator();

        @TestCase
        @TestData("stringITerator")
        public void test(String i, String 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("a", is.get(0));
    Assert.assertEquals("b", js.get(0));
    Assert.assertEquals("v", is.get(1));
    Assert.assertEquals("n", 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 39 with TestData

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

the class IteratorAsSupportedDataContainer method test_04_IteratorOfIntegers.

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

        Iterator<Integer> component() {
            return IntStream.range(55, 67).iterator();
        }

        int counter;

        @TestCase
        @Operation(MULTIPLY)
        public void test(@TestData("component") int r, @TestData("component") int g, @TestData("component") int b) {
            Color color = new Color(r, g, b);
            assertEquals(r, color.getRed());
            assertEquals(g, color.getGreen());
            assertEquals(b, color.getBlue());
            counter++;
        }
    }
    Test tg = new Test();
    com.oracle.tck.lib.autd2.TestResult s = TU.runTestGroup(tg);
    Assert.assertTrue(s.isOK());
    Assert.assertEquals(1728, tg.counter);
    Assert.assertEquals("test cases: 1; all passed", s.getMessage());
}
Also used : TestData(com.sun.tck.lib.tgf.TestData) Test(org.junit.Test) Color(java.awt.Color) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup) TestGroup(com.sun.tck.test.TestGroup) Test(org.junit.Test)

Example 40 with TestData

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

the class InvalidTestCases method noTestCaseAnn_onlyTestData_05.

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

            @TestData("blabla")
            protected void myTest01(int i) {
            }

            @TestCase
            public 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 + "myTest01\".", 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