Search in sources :

Example 21 with TestCase

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

the class TestBeforeAndAfter method plain_NoArgs.

@Test
public void plain_NoArgs() {
    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() {
            org.junit.Assert.assertTrue(beforeCalled[0]);
            org.junit.Assert.assertTrue(methodCalled[0]);
            org.junit.Assert.assertFalse(afterCalled[0]);
            afterCalled[0] = true;
            afterCounter[0]++;
        }

        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]++;
        }

        @Before("myBefore")
        @After("myAfter")
        @TestCase
        public void testWithNoArguments() {
            org.junit.Assert.assertFalse(afterCalled[0]);
            org.junit.Assert.assertTrue(beforeCalled[0]);
            methodCalled[0] = true;
            methodCounter[0]++;
        }
    }, TU.EMPTY_ARGV);
    Assert.assertTrue(status.isOK());
    Assert.assertTrue(afterCalled[0]);
    Assert.assertTrue(beforeCalled[0]);
    Assert.assertTrue(methodCalled[0]);
    Assert.assertEquals(1, methodCounter[0]);
    Assert.assertEquals(1, 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 22 with TestCase

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

the class Exclusion method check_Mixed_2.

private void check_Mixed_2(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: 2; all passed", status.toString());
    Assert.assertEquals(0, 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)

Example 23 with TestCase

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

the class Exclusion method checkNothingFound.

private void checkNothingFound(String[] args) {
    final int[] methodCounter = new int[] { 0 };
    final ArrayList<Integer> expectedArgValues = new ArrayList<Integer>() {

        {
            add(1);
            add(2);
            add(3);
        }
    };
    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);
        }

        @TestCase
        @TestData("mySetup")
        public void myTest(int i) {
            Assert.assertTrue(i + " is not among expected", expectedArgValues.contains(i));
            methodCounter[0]++;
        }
    }, args);
    Assert.assertTrue(status.isOK());
    Assert.assertEquals(3, methodCounter[0]);
}
Also used : TestData(com.sun.tck.lib.tgf.TestData) ArrayList(java.util.ArrayList) Values(com.sun.tck.lib.tgf.Values) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup) TestCase(com.sun.tck.test.TestCase)

Example 24 with TestCase

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

the class Exclusion method check_ExcludeWholeTest.

private void check_ExcludeWholeTest(String... args) {
    final int[] methodCounter = 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);
        }

        @TestCase
        @TestData("mySetup")
        public void myTest(int i) {
            methodCounter[0]++;
        }
    }, args);
    Assert.assertTrue(status.isOK());
    Assert.assertEquals(0, methodCounter[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 25 with TestCase

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

the class Exclusion method check_2.

private void check_2(String... args) {
    final int[] methodCounter = 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() {

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

        @TestCase
        @TestData("mySetup")
        public void myTest(int i) {
            methodCounter[0]++;
        }

        @TestCase
        @TestData("mySetup")
        public void blabla(int i) {
            blablaCounter[0]++;
        }

        @TestCase
        @TestData("mySetup")
        public void foo(int i) {
            fooCounter[0]++;
        }
    }, args);
    Assert.assertTrue(status.isOK());
    Assert.assertEquals(5, methodCounter[0]);
    Assert.assertEquals(0, blablaCounter[0]);
    Assert.assertEquals(0, 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)

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