Search in sources :

Example 81 with TestCase

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

the class ReferenceAttachedToParam method shorts_1.

@org.junit.Test
public void shorts_1() {
    final List<Integer> list = new ArrayList<Integer>();
    com.oracle.tck.lib.autd2.TestResult status = TU.runTestGroup(new BaseTestGroup() {

        Values ints = DataFactory.createColumn(23, 423);

        @TestCase
        public void test(@TestData("ints") int i) throws Throwable {
            list.add(i);
        }
    });
    Assert.assertTrue(status.isOK());
    Assert.assertEquals(2, list.size());
    Assert.assertEquals(23, list.get(0), 0.0);
    Assert.assertEquals(423, list.get(1), 0.0);
}
Also used : TestCase(com.sun.tck.test.TestCase) ArrayList(java.util.ArrayList) Values(com.sun.tck.lib.tgf.Values) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup)

Example 82 with TestCase

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

the class ReferenceAttachedToParam method mixed_mult_2.

@org.junit.Test
public void mixed_mult_2() {
    final List<Class<?>> list_1 = new ArrayList<Class<?>>();
    final List<String> list_2 = new ArrayList<String>();
    com.oracle.tck.lib.autd2.TestResult status = TU.runTestGroup(new BaseTestGroup() {

        Values strings_ = DataFactory.createColumn("aa", "bb", "cc");

        @TestCase
        @Operation(Operation.TYPE.MULTIPLY)
        public void test(@Classes({ String.class, Throwable.class }) Class<?> c, @TestData("strings_") String s) throws Throwable {
            list_1.add(c);
            list_2.add(s);
        }
    });
    Assert.assertTrue(status.isOK());
    Assert.assertEquals(6, list_1.size());
    Assert.assertEquals(6, list_2.size());
    Assert.assertEquals(String.class, list_1.get(0));
    Assert.assertEquals(String.class, list_1.get(1));
    Assert.assertEquals(String.class, list_1.get(2));
    Assert.assertEquals(Throwable.class, list_1.get(3));
    Assert.assertEquals(Throwable.class, list_1.get(4));
    Assert.assertEquals(Throwable.class, list_1.get(5));
    Assert.assertEquals("aa", list_2.get(0));
    Assert.assertEquals("bb", list_2.get(1));
    Assert.assertEquals("cc", list_2.get(2));
    Assert.assertEquals("aa", list_2.get(3));
    Assert.assertEquals("bb", list_2.get(4));
    Assert.assertEquals("cc", list_2.get(5));
}
Also used : ArrayList(java.util.ArrayList) Values(com.sun.tck.lib.tgf.Values) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup) Operation(com.sun.tck.lib.tgf.data.Operation) TestCase(com.sun.tck.test.TestCase)

Example 83 with TestCase

use of com.sun.tck.test.TestCase 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 84 with TestCase

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

the class Examples method test_03_array.

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

        Values quantities = createColumn(new Color[] { BLUE, BLACK, WHITE }, new Color[] { BLACK, WHITE, BLUE, GREEN }, new Color[] { BLUE, BLACK }, new Color[] { RED }).<Color[]>filter(colors -> createRow(colors.length));

        @TestCase
        @TestData("quantities")
        public void test(int quantity) {
            assertTrue(quantity > 0);
        }
    }
    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 85 with TestCase

use of com.sun.tck.test.TestCase 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)

Aggregations

TestCase (com.sun.tck.test.TestCase)147 BaseTestGroup (com.oracle.tck.lib.autd2.unittests.BaseTestGroup)126 Test (org.junit.Test)77 ArrayList (java.util.ArrayList)72 TestData (com.sun.tck.lib.tgf.TestData)57 TestResult (com.oracle.tck.lib.autd2.TestResult)28 Values (com.sun.tck.lib.tgf.Values)28 HashSet (java.util.HashSet)13 DataFactory.createValues (com.sun.tck.lib.tgf.DataFactory.createValues)12 NonTestCase (com.oracle.tck.lib.autd2.NonTestCase)10 Operation (com.sun.tck.lib.tgf.data.Operation)10 TestObject (com.oracle.tck.lib.autd2.unittests.TestObject)9 PrintWriter (java.io.PrintWriter)8 InOrder (org.mockito.InOrder)8 List (java.util.List)4 DataFactory.createColumn (com.sun.tck.lib.tgf.DataFactory.createColumn)3 DataFactory.createRow (com.sun.tck.lib.tgf.DataFactory.createRow)3 java.util (java.util)3 Assert (org.junit.Assert)3 Assert.assertEquals (com.sun.tck.lib.Assert.assertEquals)2