1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.component.html.ext;
20
21 import java.io.IOException;
22
23 import javax.faces.application.FacesMessage;
24 import javax.faces.component.UIComponent;
25
26 import junit.framework.Test;
27
28 import org.apache.myfaces.test.AbstractTomahawkViewControllerTestCase;
29 import org.apache.myfaces.test.utils.TestUtils;
30
31 public class HtmlMessageTest extends AbstractTomahawkViewControllerTestCase
32 {
33
34 public HtmlMessageTest(String name)
35 {
36 super(name);
37 }
38
39 protected void setUp() throws Exception
40 {
41 super.setUp();
42 }
43
44 protected void tearDown() throws Exception
45 {
46 super.tearDown();
47 }
48
49
50
51
52 public void testDefaultRenderer()
53 {
54
55 HtmlPanelGroup panelGroup = new HtmlPanelGroup();
56
57
58 UIComponent referencedComponent = new HtmlInputText();
59 referencedComponent.setId("referencedComponent");
60
61 panelGroup.getChildren().add(referencedComponent);
62 facesContext.addMessage(referencedComponent.getId(), new FacesMessage(
63 FacesMessage.SEVERITY_ERROR, "summary", "detail"));
64
65
66 HtmlMessage component = new HtmlMessage();
67 component.setId("TestComponent");
68
69 referencedComponent.setParent(panelGroup);
70 panelGroup.getChildren().add(component);
71 component.setFor(referencedComponent.getId());
72
73
74 try
75 {
76 TestUtils.renderComponent(facesContext, panelGroup);
77 }
78 catch (IOException e)
79 {
80 fail(e.getMessage());
81 }
82
83
84 assertIdExists(component.getId());
85 }
86 }