View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
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  }