01: // Copyright 2007 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // Unless required by applicable law or agreed to in writing, software
10: // distributed under the License is distributed on an "AS IS" BASIS,
11: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: // See the License for the specific language governing permissions and
13: // limitations under the License.
14:
15: package org.apache.tapestry.corelib.components;
16:
17: import org.apache.tapestry.Block;
18: import org.apache.tapestry.internal.test.InternalBaseTestCase;
19: import org.testng.annotations.Test;
20:
21: public class IfTest extends InternalBaseTestCase {
22: @Test
23: public void true_test_renders_body() {
24: If component = new If();
25:
26: component.setup(true, false, null);
27:
28: assertNull(component.beginRender());
29: assertTrue(component.beforeRenderBody());
30: }
31:
32: @Test
33: public void false_test_renders_else_block() {
34: Block block = mockBlock();
35:
36: replay();
37:
38: If component = new If();
39:
40: component.setup(false, false, block);
41:
42: assertSame(component.beginRender(), block);
43: assertFalse(component.beforeRenderBody());
44:
45: verify();
46: }
47:
48: @Test
49: public void negate_inverts_test() {
50: If component = new If();
51:
52: component.setup(false, true, null);
53:
54: assertNull(component.beginRender());
55: assertTrue(component.beforeRenderBody());
56: }
57: }
|