2 * Copyright 2005-2010 the original author or authors.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.wamblee.wicket.behavior;
18 import static org.mockito.Matchers.*;
19 import static org.mockito.Mockito.*;
20 import junit.framework.TestCase;
22 import org.apache.wicket.markup.html.WebPage;
23 import org.apache.wicket.protocol.http.WebResponse;
25 public class CompositePageBehaviorTest extends TestCase {
27 private CompositePageBehavior composite;
28 private PageBehavior behavior1;
29 private PageBehavior behavior2;
33 protected void setUp() throws Exception {
34 composite = new CompositePageBehavior();
35 behavior1 = mock(PageBehavior.class);
36 behavior2 = mock(PageBehavior.class);
37 page = mock(WebPage.class);
38 composite.add(behavior1);
39 composite.add(behavior2);
42 public void testOnBeforeRender() {
43 composite.onBeforeRender(page);
44 verify(behavior1).onBeforeRender(same(page));
45 verify(behavior2).onBeforeRender(same(page));
46 verifyNoMoreInteractions(behavior1);
47 verifyNoMoreInteractions(behavior2);
50 public void testSetHeaders() {
51 WebResponse response = mock(WebResponse.class);
52 composite.setHeaders(page, response);
53 verify(behavior1).setHeaders(same(page), same(response));
54 verify(behavior2).setHeaders(same(page), same(response));
55 verifyNoMoreInteractions(behavior1);
56 verifyNoMoreInteractions(behavior2);
59 public void testOnAfterRender() {
60 composite.onAfterRender(page);
61 verify(behavior1).onAfterRender(same(page));
62 verify(behavior2).onAfterRender(same(page));
63 verifyNoMoreInteractions(behavior1);
64 verifyNoMoreInteractions(behavior2);