Search in sources :

Example 41 with TestData

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

the class Examples method test_02.

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

        Values spaces = createColumn(RED, GREEN, WHITE).filter(Color::getColorSpace);

        @TestCase
        public void test(@TestData("spaces") ColorSpace cs) {
            Assert.assertTrue(cs.isCS_sRGB());
        }
    }
    TestResult testResult = TU.runTestGroup(new Test());
    Assert.assertTrue(testResult.isOK());
    Assert.assertEquals("test cases: 1; all passed", testResult.getMessage());
}
Also used : TestData(com.sun.tck.lib.tgf.TestData) Test(org.junit.Test) ColorSpace(java.awt.color.ColorSpace) Values(com.sun.tck.lib.tgf.Values) TestGroup(com.sun.tck.test.TestGroup) TestResult(com.oracle.tck.lib.autd2.TestResult) Test(org.junit.Test)

Example 42 with TestData

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

the class Examples method test_03_array.

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

        Values quantities = createColumn(new Color[] { BLUE, BLACK, WHITE }, new Color[] { BLACK, WHITE, BLUE, GREEN }, new Color[] { BLUE, BLACK }, new Color[] { RED }).<Color[]>filter(colors -> createRow(colors.length));

        @TestCase
        @TestData("quantities")
        public void test(int quantity) {
            assertTrue(quantity > 0);
        }
    }
    com.oracle.tck.lib.autd2.TestResult s = TU.runTestGroup(new Test());
    Assert.assertTrue(s.isOK());
    Assert.assertEquals("test cases: 1; all passed", s.getMessage());
}
Also used : Color(java.awt.Color) IntStream(java.util.stream.IntStream) TestData(com.sun.tck.lib.tgf.TestData) DataFactory(com.sun.tck.lib.tgf.DataFactory) Arrays(java.util.Arrays) Longs(com.sun.tck.lib.tgf.data.Longs) MULTIPLY(com.sun.tck.lib.tgf.data.Operation.TYPE.MULTIPLY) Test(org.junit.Test) TestResult(com.oracle.tck.lib.autd2.TestResult) ColorSpace(java.awt.color.ColorSpace) Operation(com.sun.tck.lib.tgf.data.Operation) TestGroup(com.sun.tck.test.TestGroup) RandomAccess(java.util.RandomAccess) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) TestCase(com.sun.tck.test.TestCase) DataFactory.createRow(com.sun.tck.lib.tgf.DataFactory.createRow) Transform(com.sun.tck.lib.tgf.Transform) ExpectedExceptions(com.sun.tck.lib.ExpectedExceptions) Values(com.sun.tck.lib.tgf.Values) Assert(org.junit.Assert) Assert.assertTrue(com.sun.tck.lib.Assert.assertTrue) DataFactory.createColumn(com.sun.tck.lib.tgf.DataFactory.createColumn) Assert.assertEquals(com.sun.tck.lib.Assert.assertEquals) Test(org.junit.Test) Color(java.awt.Color) Values(com.sun.tck.lib.tgf.Values) TestGroup(com.sun.tck.test.TestGroup) TestResult(com.oracle.tck.lib.autd2.TestResult) Test(org.junit.Test)

Example 43 with TestData

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

the class Multiply method testRun_DataFilteredOutCompletely4.

@Test
public void testRun_DataFilteredOutCompletely4() {
    final ArrayList<String> arrayList = new ArrayList<String>();
    com.oracle.tck.lib.autd2.TestResult status = com.oracle.tck.lib.autd2.unittests.TU.runTestGroup(new BaseTestGroup() {

        Values setupOne() {
            return DataFactory.createColumn().multiply(1, 2, 3);
        }

        @TestCase
        @TestData("setupOne")
        public void myTest(String s) {
            arrayList.add(s);
        }
    }, TU.EMPTY_ARGV);
    Assert.assertEquals(0, arrayList.size());
    Assert.assertTrue(status.isOK());
    Assert.assertEquals("Passed. test cases: 1; all passed", status.toString());
}
Also used : TestData(com.sun.tck.lib.tgf.TestData) TestCase(com.sun.tck.test.TestCase) ArrayList(java.util.ArrayList) Values(com.sun.tck.lib.tgf.Values) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup) Test(org.junit.Test)

Example 44 with TestData

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

the class TestAfter method runtimeSkippingFromAfter_testPasses.

@Test
public void runtimeSkippingFromAfter_testPasses() {
    final boolean[] afterCalled = new boolean[1];
    final boolean[] methodCalled = new boolean[1];
    final int[] counter = new int[] { 0 };
    final int[] afterCounter = new int[] { 0 };
    com.oracle.tck.lib.autd2.TestResult status = com.oracle.tck.lib.autd2.unittests.TU.runTestGroup(new TestAfter.Mytest() {

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

        private void myAfter() {
            org.junit.Assert.assertTrue(methodCalled[0]);
            // to be sure that it was called only once
            org.junit.Assert.assertFalse(afterCalled[0]);
            afterCalled[0] = true;
            afterCounter[0]++;
            com.sun.tck.lib.Assert.reportNotApplicable(true);
        }

        @TestCase
        @TestData("mySetup")
        @com.sun.tck.lib.tgf.After("myAfter")
        public void test(int i) {
            org.junit.Assert.assertFalse(afterCalled[0]);
            methodCalled[0] = true;
            counter[0]++;
        }
    }, TU.EMPTY_ARGV);
    assertTrue(status.isOK());
    assertEquals("test cases: 1; all not applicable", status.getMessage());
    assertTrue(afterCalled[0]);
    assertTrue(methodCalled[0]);
    assertEquals(3, counter[0]);
    assertEquals(1, afterCounter[0]);
}
Also used : TestData(com.sun.tck.lib.tgf.TestData) Values(com.sun.tck.lib.tgf.Values) TestResult(com.oracle.tck.lib.autd2.TestResult) TestCase(com.sun.tck.test.TestCase) Test(org.junit.Test)

Example 45 with TestData

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

the class TestAfter method afterCalledOnce.

@Test
public void afterCalledOnce() {
    final boolean[] afterCalled = new boolean[1];
    final boolean[] methodCalled = new boolean[1];
    final int[] counter = new int[] { 0 };
    final int[] afterCounter = new int[] { 0 };
    com.oracle.tck.lib.autd2.TestResult status = com.oracle.tck.lib.autd2.unittests.TU.runTestGroup(new TestAfter.Mytest() {

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

        private void myAfter() {
            org.junit.Assert.assertTrue(methodCalled[0]);
            // to be sure that it was called only once
            org.junit.Assert.assertFalse(afterCalled[0]);
            afterCalled[0] = true;
            afterCounter[0]++;
        }

        @TestCase
        @TestData("mySetup")
        @com.sun.tck.lib.tgf.After("myAfter")
        public void test(int i) {
            org.junit.Assert.assertFalse(afterCalled[0]);
            methodCalled[0] = true;
            counter[0]++;
        }
    }, TU.EMPTY_ARGV);
    assertTrue(status.isOK());
    assertTrue(afterCalled[0]);
    assertTrue(methodCalled[0]);
    assertEquals(3, counter[0]);
    assertEquals(1, afterCounter[0]);
}
Also used : TestData(com.sun.tck.lib.tgf.TestData) Values(com.sun.tck.lib.tgf.Values) TestResult(com.oracle.tck.lib.autd2.TestResult) TestCase(com.sun.tck.test.TestCase) 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