Search in sources :

Example 11 with TestData

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

the class TestAfter method ifTestThrowsExceptionAfterIsNotCalled.

@Test
public void ifTestThrowsExceptionAfterIsNotCalled() {
    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() {

        private void myAfter() {
            org.junit.Assert.assertTrue(methodCalled[0]);
            afterCalled[0] = true;
            afterCounter[0]++;
        }

        @TestCase
        @TestData("setup")
        @com.sun.tck.lib.tgf.After("myAfter")
        public void test(int i) {
            org.junit.Assert.assertFalse(afterCalled[0]);
            methodCalled[0] = true;
            counter[0]++;
            throw new RuntimeException("Thrown from test");
        }
    }, TU.EMPTY_ARGV);
    assertFalse(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) TestResult(com.oracle.tck.lib.autd2.TestResult) TestCase(com.sun.tck.test.TestCase) Test(org.junit.Test)

Example 12 with TestData

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

the class TestAfter method afterNotFound.

@Test
public void afterNotFound() {
    PrintWriter log = TU.createMockedPrintWriter();
    PrintWriter ref = TU.createMockedPrintWriter();
    final boolean[] methodCalled = new boolean[1];
    final int[] counter = new int[] { 0 };
    TestResult status = TU.runTestGroup(new TestAfter.Mytest() {

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

        @TestCase
        @TestData("mySetup")
        @com.sun.tck.lib.tgf.After("myAfterThatDoesnotExist")
        public void test(int i) {
            methodCalled[0] = true;
            counter[0]++;
        }
    }, log, ref, TU.EMPTY_ARGV);
    assertTrue(!status.isOK());
    assertTrue(methodCalled[0]);
    assertEquals(3, counter[0]);
    InOrder inOrder = inOrder(log, ref);
    inOrder.verify(log).println("Method \"myAfterThatDoesnotExist\" doesn't exist.");
    inOrder.verify(log).println("test: Failed. Failed trying to invoke @After method \"myAfterThatDoesnotExist\"");
    inOrder.verify(log).flush();
    inOrder.verify(ref).flush();
    verifyNoMoreInteractions(log, ref);
}
Also used : InOrder(org.mockito.InOrder) TestData(com.sun.tck.lib.tgf.TestData) TestCase(com.sun.tck.test.TestCase) Values(com.sun.tck.lib.tgf.Values) TestResult(com.oracle.tck.lib.autd2.TestResult) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Example 13 with TestData

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

the class TestAfter method runtimeSkippingFromAfter_testFails.

@Test
public void runtimeSkippingFromAfter_testFails() {
    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() {
            com.sun.tck.lib.Assert.reportNotApplicable(true);
        }

        @TestCase
        @TestData("mySetup")
        @com.sun.tck.lib.tgf.After("myAfter")
        public void test(int i) {
            Assert.fail("Failed!!!");
        }
    }, TU.EMPTY_ARGV);
    assertTrue(status.isOK());
    assertEquals("test cases: 1; all not applicable", status.getMessage());
}
Also used : TestData(com.sun.tck.lib.tgf.TestData) TestCase(com.sun.tck.test.TestCase) Values(com.sun.tck.lib.tgf.Values) TestResult(com.oracle.tck.lib.autd2.TestResult) Test(org.junit.Test)

Example 14 with TestData

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

the class Exclusion method check_Mixed_2.

private void check_Mixed_2(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 Values mySetup() {
            return DataFactory.createColumn(11, 22, 33, 44, 55, 66);
        }

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

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

        @TestCase
        @TestData("mySetup")
        public void foo(int i) {
            fooCounter[0]++;
        }
    }, args);
    Assert.assertTrue(status.isOK());
    Assert.assertEquals("Passed. test cases: 2; all passed", status.toString());
    Assert.assertEquals(0, myTestCounter[0]);
    Assert.assertEquals(1, blablaCounter[0]);
    Assert.assertEquals(6, 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 15 with TestData

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

the class Exclusion method checkNothingFound.

private void checkNothingFound(String[] args) {
    final int[] methodCounter = new int[] { 0 };
    final ArrayList<Integer> expectedArgValues = new ArrayList<Integer>() {

        {
            add(1);
            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]++;
        }
    }, args);
    Assert.assertTrue(status.isOK());
    Assert.assertEquals(3, 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)

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