Search in sources :

Example 16 with AssertionFailedException

use of com.sun.tck.lib.AssertionFailedException in project jtharness by openjdk.

the class TestPureAssert method testAssertSame_Negative_Message_arrays.

@Test
public void testAssertSame_Negative_Message_arrays() {
    try {
        com.sun.tck.lib.Assert.assertSame(new TestObject[] { new TestObject(RANDOM_STRING) }, new TestObject[] { new TestObject(RANDOM_STRING) });
        fail("Exception not thrown");
    } catch (AssertionFailedException e) {
        assertEquals("Expected same as : \"[" + new TestObject(RANDOM_STRING) + "]\", was given: \"[" + new TestObject(RANDOM_STRING) + "]\"", e.getMessage());
    }
}
Also used : TestObject(com.oracle.tck.lib.autd2.unittests.TestObject) AssertionFailedException(com.sun.tck.lib.AssertionFailedException) Test(org.junit.Test)

Example 17 with AssertionFailedException

use of com.sun.tck.lib.AssertionFailedException in project jtharness by openjdk.

the class TestPureAssert method testAssertNotEquals_Negative_message.

@Test
public void testAssertNotEquals_Negative_message() {
    TestObject to = new TestObject(RANDOM_STRING);
    try {
        com.sun.tck.lib.Assert.assertNotEquals(to, to, "234241234dfasfsaf234234");
        fail("AssertionFailedException was not thrown");
    } catch (AssertionFailedException e) {
        assertEquals("234241234dfasfsaf234234\nExpected unequal objects, were equal: \"" + to + "\", \"" + to + "\"", e.getMessage());
    }
}
Also used : TestObject(com.oracle.tck.lib.autd2.unittests.TestObject) AssertionFailedException(com.sun.tck.lib.AssertionFailedException) Test(org.junit.Test)

Example 18 with AssertionFailedException

use of com.sun.tck.lib.AssertionFailedException in project jtharness by openjdk.

the class TestPureAssert method testAssertNotSame_Negative_CustomMessage_throwable.

@Test
public void testAssertNotSame_Negative_CustomMessage_throwable() {
    TestObject testObject = new TestObject(RANDOM_STRING);
    RuntimeException runtimeException = new RuntimeException();
    try {
        com.sun.tck.lib.Assert.assertNotSame(testObject, testObject, RANDOM_STRING + "32423434", runtimeException);
        fail("Exception not thrown");
    } catch (AssertionFailedException e) {
        assertEquals(RANDOM_STRING + "32423434", e.getMessage());
        assertSame(runtimeException, e.getCause());
    }
}
Also used : TestObject(com.oracle.tck.lib.autd2.unittests.TestObject) AssertionFailedException(com.sun.tck.lib.AssertionFailedException) Test(org.junit.Test)

Example 19 with AssertionFailedException

use of com.sun.tck.lib.AssertionFailedException in project jtharness by openjdk.

the class TestPureAssert method testAssertEquals_Negative_message_exception.

@Test
public void testAssertEquals_Negative_message_exception() {
    TestObject testObject_1 = new TestObject("first" + RANDOM_STRING);
    TestObject testObject_2 = new TestObject("second" + RANDOM_STRING);
    RuntimeException exception = new RuntimeException();
    try {
        com.sun.tck.lib.Assert.assertEquals(testObject_1, testObject_2, RANDOM_STRING + "message", exception);
        fail("Exception not thrown");
    } catch (AssertionFailedException e) {
        assertEquals(RANDOM_STRING + "message", e.getMessage());
        assertSame(exception, e.getCause());
    }
}
Also used : TestObject(com.oracle.tck.lib.autd2.unittests.TestObject) AssertionFailedException(com.sun.tck.lib.AssertionFailedException) Test(org.junit.Test)

Example 20 with AssertionFailedException

use of com.sun.tck.lib.AssertionFailedException in project jtharness by openjdk.

the class TestPureAssert method testAssertNotSame_Negative_exception_1.

@Test
public void testAssertNotSame_Negative_exception_1() {
    TestObject testObject = new TestObject(RANDOM_STRING);
    RuntimeException cause = new RuntimeException();
    try {
        com.sun.tck.lib.Assert.assertNotSame(testObject, testObject, cause);
        fail("Exception not thrown");
    } catch (AssertionFailedException e) {
        assertSame(cause, e.getCause());
        assertEquals("Expected not same : \"" + testObject + "\"", e.getMessage());
    }
}
Also used : TestObject(com.oracle.tck.lib.autd2.unittests.TestObject) AssertionFailedException(com.sun.tck.lib.AssertionFailedException) Test(org.junit.Test)

Aggregations

TestObject (com.oracle.tck.lib.autd2.unittests.TestObject)22 AssertionFailedException (com.sun.tck.lib.AssertionFailedException)22 Test (org.junit.Test)22