Search in sources :

Example 26 with TestGroup

use of com.sun.tck.test.TestGroup in project jtharness by openjdk.

the class FailingSimpleTestCases method ExceptionsThrownFromStatus_01.

@Test
public void ExceptionsThrownFromStatus_01() {
    final AtomicBoolean testCase_1_called = new AtomicBoolean();
    final AtomicBoolean testCase_2_called = new AtomicBoolean();
    final AtomicBoolean testCase_3_called = new AtomicBoolean();
    @TestGroup
    class TestGr {

        @TestCase
        public void test1() {
            testCase_1_called.set(true);
        }

        @TestCase
        public Status test2() {
            testCase_2_called.set(true);
            throw new RuntimeException();
        }

        @TestCase
        public Status test3() {
            testCase_3_called.set(true);
            return Status.passed("Well. OK");
        }
    }
    TestResult s = TU.runTestGroup(new TestGr(), TU.EMPTY_ARGV);
    Assert.assertTrue(!s.isOK());
    Assert.assertTrue(testCase_1_called.get());
    Assert.assertTrue(testCase_2_called.get());
    Assert.assertTrue(testCase_3_called.get());
    Assert.assertEquals("test cases: 3; passed: 2; failed: 1; failed: [test2]", s.getMessage());
    testCase_1_called.set(false);
    testCase_2_called.set(false);
    testCase_3_called.set(false);
    PrintWriter log = new PrintWriter(System.err, true);
    PrintWriter ref = new PrintWriter(System.out, true);
    s = TU.runTestGroup(new TestGr());
    Assert.assertTrue(!s.isOK());
    Assert.assertTrue(testCase_1_called.get());
    Assert.assertTrue(testCase_2_called.get());
    Assert.assertTrue(testCase_3_called.get());
    Assert.assertEquals("test cases: 3; passed: 2; failed: 1; failed: [test2]", s.getMessage());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) TestGroup(com.sun.tck.test.TestGroup) TestResult(com.oracle.tck.lib.autd2.TestResult) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Example 27 with TestGroup

use of com.sun.tck.test.TestGroup in project jtharness by openjdk.

the class FailingSimpleTestCases method testedAPI_package.

@Test
public void testedAPI_package() {
    @TestedAPI(testedPackage = "x.e.r")
    @TestGroup
    class MyTest {

        @TestCase
        @TestedStatement("a statement")
        public void testCase() {
            Assert.fail();
        }
    }
    TestResult s = TU.runTestGroup(new MyTest(), TU.EMPTY_ARGV);
    Assert.assertTrue(!s.isOK());
    Assert.assertEquals("test cases: 1; all failed", s.getMessage());
}
Also used : TestGroup(com.sun.tck.test.TestGroup) TestResult(com.oracle.tck.lib.autd2.TestResult) TestedAPI(com.sun.tck.test.TestedAPI) Test(org.junit.Test)

Example 28 with TestGroup

use of com.sun.tck.test.TestGroup 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 29 with TestGroup

use of com.sun.tck.test.TestGroup in project jtharness by openjdk.

the class BranchAndUniteSetups method test.

@org.junit.Test
public void test() {
    final BranchAndUniteSetups.MyTestedInstance mock = mock(BranchAndUniteSetups.MyTestedInstance.class);
    @TestGroup
    class MyTest {

        Values setup1() {
            Values values2 = DataFactory.createColumn((Object[]) ROW_3).multiply((Object[]) ROW_4);
            Values values1 = DataFactory.createColumn((Object[]) ROW_1).multiply((Object[]) ROW_2);
            return values1.unite(values2);
        }

        @TestCase
        @TestData("setup1")
        public void test(String s1, String s2) {
            mock.method(s1, s2);
        }
    }
    com.oracle.tck.lib.autd2.TestResult status = TU.runTestGroup(new MyTest());
    Assert.assertTrue(status.isOK());
    for (String s1 : ROW_1) {
        for (String s2 : ROW_2) {
            verify(mock).method(s1, s2);
        }
    }
    for (String s3 : ROW_3) {
        for (String s4 : ROW_4) {
            verify(mock).method(s3, s4);
        }
    }
}
Also used : Values(com.sun.tck.lib.tgf.Values) TestGroup(com.sun.tck.test.TestGroup)

Example 30 with TestGroup

use of com.sun.tck.test.TestGroup in project jtharness by openjdk.

the class Examples method test_07.

@Test
public void test_07() {
    @TestGroup
    class TestTransformingIterator {

        Values multiplyValues = DataFactory.createValues(new Comparable<?>[][] { { 1, 2 }, { 3, 4 } }).multiply(DataFactory.createValues(new Comparable<?>[][] { { 5, 6 }, { 7, 8 } })).filter((Comparable<?> c1, Comparable<?> c2, Comparable<?> c3, Comparable<?> c4) -> DataFactory.createRow(c1));

        @TestCase
        @TestData("multiplyValues")
        public void testToString(Integer i) {
        }
    }
    com.oracle.tck.lib.autd2.TestResult s = TU.runTestGroup(new TestTransformingIterator());
    Assert.assertTrue(s.isOK());
    Assert.assertEquals("test cases: 1; all passed", s.getMessage());
}
Also used : Values(com.sun.tck.lib.tgf.Values) TestGroup(com.sun.tck.test.TestGroup) TestResult(com.oracle.tck.lib.autd2.TestResult) Test(org.junit.Test)

Aggregations

TestGroup (com.sun.tck.test.TestGroup)55 Test (org.junit.Test)53 TestResult (com.oracle.tck.lib.autd2.TestResult)49 Values (com.sun.tck.lib.tgf.Values)27 TestedAPI (com.sun.tck.test.TestedAPI)10 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)10 TestData (com.sun.tck.lib.tgf.TestData)7 Color (java.awt.Color)7 BaseTestGroup (com.oracle.tck.lib.autd2.unittests.BaseTestGroup)4 DataFactory (com.sun.tck.lib.tgf.DataFactory)4 Longs (com.sun.tck.lib.tgf.data.Longs)3 ColorSpace (java.awt.color.ColorSpace)3 Iterator (java.util.Iterator)3 List (java.util.List)3 RandomAccess (java.util.RandomAccess)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.createColumn (com.sun.tck.lib.tgf.DataFactory.createColumn)2