1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.myfaces.tobago.internal.renderkit.renderer;
21
22 import org.apache.myfaces.tobago.component.RendererTypes;
23 import org.apache.myfaces.tobago.component.Tags;
24 import org.apache.myfaces.tobago.component.UILink;
25 import org.apache.myfaces.tobago.component.UILinks;
26 import org.apache.myfaces.tobago.util.ComponentUtils;
27 import org.junit.Assert;
28 import org.junit.jupiter.api.Test;
29
30 import java.io.IOException;
31
32 public class LinksRendererUnitTest extends RendererTestBase {
33
34 @Test
35 public void linkInsideLinks() throws IOException {
36 final UILinks l = (UILinks) ComponentUtils.createComponent(
37 facesContext, Tags.links.componentType(), RendererTypes.Links, "list");
38 final UILink c = (UILink) ComponentUtils.createComponent(
39 facesContext, Tags.link.componentType(), RendererTypes.Link, "id");
40 c.setLabel("apache");
41 c.setLink("https://www.apache.org/");
42 l.getChildren().add(c);
43 l.encodeAll(facesContext);
44
45 Assert.assertEquals(loadHtml("renderer/links/link-inside-links.html"), formattedResult());
46 }
47
48 @Test
49 public void linkInsideLinksSub() throws IOException {
50 final UILinks l = (UILinks) ComponentUtils.createComponent(
51 facesContext, Tags.links.componentType(), RendererTypes.Links, "list");
52 final UILink c = (UILink) ComponentUtils.createComponent(
53 facesContext, Tags.link.componentType(), RendererTypes.Link, "id");
54 c.setLabel("apache");
55
56 final UILink s = (UILink) ComponentUtils.createComponent(
57 facesContext, Tags.link.componentType(), RendererTypes.Link, "sub");
58 s.setLabel("sub");
59 s.setLink("https://www.apache.org/");
60 c.getChildren().add(s);
61
62 l.getChildren().add(c);
63 l.encodeAll(facesContext);
64
65 Assert.assertEquals(loadHtml("renderer/links/link-inside-links-sub.html"), formattedResult());
66 }
67
68 }