Search in sources :

Example 16 with TestData

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

the class Exclusion method check_ExcludeWholeTest.

private void check_ExcludeWholeTest(String... args) {
    final int[] methodCounter = new int[] { 0 };
    com.oracle.tck.lib.autd2.TestResult status = com.oracle.tck.lib.autd2.unittests.TU.runTestGroup(new BaseTestGroup() {

        protected Values mySetup() {
            return DataFactory.createColumn(1, 2, 3);
        }

        @TestCase
        @TestData("mySetup")
        public void myTest(int i) {
            methodCounter[0]++;
        }
    }, args);
    Assert.assertTrue(status.isOK());
    Assert.assertEquals(0, methodCounter[0]);
}
Also used : TestData(com.sun.tck.lib.tgf.TestData) TestCase(com.sun.tck.test.TestCase) Values(com.sun.tck.lib.tgf.Values) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup)

Example 17 with TestData

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

the class Exclusion method check_2.

private void check_2(String... args) {
    final int[] methodCounter = new int[] { 0 };
    final int[] blablaCounter = new int[] { 0 };
    final int[] fooCounter = new int[] { 0 };
    com.oracle.tck.lib.autd2.TestResult status = com.oracle.tck.lib.autd2.unittests.TU.runTestGroup(new BaseTestGroup() {

        protected Values mySetup() {
            return DataFactory.createColumn(11, 22, 33, 44, 55);
        }

        @TestCase
        @TestData("mySetup")
        public void myTest(int i) {
            methodCounter[0]++;
        }

        @TestCase
        @TestData("mySetup")
        public void blabla(int i) {
            blablaCounter[0]++;
        }

        @TestCase
        @TestData("mySetup")
        public void foo(int i) {
            fooCounter[0]++;
        }
    }, args);
    Assert.assertTrue(status.isOK());
    Assert.assertEquals(5, methodCounter[0]);
    Assert.assertEquals(0, blablaCounter[0]);
    Assert.assertEquals(0, fooCounter[0]);
}
Also used : TestData(com.sun.tck.lib.tgf.TestData) TestCase(com.sun.tck.test.TestCase) Values(com.sun.tck.lib.tgf.Values) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup)

Example 18 with TestData

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

the class Exclusion method check_Mixed_4.

private void check_Mixed_4(List<Integer> allData, List<Integer> expectedPassedToTestCase, String expectedStatusMessage, final int expectedMyTestCounter, final int expectedBlablaCounter, String... args) {
    final int[] myTestCounter = new int[] { 0 };
    final int[] blablaCounter = new int[] { 0 };
    final int[] fooCounter = new int[] { 0 };
    com.oracle.tck.lib.autd2.TestResult status = com.oracle.tck.lib.autd2.unittests.TU.runTestGroup(new BaseTestGroup() {

        private List mySetup() {
            return allData;
        }

        @TestCase
        public void myTest() {
            myTestCounter[0]++;
        }

        @TestCase
        public void blabla() {
            blablaCounter[0]++;
        }

        @TestCase
        @TestData("mySetup")
        public void foo(int i) {
            Assert.assertEquals((int) expectedPassedToTestCase.get(fooCounter[0]), i);
            fooCounter[0]++;
        }
    }, args);
    Assert.assertTrue(status.isOK());
    Assert.assertEquals(expectedStatusMessage, status.toString());
    Assert.assertEquals(expectedMyTestCounter, myTestCounter[0]);
    Assert.assertEquals(expectedBlablaCounter, blablaCounter[0]);
    Assert.assertEquals(expectedPassedToTestCase.size(), fooCounter[0]);
}
Also used : TestData(com.sun.tck.lib.tgf.TestData) TestCase(com.sun.tck.test.TestCase) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup) List(java.util.List) ArrayList(java.util.ArrayList)

Example 19 with TestData

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

the class Exclusion method test_excludedArg.

@Test
public void test_excludedArg() {
    final int[] methodCounter = new int[] { 0 };
    final ArrayList<Integer> expectedArgValues = new ArrayList<Integer>() {

        {
            add(2);
            add(3);
        }
    };
    com.oracle.tck.lib.autd2.TestResult status = com.oracle.tck.lib.autd2.unittests.TU.runTestGroup(new BaseTestGroup() {

        protected Values mySetup() {
            return DataFactory.createColumn(1, 2, 3);
        }

        @TestCase
        @TestData("mySetup")
        public void myTest(int i) {
            Assert.assertTrue(i + " is not among expected", expectedArgValues.contains(i));
            methodCounter[0]++;
        }
    }, new String[] { EXCLUDE_WORD, "myTest" });
    Assert.assertTrue(status.isOK());
    Assert.assertEquals(0, methodCounter[0]);
}
Also used : TestData(com.sun.tck.lib.tgf.TestData) ArrayList(java.util.ArrayList) Values(com.sun.tck.lib.tgf.Values) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup) TestCase(com.sun.tck.test.TestCase) Test(org.junit.Test)

Example 20 with TestData

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

the class Examples method test_04.

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

        List<Integer> component = IntStream.range(55, 99).boxed().collect(toList());

        int counter = 0;

        @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(85184, 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) TestGroup(com.sun.tck.test.TestGroup) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) TestResult(com.oracle.tck.lib.autd2.TestResult) 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