use of com.oracle.tck.lib.autd2.unittests.BaseTestGroup in project jtharness by openjdk.
the class TestBefore method beforeIsBeforeValuesInitialization.
@Test
public void beforeIsBeforeValuesInitialization() {
final boolean[] beforeCalled = new boolean[1];
final boolean[] valuesInited = new boolean[1];
com.oracle.tck.lib.autd2.TestResult status = com.oracle.tck.lib.autd2.unittests.TU.runTestGroup(new BaseTestGroup() {
Object[] objects() {
valuesInited[0] = true;
return new Object[] { new Object() };
}
private void before() {
Assert.assertFalse(valuesInited[0]);
beforeCalled[0] = true;
}
@TestCase
@TestData("objects")
@Before("before")
public void test(Object o) {
Assert.assertTrue(beforeCalled[0]);
}
}, TU.EMPTY_ARGV);
assertTrue(status.isOK());
assertTrue(beforeCalled[0]);
assertTrue(valuesInited[0]);
}
use of com.oracle.tck.lib.autd2.unittests.BaseTestGroup in project jtharness by openjdk.
the class TestBeforeAndAfter method beforeThrowsException.
@Test
public void beforeThrowsException() {
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")
@TestData("mySetup")
public void test(int i) {
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]);
}
use of com.oracle.tck.lib.autd2.unittests.BaseTestGroup in project jtharness by openjdk.
the class TestBeforeAndAfter method plain.
@Test
public void plain() {
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]++;
}
@TestCase
@Before("myBefore")
@After("myAfter")
@TestData("mySetup")
public void test(int i) {
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(3, methodCounter[0]);
Assert.assertEquals(1, afterCounter[0]);
Assert.assertEquals(1, beforeCounter[0]);
}
use of com.oracle.tck.lib.autd2.unittests.BaseTestGroup 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]);
}
use of com.oracle.tck.lib.autd2.unittests.BaseTestGroup 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]);
}
Aggregations