Search in sources :

Example 71 with BaseTestGroup

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

the class InvalidTestCases method publicNonTestCaseMethod_message2.

@Test
public void publicNonTestCaseMethod_message2() {
    try {
        com.oracle.tck.lib.autd2.TestResult status = TU.runTestGroup(new BaseTestGroup() {

            public void myTest4444444() {
            }
        });
        Assert.fail("IAE was not thrown");
    } catch (IllegalArgumentException e) {
        assertEquals("Please either add @TestCase or @NonTestCase annotation to method \"com.oracle.tck.lib.autd2.unittests.tgfported.general.InvalidTestCases$23.myTest4444444\" or make it non-public. All public methods must have @TestCase annotation by default. As an exception a method which needs to be public but is not a testcase should be annotated with @NonTestCase annotation.", e.getMessage());
    }
}
Also used : BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup) Test(org.junit.Test)

Example 72 with BaseTestGroup

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

the class InvalidTestCases method noTestCaseAnn_onlyTestData_05.

@Test
public void noTestCaseAnn_onlyTestData_05() {
    try {
        com.oracle.tck.lib.autd2.TestResult status = com.oracle.tck.lib.autd2.unittests.TU.runTestGroup(new BaseTestGroup() {

            @TestData("blabla")
            protected void myTest01(int i) {
            }

            @TestCase
            public void myTest02() {
            }
        }, TU.EMPTY_ARGV);
        Assert.fail("IAE was not thrown");
    } catch (IllegalArgumentException e) {
        assertEquals(MARKING_METHOD_ONLY_WITH_TEST_DATA_IS_NOT_ALLOWED_PLEASE_ADD_TEST_CASE_ANNOTATION_TO_METHOD + "myTest01\".", e.getMessage());
    }
}
Also used : TestData(com.sun.tck.lib.tgf.TestData) TestCase(com.sun.tck.test.TestCase) NonTestCase(com.oracle.tck.lib.autd2.NonTestCase) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup) Test(org.junit.Test)

Example 73 with BaseTestGroup

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

the class TestCaseThrowsException method unexpectedRuntimeException.

@Test
public void unexpectedRuntimeException() {
    PrintWriter log = TU.createMockedPrintWriter();
    PrintWriter ref = TU.createMockedPrintWriter();
    BaseTestGroup baseTestGroup = new BaseTestGroup() {

        Values setup() {
            return DataFactory.createColumn(115);
        }

        @TestCase
        @TestData("setup")
        public void theTest(int i) {
            throw new CustomException(Integer.toString(i));
        }
    };
    com.oracle.tck.lib.autd2.TestResult status = TU.runTestGroup(baseTestGroup, log, ref);
    Assert.assertTrue(!status.isOK());
    Assert.assertEquals("Failed. test cases: 1; all failed", status.toString());
    InOrder inOrder = inOrder(log, ref);
    inOrder.verify(log).println("Testcase \"theTest(0)\" has thrown an unexpected exception com.oracle.tck.lib.autd2.unittests.CustomException: 115");
    inOrder.verify(log).println(CustomException.STACKTRACE_LINE);
    inOrder.verify(log).println("Testcase \"theTest(0)\" failed with arguments [115]");
    inOrder.verify(log).println("theTest: Failed. Testcase \"theTest(0)\" has thrown an unexpected exception com.oracle.tck.lib.autd2.unittests.CustomException: 115");
    inOrder.verify(log).flush();
    inOrder.verify(ref).flush();
    verifyNoMoreInteractions(log, ref);
}
Also used : InOrder(org.mockito.InOrder) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup) CustomException(com.oracle.tck.lib.autd2.unittests.CustomException) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Example 74 with BaseTestGroup

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

the class Cache method runTest.

private long runTest(final Values column, boolean createCache) {
    final long start = System.currentTimeMillis();
    final Values dataToUse = createCache ? column.createCache() : column;
    TU.runTestGroup(new BaseTestGroup() {

        Values setup() {
            return dataToUse.multiply(dataToUse);
        }

        @TestCase
        @TestData("setup")
        public void theTest(TestObject t1, TestObject t2) {
        }
    });
    return System.currentTimeMillis() - start;
}
Also used : TestCase(com.sun.tck.test.TestCase) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup) TestObject(com.oracle.tck.lib.autd2.unittests.TestObject)

Example 75 with BaseTestGroup

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

the class Filtering method arrayReturned_01.

@Test
public void arrayReturned_01() {
    com.oracle.tck.lib.autd2.TestResult status = com.oracle.tck.lib.autd2.unittests.TU.runTestGroup(new BaseTestGroup() {

        private Values values() {
            Values values = createColumn(0, 1, 2).filter(new Object() {

                @Transform
                Integer[] create(int i) {
                    return new Integer[] { i, i + 1, i + 2 };
                }
            });
            return createColumn("a", "b", "c").pseudoMultiply(values);
        }

        @TestCase
        @TestData("values")
        public void wrongTest(String s, Integer integer) throws Throwable {
            System.out.println("s = " + s);
            System.out.println("integers = " + integer);
        }
    }, TU.EMPTY_ARGV);
    assertTrue(status.isOK());
}
Also used : TestCase(com.sun.tck.test.TestCase) DataFactory.createValues(com.sun.tck.lib.tgf.DataFactory.createValues) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup) TestResult(com.oracle.tck.lib.autd2.TestResult) Test(org.junit.Test)

Aggregations

BaseTestGroup (com.oracle.tck.lib.autd2.unittests.BaseTestGroup)132 TestCase (com.sun.tck.test.TestCase)126 ArrayList (java.util.ArrayList)73 Test (org.junit.Test)62 TestData (com.sun.tck.lib.tgf.TestData)47 Values (com.sun.tck.lib.tgf.Values)21 HashSet (java.util.HashSet)13 DataFactory.createValues (com.sun.tck.lib.tgf.DataFactory.createValues)12 NonTestCase (com.oracle.tck.lib.autd2.NonTestCase)11 TestResult (com.oracle.tck.lib.autd2.TestResult)11 TestObject (com.oracle.tck.lib.autd2.unittests.TestObject)9 Operation (com.sun.tck.lib.tgf.data.Operation)8 java.util (java.util)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 List (java.util.List)2 com.oracle.tck.lib.autd2 (com.oracle.tck.lib.autd2)1 CustomException (com.oracle.tck.lib.autd2.unittests.CustomException)1 TU (com.oracle.tck.lib.autd2.unittests.TU)1 ValuesComparison (com.oracle.tck.lib.autd2.unittests.ValuesComparison)1 com.sun.tck.lib.tgf (com.sun.tck.lib.tgf)1