001: /***************************************************************
002: * This file is part of the [fleXive](R) project.
003: *
004: * Copyright (c) 1999-2007
005: * UCS - unique computing solutions gmbh (http://www.ucs.at)
006: * All rights reserved
007: *
008: * The [fleXive](R) project is free software; you can redistribute
009: * it and/or modify it under the terms of the GNU General Public
010: * License as published by the Free Software Foundation;
011: * either version 2 of the License, or (at your option) any
012: * later version.
013: *
014: * The GNU General Public License can be found at
015: * http://www.gnu.org/copyleft/gpl.html.
016: * A copy is found in the textfile GPL.txt and important notices to the
017: * license from the author are found in LICENSE.txt distributed with
018: * these libraries.
019: *
020: * This library is distributed in the hope that it will be useful,
021: * but WITHOUT ANY WARRANTY; without even the implied warranty of
022: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
023: * GNU General Public License for more details.
024: *
025: * For further information about UCS - unique computing solutions gmbh,
026: * please see the company website: http://www.ucs.at
027: *
028: * For further information about [fleXive](R), please see the
029: * project website: http://www.flexive.org
030: *
031: *
032: * This copyright notice MUST APPEAR in all copies of the file!
033: ***************************************************************/package com.flexive.tests.embedded.jsf;
034:
035: import com.flexive.faces.messages.FxFacesMessage;
036: import com.flexive.shared.exceptions.FxAccountInUseException;
037: import com.flexive.shared.exceptions.FxLoginFailedException;
038: import com.flexive.shared.exceptions.FxLogoutFailedException;
039: import static com.flexive.tests.embedded.FxTestUtils.login;
040: import static com.flexive.tests.embedded.FxTestUtils.logout;
041: import com.flexive.tests.embedded.TestUsers;
042: import org.testng.annotations.AfterClass;
043: import org.testng.annotations.BeforeClass;
044: import org.testng.annotations.Test;
045:
046: /**
047: * FxFacesMessage tests.
048: *
049: * @author Daniel Lichtenberger (daniel.lichtenberger@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
050: */
051: @Test(groups={"jsf"})
052: public class FxFacesMessageTest {
053:
054: private static final String MSG_TEST_1 = "test.jsf.fxFacesMessage.1";
055:
056: @BeforeClass
057: public void beforeClass() throws FxLoginFailedException,
058: FxAccountInUseException {
059: login(TestUsers.SUPERVISOR);
060: }
061:
062: @AfterClass
063: public void afterClass() throws FxLoginFailedException,
064: FxAccountInUseException, FxLogoutFailedException {
065: logout();
066: }
067:
068: @Test
069: public void equalsNullDetails() {
070: FxFacesMessage message1 = new FxFacesMessage(
071: FxFacesMessage.SEVERITY_ERROR, MSG_TEST_1);
072: FxFacesMessage message2 = new FxFacesMessage(
073: FxFacesMessage.SEVERITY_ERROR, MSG_TEST_1);
074: assert message1.equals(message2) : "Messages not equal.";
075: assert message1.hashCode() == message2.hashCode() : "Hashcodes not equal";
076: }
077:
078: @Test
079: public void unequalsArgs() {
080: FxFacesMessage message1 = new FxFacesMessage(
081: FxFacesMessage.SEVERITY_ERROR, MSG_TEST_1, 21);
082: FxFacesMessage message2 = new FxFacesMessage(
083: FxFacesMessage.SEVERITY_ERROR, MSG_TEST_1, 22);
084: assert !message1.equals(message2) : "Messages with different object args considered equal."
085: + "\nMessage 1: "
086: + message1.getSummary()
087: + ", Message 2: " + message2.getSummary();
088: assert message1.hashCode() != message2.hashCode() : "Different messages should have different hash codes";
089: }
090:
091: @Test
092: public void equalsArgs() {
093: FxFacesMessage message1 = new FxFacesMessage(
094: FxFacesMessage.SEVERITY_ERROR, MSG_TEST_1, 21);
095: FxFacesMessage message2 = new FxFacesMessage(
096: FxFacesMessage.SEVERITY_ERROR, MSG_TEST_1, 21);
097: assert message1.equals(message2) : "Messages with same object args considered unequal."
098: + "\nMessage 1: "
099: + message1.getSummary()
100: + ", Message 2: " + message2.getSummary();
101: assert message1.hashCode() == message2.hashCode() : "Hashcodes not equal";
102: }
103: }
|