Search in sources :

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

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

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

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

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

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

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

the class Examples method from_VMTests.

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

        Values frames() {
            Values rowsOfTypes = DataFactory.createValues(new String[][] { {}, { "a" }, { "a", "b" }, { "a", "b", "c", "d" } });
            Values frames = rowsOfTypes.filter(new Object() {

                @Transform
                public Object transform(Object[] row1) {
                    Object[] copiedArray = Arrays.copyOf(row1, row1.length, (Class<? extends Object[]>) String[].class);
                    return DataFactory.createRow((Object) copiedArray);
                }
            }).filter((String[] stackState) -> new Object());
            return frames;
        }

        @TestCase
        @TestData("frames")
        public void testToString(Object i) {
            System.out.println("TestTransformingIterator.testToString");
            System.out.println("i = " + 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

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