Search in sources :

Example 6 with AssertionFailedException

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

the class TestPureAssert method testAssertNotEquals_arrays_equal_message.

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

Example 7 with AssertionFailedException

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

the class TestPureAssert method testAssertSame_Negative_Message_exception_message.

@Test
public void testAssertSame_Negative_Message_exception_message() {
    RuntimeException exception = new RuntimeException();
    try {
        com.sun.tck.lib.Assert.assertSame(new TestObject(RANDOM_STRING), new TestObject(RANDOM_STRING), "sdfsdfsdfsf", exception);
        fail("Exception not thrown");
    } catch (AssertionFailedException e) {
        assertEquals("sdfsdfsdfsf", 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 8 with AssertionFailedException

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

the class TestPureAssert method testAssertNotEquals_Negative_Message_arrays.

@Test
public void testAssertNotEquals_Negative_Message_arrays() {
    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;
        }
    };
    try {
        com.sun.tck.lib.Assert.assertNotEquals(new TestObject[] { testObject_1 }, new TestObject[] { testObject_2 });
        fail("Exception not thrown");
    } catch (AssertionFailedException e) {
        assertEquals("Expected unequal objects, were equal: \"[TestObject:theFirst]\", \"[TestObject:theSecond]\"", e.getMessage());
    }
}
Also used : TestObject(com.oracle.tck.lib.autd2.unittests.TestObject) TestObject(com.oracle.tck.lib.autd2.unittests.TestObject) AssertionFailedException(com.sun.tck.lib.AssertionFailedException) Test(org.junit.Test)

Example 9 with AssertionFailedException

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

the class TestPureAssert method testAssertNotSame_Negative_Message.

@Test
public void testAssertNotSame_Negative_Message() {
    TestObject testObject = new TestObject(RANDOM_STRING);
    try {
        com.sun.tck.lib.Assert.assertNotSame(testObject, testObject);
        fail("Exception not thrown");
    } catch (AssertionFailedException e) {
        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)

Example 10 with AssertionFailedException

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

the class TestPureAssert method testAssertEquals_Negative_Message_custom.

@Test
public void testAssertEquals_Negative_Message_custom() {
    TestObject testObject_1 = new TestObject("1" + RANDOM_STRING);
    TestObject testObject_2 = new TestObject("2" + RANDOM_STRING);
    try {
        com.sun.tck.lib.Assert.assertEquals(testObject_1, testObject_2, "MyMessage" + RANDOM_STRING);
        fail("Exception not thrown");
    } catch (AssertionFailedException e) {
        assertEquals("MyMessage" + RANDOM_STRING + "\n" + "Expected equal to : \"" + testObject_1 + "\", was given: \"" + testObject_2 + "\"", 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