1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.creadur.whisker.out.velocity;
20
21 import static org.apache.creadur.whisker.app.ConfigurationBuilder.*;
22
23 import org.apache.creadur.whisker.model.Descriptor;
24 import org.apache.creadur.whisker.model.Resource;
25
26 import junit.framework.TestCase;
27
28 public class TestRenderingHelper extends TestCase {
29
30 private static final String A_SOURCE_URL = "http://example.org/sample";
31
32 RenderingHelper subject;
33
34 Resource resourceWithSourceUrl;
35 Resource resourceNoSourceUrl;
36
37 Descriptor work;
38
39 @Override
40 protected void setUp() throws Exception {
41 super.setUp();
42 resourceWithSourceUrl = new Resource("a name", "an:id", A_SOURCE_URL);
43 resourceNoSourceUrl = new Resource("a name", "an:id", null);
44 }
45
46 public void testSourceWithSourceUrlsConfiguration() {
47 subject = new RenderingHelper(work,
48 aConfiguration().withSourceURLsInLicense().build());
49 assertEquals(subject.sourceUrl(resourceWithSourceUrl), " from " + A_SOURCE_URL);
50 }
51
52 public void testSourceNoSourceUrlsConfiguration() {
53 subject = new RenderingHelper(work,
54 aConfiguration().noSourceURLsInLicense().build());
55 assertEquals(subject.sourceUrl(resourceWithSourceUrl), "");
56 }
57
58 public void testNoSourceWithSourceUrlsConfiguration() {
59 subject = new RenderingHelper(work,
60 aConfiguration().withSourceURLsInLicense().build());
61 assertEquals(subject.sourceUrl(resourceNoSourceUrl), "");
62 }
63
64 public void testNoSourceNoSourceUrlsConfiguration() {
65 subject = new RenderingHelper(work,
66 aConfiguration().noSourceURLsInLicense().build());
67 assertEquals(subject.sourceUrl(resourceNoSourceUrl), "");
68 }
69
70 }