1 package uba.db.testhelpers;
2
3 import junit.framework.AssertionFailedError;
4 import junit.framework.TestCase;
5
6 /***
7 * @version $Revision: 1.2 $
8 */
9 public class TestUtilsTest extends TestCase {
10
11 /***
12 * Test {@link TestUtils#assertEqualsImplementation} en objetos que tienen una
13 * correcta implementacion de equals.
14 */
15 public void testAssertEqualsImplementationPassed() {
16 try {
17 TestUtils.assertEqualsImplementation("obj", "obj", "other");
18 } catch (AssertionFailedError e) {
19 fail("No se deberia haber generado ningun assertion error");
20 }
21 }
22
23 /***
24 * Test {@link TestUtils#assertEqualsImplementation} en objetos que tienen una
25 * correcta implementacion de equals, pero se testea el caso en que dos de los
26 * parametros deberian de ser iguales o distintos pero no lo son.
27 */
28 public void testAssertEqualsImplementationFailed() {
29 boolean assertionErrorCatched;
30
31 try {
32 TestUtils.assertEqualsImplementation("obj", "other", "other");
33 assertionErrorCatched = false;
34 } catch (AssertionFailedError e) {
35 assertionErrorCatched = true;
36 }
37
38 assertTrue(assertionErrorCatched);
39
40 try {
41 TestUtils.assertEqualsImplementation("obj", "obj", "obj");
42 assertionErrorCatched = false;
43 } catch (AssertionFailedError e) {
44 assertionErrorCatched = true;
45 }
46
47 assertTrue(assertionErrorCatched);
48 }
49 }