Author: ivaynberg Date: Wed Feb 11 22:03:37 2009 New Revision: 743528 URL: http://svn.apache.org/viewvc?rev=743528&view=rev Log: WICKET-2190
Added: wicket/trunk/wicket/src/test/java/org/apache/wicket/FeedbackMessagesTest.java (with props) Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/feedback/FeedbackMessages.java Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/feedback/FeedbackMessages.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/feedback/FeedbackMessages.java?rev=743528&r1=743527&r2=743528&view=diff ============================================================================== --- wicket/trunk/wicket/src/main/java/org/apache/wicket/feedback/FeedbackMessages.java (original) +++ wicket/trunk/wicket/src/main/java/org/apache/wicket/feedback/FeedbackMessages.java Wed Feb 11 22:03:37 2009 @@ -189,8 +189,14 @@ */ public final boolean hasMessageFor(Component component, int level) { - final FeedbackMessage message = messageForComponent(component); - return message != null && message.isLevel(level); + for (FeedbackMessage message : messages) + { + if (message.getReporter() == component && message.isLevel(level)) + { + return true; + } + } + return false; } /** @@ -229,6 +235,8 @@ /** * Looks up a message for the given component. * + * TODO: 1.5 This should be deprecated and return a Collection. + * * @param component * the component to look up the message for * @return the message that is found for the given component (first match) or null if none was Added: wicket/trunk/wicket/src/test/java/org/apache/wicket/FeedbackMessagesTest.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/FeedbackMessagesTest.java?rev=743528&view=auto ============================================================================== --- wicket/trunk/wicket/src/test/java/org/apache/wicket/FeedbackMessagesTest.java (added) +++ wicket/trunk/wicket/src/test/java/org/apache/wicket/FeedbackMessagesTest.java Wed Feb 11 22:03:37 2009 @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket; + +import junit.framework.Assert; +import junit.framework.TestCase; + +import org.apache.wicket.Page; +import org.apache.wicket.Session; +import org.apache.wicket.feedback.FeedbackMessage; +import org.apache.wicket.feedback.FeedbackMessages; +import org.apache.wicket.util.tester.WicketTester; + +/** + * @author oli + */ +public class FeedbackMessagesTest extends TestCase +{ + + WicketTester tester; + + @Override + protected void setUp() throws Exception + { + tester = new WicketTester(); + } + + @Override + protected void tearDown() throws Exception + { + tester.destroy(); + } + + /** + * Test method for + * {...@link org.apache.wicket.feedback.FeedbackMessages#hasMessageFor(org.apache.wicket.Component, int)} + * . + */ + public void testHasMessageForComponentInt() + { + Session session = tester.setupRequestAndResponse().getSession(); + final Page page = new TestPage_1(); + tester.startPage(page); + page.debug("debug message"); + page.info("info message"); + page.error("error message"); + Assert.assertTrue(session.getFeedbackMessages().hasMessageFor(page, FeedbackMessage.ERROR)); + } +} Propchange: wicket/trunk/wicket/src/test/java/org/apache/wicket/FeedbackMessagesTest.java ------------------------------------------------------------------------------ svn:mime-type = text/plain