Search in sources :

Example 76 with BaseTestGroup

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

the class Filtering method returningArrayUntouched.

@Test
public void returningArrayUntouched() {
    final java.util.List<Integer[]> passed = new ArrayList<Integer[]>();
    com.oracle.tck.lib.autd2.TestResult status = com.oracle.tck.lib.autd2.unittests.TU.runTestGroup(new BaseTestGroup() {

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

                @Transform
                Values create(int i) {
                    return DataFactory.createValues(new Object[][] { { new Integer[] { i, i + 1, i + 2 } } });
                }
            });
        }

        @TestCase
        @TestData("values")
        public void test(Integer[] integer) throws Throwable {
            passed.add(integer);
        }
    }, TU.EMPTY_ARGV);
    assertEquals(3, passed.size());
    assertArrayEquals(new Integer[] { 0, 1, 2 }, passed.get(0));
    assertArrayEquals(new Integer[] { 1, 2, 3 }, passed.get(1));
    assertArrayEquals(new Integer[] { 2, 3, 4 }, passed.get(2));
    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)

Example 77 with BaseTestGroup

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

the class Filtering method absorbingExceptions_testPassed.

@Test
public void absorbingExceptions_testPassed() {
    final ArrayList<String> arrayList = new ArrayList<String>();
    com.oracle.tck.lib.autd2.TestResult status = com.oracle.tck.lib.autd2.unittests.TU.runTestGroup(new BaseTestGroup() {

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

        @TestCase
        @TestData("values")
        public void myTest(Object s) {
            arrayList.add(s.getClass().getCanonicalName());
        }
    }, TU.EMPTY_ARGV);
    Assert.assertEquals(2, arrayList.size());
    Assert.assertEquals("java.lang.String", arrayList.get(0));
    Assert.assertEquals("java.lang.Object", arrayList.get(1));
    Assert.assertTrue(status.isOK());
    Assert.assertEquals("Passed. test cases: 1; all passed", status.toString());
}
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) TestCase(com.sun.tck.test.TestCase) Test(org.junit.Test)

Example 78 with BaseTestGroup

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

the class Filtering method iteratorReturned_01.

@Test
public void iteratorReturned_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
                Iterator<Integer> create(int i) {
                    return Arrays.asList(i, i + 1, i + 2).iterator();
                }
            });
            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 79 with BaseTestGroup

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

the class Filtering method test_exception.

@Test
public void test_exception() {
    ArrayList<Integer> passed = new ArrayList<>();
    com.oracle.tck.lib.autd2.TestResult status = com.oracle.tck.lib.autd2.unittests.TU.runTestGroup(new BaseTestGroup() {

        Values data = DataFactory.createColumn(1, 2, 3, 4, 5).filter((Integer i) -> {
            return i;
        });

        @TestCase
        @TestData("data")
        public void myTest(int i) {
            passed.add(i);
        }
    }, TU.EMPTY_ARGV);
    Assert.assertEquals(!status.isOK(), false);
    Assert.assertEquals(status.isOK(), true);
    Assert.assertEquals(5, passed.size());
    Assert.assertArrayEquals(new Integer[] { 1, 2, 3, 4, 5 }, passed.toArray(new Object[passed.size()]));
}
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) TestCase(com.sun.tck.test.TestCase) Test(org.junit.Test)

Example 80 with BaseTestGroup

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

the class Filtering method listReturned_01_lambda.

@Test
public void listReturned_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) -> 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 : 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