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.util;
21
22 import org.apache.myfaces.tobago.component.UILink;
23 import org.apache.myfaces.tobago.internal.config.AbstractTobagoTestBase;
24 import org.junit.Assert;
25 import org.junit.Test;
26
27 import javax.faces.component.UIParameter;
28
29 public class RenderUtilsUnitTest extends AbstractTobagoTestBase {
30
31 @Test
32 public void simple() {
33 final UILink link = new UILink();
34 link.setLink("local.xhtml");
35 final String url = RenderUtils.generateUrl(getFacesContext(), link);
36 Assert.assertEquals("local.xhtml", url);
37 }
38
39 @Test
40 public void mailto() {
41 final UILink link = new UILink();
42 link.setLink("mailto:MyFaces Discussion <users@myfaces.apache.org>");
43
44 final UIParameter subject = new UIParameter();
45 subject.setName("subject");
46 subject.setValue("[Tobago] Preparation for the 5.0.0 release");
47 link.getChildren().add(subject);
48
49 final UIParameter body = new UIParameter();
50 body.setName("body");
51 body.setValue("Hi, folks,\n"
52 + "\n"
53 + "we plan to build version 5.0.0 of Tobago soon.");
54 link.getChildren().add(body);
55
56 final String url = RenderUtils.generateUrl(getFacesContext(), link);
57 Assert.assertEquals("mailto:MyFaces Discussion <users@myfaces.apache.org>"
58 + "?subject=%5BTobago%5D%20Preparation%20for%20the%205.0.0%20release"
59 + "&body=Hi%2C%20folks%2C%0A%0Awe%20plan%20to%20build%20version%205.0.0%20of%20Tobago%20soon.", url);
60 }
61 }