Search in sources :

Example 16 with TestGroup

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

the class Examples method test_03.

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

        Values colors = createColumn(BLUE, BLACK, WHITE).<Color>filter(c -> createRow(c.darker(), c.brighter()));

        @TestCase
        @TestData("colors")
        public void test(Color darker, Color brighter) {
            assertTrue(darker.getRed() <= brighter.getRed());
            assertTrue(darker.getGreen() <= brighter.getGreen());
            assertTrue(darker.getBlue() <= brighter.getBlue());
        }
    }
    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 17 with TestGroup

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

the class FailingSimpleTestCases method testedAPI_package_class_methods.

@Test
public void testedAPI_package_class_methods() {
    @TestedAPI(testedPackage = "s.e.g", testedClass = "TheClass", testedMember = { "method1", "method2" })
    @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 18 with TestGroup

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

the class FailingSimpleTestCases method threeMixedTestCases_AUTD2StatusRecognizingProcessor_01.

@Test
public void threeMixedTestCases_AUTD2StatusRecognizingProcessor_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
        @ExpectedExceptions(IllegalArgumentException.class)
        public void test1() {
            testCase_1_called.set(true);
            throw new IllegalArgumentException();
        }

        @TestCase
        public Status test2() {
            testCase_2_called.set(true);
            return Status.passed("Status passed");
        }

        @TestCase
        public void test3() {
            testCase_3_called.set(true);
        }
    }
    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; all passed", s.getMessage());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) TestGroup(com.sun.tck.test.TestGroup) TestResult(com.oracle.tck.lib.autd2.TestResult) Test(org.junit.Test)

Example 19 with TestGroup

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

the class FailingSimpleTestCases method ExceptionsThrownFromStatus.

@Test
public void ExceptionsThrownFromStatus() {
    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);
            throw new RuntimeException();
        }
    }
    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: 1; failed: 2; failed: [test2, test3]", s.getMessage());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) TestGroup(com.sun.tck.test.TestGroup) TestResult(com.oracle.tck.lib.autd2.TestResult) Test(org.junit.Test)

Example 20 with TestGroup

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

the class FailingSimpleTestCases method testedAPI_package_class_method.

@Test
public void testedAPI_package_class_method() {
    @TestedAPI(testedPackage = "s.e.g", testedClass = "TheClass", testedMember = "method1")
    @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)

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