use of com.sun.tck.lib.tgf.TestData in project jtharness by openjdk.
the class Examples method test_02.
@Test
public void test_02() {
@TestGroup
class Test {
Values spaces = createColumn(RED, GREEN, WHITE).filter(Color::getColorSpace);
@TestCase
public void test(@TestData("spaces") ColorSpace cs) {
Assert.assertTrue(cs.isCS_sRGB());
}
}
TestResult testResult = TU.runTestGroup(new Test());
Assert.assertTrue(testResult.isOK());
Assert.assertEquals("test cases: 1; all passed", testResult.getMessage());
}
use of com.sun.tck.lib.tgf.TestData in project jtharness by openjdk.
the class Examples method test_03_array.
@Test
public void test_03_array() {
@TestGroup
class Test {
Values quantities = createColumn(new Color[] { BLUE, BLACK, WHITE }, new Color[] { BLACK, WHITE, BLUE, GREEN }, new Color[] { BLUE, BLACK }, new Color[] { RED }).<Color[]>filter(colors -> createRow(colors.length));
@TestCase
@TestData("quantities")
public void test(int quantity) {
assertTrue(quantity > 0);
}
}
com.oracle.tck.lib.autd2.TestResult s = TU.runTestGroup(new Test());
Assert.assertTrue(s.isOK());
Assert.assertEquals("test cases: 1; all passed", s.getMessage());
}
use of com.sun.tck.lib.tgf.TestData in project jtharness by openjdk.
the class Multiply method testRun_DataFilteredOutCompletely4.
@Test
public void testRun_DataFilteredOutCompletely4() {
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 setupOne() {
return DataFactory.createColumn().multiply(1, 2, 3);
}
@TestCase
@TestData("setupOne")
public void myTest(String s) {
arrayList.add(s);
}
}, TU.EMPTY_ARGV);
Assert.assertEquals(0, arrayList.size());
Assert.assertTrue(status.isOK());
Assert.assertEquals("Passed. test cases: 1; all passed", status.toString());
}
use of com.sun.tck.lib.tgf.TestData in project jtharness by openjdk.
the class TestAfter method runtimeSkippingFromAfter_testPasses.
@Test
public void runtimeSkippingFromAfter_testPasses() {
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() {
protected Values mySetup() {
return DataFactory.createColumn(1, 2, 3);
}
private void myAfter() {
org.junit.Assert.assertTrue(methodCalled[0]);
// to be sure that it was called only once
org.junit.Assert.assertFalse(afterCalled[0]);
afterCalled[0] = true;
afterCounter[0]++;
com.sun.tck.lib.Assert.reportNotApplicable(true);
}
@TestCase
@TestData("mySetup")
@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());
assertEquals("test cases: 1; all not applicable", status.getMessage());
assertTrue(afterCalled[0]);
assertTrue(methodCalled[0]);
assertEquals(3, counter[0]);
assertEquals(1, afterCounter[0]);
}
use of com.sun.tck.lib.tgf.TestData in project jtharness by openjdk.
the class TestAfter method afterCalledOnce.
@Test
public void afterCalledOnce() {
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() {
protected Values mySetup() {
return DataFactory.createColumn(1, 2, 3);
}
private void myAfter() {
org.junit.Assert.assertTrue(methodCalled[0]);
// to be sure that it was called only once
org.junit.Assert.assertFalse(afterCalled[0]);
afterCalled[0] = true;
afterCounter[0]++;
}
@TestCase
@TestData("mySetup")
@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]);
}
Aggregations