Search in sources :

Example 11 with com.oracle.tck.lib.autd2

use of com.oracle.tck.lib.autd2 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 com.oracle.tck.lib.autd2

use of com.oracle.tck.lib.autd2 in project jtharness by openjdk.

the class TestAfter method inheritingAfter_NoParams.

@Test
public void inheritingAfter_NoParams() {
    final boolean[] methodCalled = new boolean[1];
    final int[] counter = new int[] { 0 };
    PredefinedAfter testInstance = new PredefinedAfter() {

        @TestCase
        @com.sun.tck.lib.tgf.After("after")
        public void test() {
            methodCalled[0] = true;
            counter[0]++;
        }
    };
    com.oracle.tck.lib.autd2.TestResult status = com.oracle.tck.lib.autd2.unittests.TU.runTestGroup(testInstance, TU.EMPTY_ARGV);
    assertTrue(status.isOK());
    assertTrue(testInstance.initialAfterWasCalled);
    assertTrue(methodCalled[0]);
    assertEquals(1, counter[0]);
}
Also used : TestResult(com.oracle.tck.lib.autd2.TestResult) Test(org.junit.Test)

Example 13 with com.oracle.tck.lib.autd2

use of com.oracle.tck.lib.autd2 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 com.oracle.tck.lib.autd2

use of com.oracle.tck.lib.autd2 in project jtharness by openjdk.

the class TestBefore method beforeIsBeforeValuesInitialization.

@Test
public void beforeIsBeforeValuesInitialization() {
    final boolean[] beforeCalled = new boolean[1];
    final boolean[] valuesInited = new boolean[1];
    com.oracle.tck.lib.autd2.TestResult status = com.oracle.tck.lib.autd2.unittests.TU.runTestGroup(new BaseTestGroup() {

        Object[] objects() {
            valuesInited[0] = true;
            return new Object[] { new Object() };
        }

        private void before() {
            Assert.assertFalse(valuesInited[0]);
            beforeCalled[0] = true;
        }

        @TestCase
        @TestData("objects")
        @Before("before")
        public void test(Object o) {
            Assert.assertTrue(beforeCalled[0]);
        }
    }, TU.EMPTY_ARGV);
    assertTrue(status.isOK());
    assertTrue(beforeCalled[0]);
    assertTrue(valuesInited[0]);
}
Also used : com.oracle.tck.lib.autd2(com.oracle.tck.lib.autd2) TestCase(com.sun.tck.test.TestCase) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup) Test(org.junit.Test)

Example 15 with com.oracle.tck.lib.autd2

use of com.oracle.tck.lib.autd2 in project jtharness by openjdk.

the class TestBeforeAndAfter method beforeThrowsException.

@Test
public void beforeThrowsException() {
    final boolean[] afterCalled = new boolean[1];
    final boolean[] beforeCalled = new boolean[1];
    final boolean[] methodCalled = new boolean[1];
    final int[] methodCounter = new int[] { 0 };
    final int[] afterCounter = new int[] { 0 };
    final int[] beforeCounter = 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);
        }

        private void myAfter() {
            afterCalled[0] = true;
            afterCounter[0]++;
            org.junit.Assert.fail("This must not be called");
        }

        private void myBefore() {
            org.junit.Assert.assertFalse(beforeCalled[0]);
            org.junit.Assert.assertFalse(methodCalled[0]);
            org.junit.Assert.assertFalse(afterCalled[0]);
            beforeCalled[0] = true;
            beforeCounter[0]++;
            throw new RuntimeException("Exception thrown from before");
        }

        @TestCase
        @Before("myBefore")
        @After("myAfter")
        @TestData("mySetup")
        public void test(int i) {
            methodCalled[0] = true;
            methodCounter[0]++;
            org.junit.Assert.fail("This must not be called");
        }
    }, TU.EMPTY_ARGV);
    Assert.assertFalse(status.isOK());
    Assert.assertFalse(afterCalled[0]);
    Assert.assertTrue(beforeCalled[0]);
    Assert.assertFalse(methodCalled[0]);
    Assert.assertEquals(0, methodCounter[0]);
    Assert.assertEquals(0, afterCounter[0]);
    Assert.assertEquals(1, beforeCounter[0]);
}
Also used : BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup) TestCase(com.sun.tck.test.TestCase) Test(org.junit.Test)

Aggregations

TestCase (com.sun.tck.test.TestCase)139 BaseTestGroup (com.oracle.tck.lib.autd2.unittests.BaseTestGroup)135 Test (org.junit.Test)107 ArrayList (java.util.ArrayList)73 TestData (com.sun.tck.lib.tgf.TestData)61 TestResult (com.oracle.tck.lib.autd2.TestResult)52 Values (com.sun.tck.lib.tgf.Values)50 TestGroup (com.sun.tck.test.TestGroup)30 HashSet (java.util.HashSet)13 DataFactory.createValues (com.sun.tck.lib.tgf.DataFactory.createValues)12 NonTestCase (com.oracle.tck.lib.autd2.NonTestCase)11 Operation (com.sun.tck.lib.tgf.data.Operation)10 TestObject (com.oracle.tck.lib.autd2.unittests.TestObject)8 Color (java.awt.Color)7 List (java.util.List)5 DataFactory (com.sun.tck.lib.tgf.DataFactory)4 DataFactory.createColumn (com.sun.tck.lib.tgf.DataFactory.createColumn)3 DataFactory.createRow (com.sun.tck.lib.tgf.DataFactory.createRow)3 PrintWriter (java.io.PrintWriter)3 java.util (java.util)3