use of com.sun.tck.lib.AssertionFailedException in project jtharness by openjdk.
the class TestPureAssert method testAssertEquals_Negative_Message.
@Test
public void testAssertEquals_Negative_Message() {
TestObject testObject_1 = new TestObject("first" + RANDOM_STRING);
TestObject testObject_2 = new TestObject("second" + RANDOM_STRING);
try {
com.sun.tck.lib.Assert.assertEquals(testObject_1, testObject_2);
fail("Exception not thrown");
} catch (AssertionFailedException e) {
assertEquals("Expected equal to : \"" + testObject_1 + "\", was given: \"" + testObject_2 + "\"", e.getMessage());
}
}
use of com.sun.tck.lib.AssertionFailedException in project jtharness by openjdk.
the class TestPureAssert method testAssertSame_Negative_standardMessage_exception.
@Test
public void testAssertSame_Negative_standardMessage_exception() {
RuntimeException runtimeException = new RuntimeException();
try {
com.sun.tck.lib.Assert.assertSame(new TestObject(RANDOM_STRING), new TestObject(RANDOM_STRING), runtimeException);
fail("Exception not thrown");
} catch (AssertionFailedException e) {
assertSame(runtimeException, e.getCause());
assertEquals("Expected same as : \"" + new TestObject(RANDOM_STRING) + "\", was given: \"" + new TestObject(RANDOM_STRING) + "\"", e.getMessage());
}
}
use of com.sun.tck.lib.AssertionFailedException in project jtharness by openjdk.
the class TestPureAssert method testAssertSame_Negative_Message_customMessage.
@Test
public void testAssertSame_Negative_Message_customMessage() {
final TestObject to = new TestObject(RANDOM_STRING);
final TestObject to1 = new TestObject(RANDOM_STRING);
try {
com.sun.tck.lib.Assert.assertSame(to, to1, "werwer12534523535");
fail("Exception not thrown");
} catch (AssertionFailedException e) {
assertEquals("werwer12534523535\nExpected same as : \"" + to + "\", was given: \"" + to1 + "\"", e.getMessage());
}
}
use of com.sun.tck.lib.AssertionFailedException in project jtharness by openjdk.
the class TestPureAssert method testAssertEquals_Negative_Arrays2dim_Object.
@Test
public void testAssertEquals_Negative_Arrays2dim_Object() {
TestObject[][] arr_1 = new TestObject[][] { { new TestObject("one") }, { new TestObject("three") } };
TestObject[][] arr_2 = new TestObject[][] { { new TestObject("two") }, { new TestObject("four") } };
try {
com.sun.tck.lib.Assert.assertEquals(arr_1, arr_2);
fail("Exception not thrown");
} catch (AssertionFailedException e) {
assertEquals("Expected equal to : \"[[TestObject:one], [TestObject:three]]\", was given: \"[[TestObject:two], [TestObject:four]]\"", e.getMessage());
}
}
use of com.sun.tck.lib.AssertionFailedException in project jtharness by openjdk.
the class TestPureAssert method testAssertNotEquals_Negative_exception.
@Test
public void testAssertNotEquals_Negative_exception() {
TestObject testObject_1 = new TestObject("theFirst") {
public boolean equals(Object o) {
return true;
}
};
TestObject testObject_2 = new TestObject("theSecond") {
public boolean equals(Object o) {
return true;
}
};
RuntimeException cause = new RuntimeException();
try {
com.sun.tck.lib.Assert.assertNotEquals(testObject_1, testObject_2, cause);
fail("Exception not thrown");
} catch (AssertionFailedException e) {
assertEquals("Expected unequal objects, were equal: \"TestObject:theFirst\", \"TestObject:theSecond\"", e.getMessage());
assertSame(cause, e.getCause());
}
}
Aggregations