Search in sources :

Example 6 with com.oracle.tck.lib.autd2

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

the class TestAfter method afterOfNonVoidTypeWasCalled.

@Test
public void afterOfNonVoidTypeWasCalled() {
    final boolean[] afterCalled = new boolean[1];
    final boolean[] methodCalled = new boolean[1];
    final int[] counter = new int[] { 0 };
    final int[] afterCounter = new int[] { 0 };
    com.oracle.tck.lib.autd2.TestResult status = com.oracle.tck.lib.autd2.unittests.TU.runTestGroup(new TestAfter.Mytest() {

        private IllegalArgumentException myAfter() {
            org.junit.Assert.assertTrue(methodCalled[0]);
            afterCalled[0] = true;
            afterCounter[0]++;
            return new IllegalArgumentException();
        }

        @TestCase
        @TestData("setup")
        @com.sun.tck.lib.tgf.After("myAfter")
        public void test(int i) {
            org.junit.Assert.assertFalse(afterCalled[0]);
            methodCalled[0] = true;
            counter[0]++;
        }
    }, TU.EMPTY_ARGV);
    assertTrue(status.isOK());
    assertTrue(afterCalled[0]);
    assertTrue(methodCalled[0]);
    assertEquals(3, counter[0]);
    assertEquals(1, afterCounter[0]);
}
Also used : TestData(com.sun.tck.lib.tgf.TestData) TestResult(com.oracle.tck.lib.autd2.TestResult) TestCase(com.sun.tck.test.TestCase) Test(org.junit.Test)

Example 7 with com.oracle.tck.lib.autd2

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

the class TestAfter method afterThrowsException.

@Test
public void afterThrowsException() {
    PrintWriter log = TU.createMockedPrintWriter();
    PrintWriter ref = TU.createMockedPrintWriter();
    final boolean[] afterCalled = new boolean[1];
    final boolean[] methodCalled = new boolean[1];
    final int[] counter = new int[] { 0 };
    final int[] afterCounter = new int[] { 0 };
    TestResult status = TU.runTestGroup(new TestAfter.Mytest() {

        private void myAfter() {
            org.junit.Assert.assertTrue(methodCalled[0]);
            afterCalled[0] = true;
            afterCounter[0]++;
            throw new ExceptionThrownFromAfter();
        }

        @TestCase
        @TestData("setup")
        @com.sun.tck.lib.tgf.After("myAfter")
        public void test(int i) {
            org.junit.Assert.assertFalse(afterCalled[0]);
            methodCalled[0] = true;
            counter[0]++;
        }
    }, log, ref, TU.EMPTY_ARGV);
    assertTrue(!status.isOK());
    assertTrue(afterCalled[0]);
    assertTrue(methodCalled[0]);
    assertEquals(3, counter[0]);
    assertEquals(1, afterCounter[0]);
    InOrder inOrder = inOrder(log, ref);
    inOrder.verify(log).println("Haha - this is overriden printStackTrace " + RANDOM);
    inOrder.verify(log).println("Method \"myAfter\" has thrown an exception com.oracle.tck.lib.autd2.unittests.tgfported.beforeafter.TestAfter$ExceptionThrownFromAfter: This exception is thrown from After " + RANDOM);
    inOrder.verify(log).println("test: Failed. Failed trying to invoke @After method \"myAfter\"");
    inOrder.verify(log).flush();
    inOrder.verify(ref).flush();
    verifyNoMoreInteractions(log, ref);
}
Also used : InOrder(org.mockito.InOrder) TestData(com.sun.tck.lib.tgf.TestData) TestCase(com.sun.tck.test.TestCase) TestResult(com.oracle.tck.lib.autd2.TestResult) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Example 8 with com.oracle.tck.lib.autd2

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

the class TestAfter method invalidSignature.

@Test
public void invalidSignature() {
    final boolean[] methodCalled = new boolean[1];
    final int[] counter = new int[] { 0 };
    com.oracle.tck.lib.autd2.TestResult status = com.oracle.tck.lib.autd2.unittests.TU.runTestGroup(new TestAfter.Mytest() {

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

        protected boolean afterWithInvalidSignature(int i, int j) {
            org.junit.Assert.assertTrue(methodCalled[0]);
            // to be sure that it was called only once
            return true;
        }

        @TestCase
        @TestData("mySetup")
        @com.sun.tck.lib.tgf.After("afterWithInvalidSignature")
        public void test(int i) {
            methodCalled[0] = true;
            counter[0]++;
        }
    }, TU.EMPTY_ARGV);
    assertTrue(!status.isOK());
    assertTrue(methodCalled[0]);
    assertEquals(3, counter[0]);
}
Also used : TestData(com.sun.tck.lib.tgf.TestData) Values(com.sun.tck.lib.tgf.Values) TestResult(com.oracle.tck.lib.autd2.TestResult) TestCase(com.sun.tck.test.TestCase) Test(org.junit.Test)

Example 9 with com.oracle.tck.lib.autd2

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

the class TestAfter method afterWasCalled.

@Test
public void afterWasCalled() {
    final boolean[] afterCalled = new boolean[1];
    final boolean[] methodCalled = new boolean[1];
    final int[] counter = new int[] { 0 };
    final int[] afterCounter = new int[] { 0 };
    com.oracle.tck.lib.autd2.TestResult status = com.oracle.tck.lib.autd2.unittests.TU.runTestGroup(new TestAfter.Mytest() {

        private void myAfter() {
            org.junit.Assert.assertTrue(methodCalled[0]);
            afterCalled[0] = true;
            afterCounter[0]++;
        }

        // this is optional
        @TestCase
        @TestData("setup")
        @com.sun.tck.lib.tgf.After("myAfter")
        public void test(int i) {
            org.junit.Assert.assertFalse(afterCalled[0]);
            methodCalled[0] = true;
            counter[0]++;
        }
    }, TU.EMPTY_ARGV);
    assertTrue(status.isOK());
    assertTrue(afterCalled[0]);
    assertTrue(methodCalled[0]);
    assertEquals(3, counter[0]);
    assertEquals(1, afterCounter[0]);
    Assert.assertEquals("Passed. test cases: 1; all passed", status.toString());
}
Also used : TestData(com.sun.tck.lib.tgf.TestData) TestCase(com.sun.tck.test.TestCase) TestResult(com.oracle.tck.lib.autd2.TestResult) Test(org.junit.Test)

Example 10 with com.oracle.tck.lib.autd2

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

the class TestAfter method afterOfNonVoidTypeWasCalled_NoParams.

@Test
public void afterOfNonVoidTypeWasCalled_NoParams() {
    final boolean[] afterCalled = new boolean[1];
    final boolean[] methodCalled = new boolean[1];
    final int[] counter = new int[] { 0 };
    final int[] afterCounter = new int[] { 0 };
    com.oracle.tck.lib.autd2.TestResult status = com.oracle.tck.lib.autd2.unittests.TU.runTestGroup(new TestAfter.Mytest() {

        private Class myAfter() {
            org.junit.Assert.assertTrue(methodCalled[0]);
            afterCalled[0] = true;
            afterCounter[0]++;
            return Runtime.class;
        }

        @TestCase
        @com.sun.tck.lib.tgf.After("myAfter")
        public void test() {
            org.junit.Assert.assertFalse(afterCalled[0]);
            methodCalled[0] = true;
            counter[0]++;
        }
    }, TU.EMPTY_ARGV);
    assertTrue(status.isOK());
    assertTrue(afterCalled[0]);
    assertTrue(methodCalled[0]);
    assertEquals(1, counter[0]);
    assertEquals(1, afterCounter[0]);
}
Also used : TestCase(com.sun.tck.test.TestCase) TestResult(com.oracle.tck.lib.autd2.TestResult) Test(org.junit.Test)

Aggregations

TestCase (com.sun.tck.test.TestCase)139 BaseTestGroup (com.oracle.tck.lib.autd2.unittests.BaseTestGroup)135 Test (org.junit.Test)107 ArrayList (java.util.ArrayList)73 TestData (com.sun.tck.lib.tgf.TestData)61 TestResult (com.oracle.tck.lib.autd2.TestResult)52 Values (com.sun.tck.lib.tgf.Values)50 TestGroup (com.sun.tck.test.TestGroup)30 HashSet (java.util.HashSet)13 DataFactory.createValues (com.sun.tck.lib.tgf.DataFactory.createValues)12 NonTestCase (com.oracle.tck.lib.autd2.NonTestCase)11 Operation (com.sun.tck.lib.tgf.data.Operation)10 TestObject (com.oracle.tck.lib.autd2.unittests.TestObject)8 Color (java.awt.Color)7 List (java.util.List)5 DataFactory (com.sun.tck.lib.tgf.DataFactory)4 DataFactory.createColumn (com.sun.tck.lib.tgf.DataFactory.createColumn)3 DataFactory.createRow (com.sun.tck.lib.tgf.DataFactory.createRow)3 PrintWriter (java.io.PrintWriter)3 java.util (java.util)3