Search in sources :

Example 16 with BaseTestGroup

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

the class Filtering method absorbingExceptions_exceptionThrownOut.

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

            Values values = createColumn(Double.class, Class.class).filter((Values.Transformer1<Class<?>>) c -> c.getConstructor().newInstance());

            @TestCase
            @TestData("values")
            public void myTest(Object s) {
                System.out.println("s = " + s);
            }
        });
        Assert.fail("Exception expected");
    } catch (RuntimeException e) {
        Assert.assertTrue(e.getCause() instanceof InvocationTargetException);
        Assert.assertTrue(e.getCause().getCause() instanceof NoSuchMethodException);
        Assert.assertEquals("java.lang.Double.<init>()", e.getCause().getCause().getMessage());
    }
}
Also used : java.util(java.util) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup) TU(com.oracle.tck.lib.autd2.unittests.TU) TestResult(com.oracle.tck.lib.autd2.TestResult) ValuesComparison(com.oracle.tck.lib.autd2.unittests.ValuesComparison) InvocationTargetException(java.lang.reflect.InvocationTargetException) java.awt(java.awt) DataFactory.createValues(com.sun.tck.lib.tgf.DataFactory.createValues) TestCase(com.sun.tck.test.TestCase) DataFactory.createRow(com.sun.tck.lib.tgf.DataFactory.createRow) Assert.assertArrayEquals(org.junit.Assert.assertArrayEquals) Assert(org.junit.Assert) DataFactory.createColumn(com.sun.tck.lib.tgf.DataFactory.createColumn) Assert.assertEquals(org.junit.Assert.assertEquals) com.sun.tck.lib.tgf(com.sun.tck.lib.tgf) javax.swing(javax.swing) 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) InvocationTargetException(java.lang.reflect.InvocationTargetException) Test(org.junit.Test)

Example 17 with BaseTestGroup

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

the class Filtering method absorbingExceptions_exceptionThrownOut_1.

@Test
public void absorbingExceptions_exceptionThrownOut_1() {
    final ArrayList<String> arrayList = new ArrayList<String>();
    final Throwable throwable = new Throwable();
    try {
        com.oracle.tck.lib.autd2.unittests.TU.runTestGroup(new BaseTestGroup() {

            Values values = createColumn("1", "2").filter((String s) -> {
                throw throwable;
            });

            @TestCase
            @TestData("values")
            public void myTest(Object s) {
                arrayList.add(s.getClass().getCanonicalName());
            }
        });
        Assert.fail("Exception expected");
    } catch (RuntimeException e) {
        Assert.assertTrue(e.getCause() instanceof InvocationTargetException);
        Assert.assertSame(throwable, e.getCause().getCause());
    }
}
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) InvocationTargetException(java.lang.reflect.InvocationTargetException) Test(org.junit.Test)

Example 18 with BaseTestGroup

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

the class Filtering method arrayReturned_01_lambda.

@Test
public void arrayReturned_01_lambda() {
    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((Integer i) -> 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)

Example 19 with BaseTestGroup

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

the class Filtering method arrayReturned_02_lambda.

@Test
public void arrayReturned_02_lambda() {
    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((Integer i) -> new Integer[][] { { i, i + 1 }, { i, i + 2 }, { i, i + 20 } });
            return createColumn("a", "b", "c").pseudoMultiply(values);
        }

        @TestCase
        @TestData("values")
        public void wrongTest(String s, Integer integer1, Integer integer2) throws Throwable {
            System.out.println("s = " + s);
            System.out.println("integer1 = " + integer1);
            System.out.println("integer2 = " + integer2);
        }
    }, 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)

Example 20 with BaseTestGroup

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

the class Filtering method listReturned_01.

@Test
public void listReturned_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
                java.util.List<Integer> create(int i) {
                    return Arrays.asList(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 : DataFactory.createValues(com.sun.tck.lib.tgf.DataFactory.createValues) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup) TestResult(com.oracle.tck.lib.autd2.TestResult) java.util(java.util) TestCase(com.sun.tck.test.TestCase) 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