Search in sources :

Example 86 with BaseTestGroup

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

the class TestBeforeAndAfter method beforeThrowsException_NoParams.

@Test
public void beforeThrowsException_NoParams() {
    final boolean[] afterCalled = new boolean[1];
    final boolean[] beforeCalled = new boolean[1];
    final boolean[] methodCalled = new boolean[1];
    final int[] methodCounter = new int[] { 0 };
    final int[] afterCounter = new int[] { 0 };
    final int[] beforeCounter = new int[] { 0 };
    com.oracle.tck.lib.autd2.TestResult status = com.oracle.tck.lib.autd2.unittests.TU.runTestGroup(new BaseTestGroup() {

        protected Values mySetup() {
            return DataFactory.createColumn(1, 2, 3);
        }

        private void myAfter() {
            afterCalled[0] = true;
            afterCounter[0]++;
            org.junit.Assert.fail("This must not be called");
        }

        private void myBefore() {
            org.junit.Assert.assertFalse(beforeCalled[0]);
            org.junit.Assert.assertFalse(methodCalled[0]);
            org.junit.Assert.assertFalse(afterCalled[0]);
            beforeCalled[0] = true;
            beforeCounter[0]++;
            throw new RuntimeException("Exception thrown from before");
        }

        @TestCase
        @Before("myBefore")
        @After("myAfter")
        public void test() {
            methodCalled[0] = true;
            methodCounter[0]++;
            org.junit.Assert.fail("This must not be called");
        }
    }, TU.EMPTY_ARGV);
    Assert.assertFalse(status.isOK());
    Assert.assertFalse(afterCalled[0]);
    Assert.assertTrue(beforeCalled[0]);
    Assert.assertFalse(methodCalled[0]);
    Assert.assertEquals(0, methodCounter[0]);
    Assert.assertEquals(0, afterCounter[0]);
    Assert.assertEquals(1, beforeCounter[0]);
}
Also used : TestCase(com.sun.tck.test.TestCase) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup) Test(org.junit.Test)

Example 87 with BaseTestGroup

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

the class Exclusion method test_Mixed_1.

@Test
public void test_Mixed_1() {
    final int[] myTestCounter = new int[] { 0 };
    final int[] blablaCounter = new int[] { 0 };
    final int[] fooCounter = new int[] { 0 };
    com.oracle.tck.lib.autd2.TestResult status = com.oracle.tck.lib.autd2.unittests.TU.runTestGroup(new BaseTestGroup() {

        private Values mySetup() {
            return DataFactory.createColumn(11, 22, 33, 44, 55, 66);
        }

        @TestCase
        public void myTest() {
            myTestCounter[0]++;
        }

        @TestCase
        public void blabla() {
            blablaCounter[0]++;
        }

        @TestCase
        @TestData("mySetup")
        public void foo(int i) {
            fooCounter[0]++;
        }
    }, new String[] { EXCLUDE_WORD });
    Assert.assertTrue(status.isOK());
    Assert.assertEquals("Passed. test cases: 3; all passed", status.toString());
    Assert.assertEquals(1, myTestCounter[0]);
    Assert.assertEquals(1, blablaCounter[0]);
    Assert.assertEquals(6, fooCounter[0]);
}
Also used : TestData(com.sun.tck.lib.tgf.TestData) TestCase(com.sun.tck.test.TestCase) Values(com.sun.tck.lib.tgf.Values) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup) Test(org.junit.Test)

Example 88 with BaseTestGroup

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

the class Exclusion method check_Mixed_3.

private void check_Mixed_3(String... args) {
    final int[] myTestCounter = new int[] { 0 };
    final int[] blablaCounter = new int[] { 0 };
    final int[] fooCounter = new int[] { 0 };
    com.oracle.tck.lib.autd2.TestResult status = com.oracle.tck.lib.autd2.unittests.TU.runTestGroup(new BaseTestGroup() {

        private Values mySetup() {
            return DataFactory.createColumn(11, 22, 33, 44, 55, 66);
        }

        @TestCase
        public void myTest() {
            myTestCounter[0]++;
        }

        @TestCase
        public void blabla() {
            blablaCounter[0]++;
        }

        @TestCase
        @TestData("mySetup")
        public void foo(int i) {
            fooCounter[0]++;
        }
    }, args);
    Assert.assertTrue(status.isOK());
    Assert.assertEquals("Passed. test cases: 1; all passed", status.toString());
    Assert.assertEquals(0, myTestCounter[0]);
    Assert.assertEquals(0, blablaCounter[0]);
    Assert.assertEquals(6, fooCounter[0]);
}
Also used : TestData(com.sun.tck.lib.tgf.TestData) TestCase(com.sun.tck.test.TestCase) Values(com.sun.tck.lib.tgf.Values) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup)

Example 89 with BaseTestGroup

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

the class Filtering method arrayReturned_02.

@Test
public void arrayReturned_02() {
    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, 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 90 with BaseTestGroup

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

the class ArraysOfPrimitives method arrayAsReturnType_longs_special_case.

@org.junit.Test
public void arrayAsReturnType_longs_special_case() {
    final List<Long> is = new ArrayList<Long>();
    final List<Long> js = new ArrayList<Long>();
    com.oracle.tck.lib.autd2.TestResult status = com.oracle.tck.lib.autd2.unittests.TU.runTestGroup(new BaseTestGroup() {

        long[][] longs = { { 234234234l, 234023400034l } };

        @TestCase
        @TestData("longs")
        public void test(long i, long j) throws Throwable {
            is.add(i);
            js.add(j);
        }
    }, TU.EMPTY_ARGV);
    Assert.assertTrue(status.isOK());
    Assert.assertEquals(1, is.size());
    Assert.assertEquals(1, js.size());
    Assert.assertEquals(234234234l, (long) is.get(0));
    Assert.assertEquals(234023400034l, (long) js.get(0));
}
Also used : TestData(com.sun.tck.lib.tgf.TestData) ArrayList(java.util.ArrayList) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup) TestCase(com.sun.tck.test.TestCase)

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