1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
package org.devacfr.maven.skins.reflow; |
20 |
|
|
21 |
|
import java.io.IOException; |
22 |
|
import java.net.URI; |
23 |
|
|
24 |
|
import org.devacfr.maven.skins.reflow.URITool.URLRebaser; |
25 |
|
import org.devacfr.testing.jupiter.TestCase; |
26 |
|
import org.junit.jupiter.api.Test; |
27 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (56) |
Complexity: 10 |
Complexity Density: 0,22 |
|
28 |
|
public class URIToolTest extends TestCase { |
29 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
1PASS
|
|
30 |
1 |
@Test... |
31 |
|
public void shouldRelativizeLinkAccetupNullBase() throws IOException { |
32 |
1 |
final String actual = URITool.relativizeLink(null, "link"); |
33 |
1 |
assertEquals("link", actual); |
34 |
|
} |
35 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
1PASS
|
|
36 |
1 |
@Test... |
37 |
|
public void shouldRelativizeLinkAcceptsAbsoluteBaseUri() throws IOException { |
38 |
1 |
final String actual = URITool.relativizeLink("reflow-maven-skin", "link"); |
39 |
1 |
assertEquals("link", actual); |
40 |
|
} |
41 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
1PASS
|
|
42 |
1 |
@Test... |
43 |
|
public void relativeRootLink() throws IOException { |
44 |
1 |
final String absoluteResourceURL = "https://devacfr.github.io/reflow-maven-skin"; |
45 |
1 |
final String currentFilename = "index.html"; |
46 |
1 |
final String projectUrl = "https://devacfr.github.io/reflow-maven-skin/"; |
47 |
|
|
48 |
1 |
final String currentFileDir = URITool.toURI(projectUrl).resolve(currentFilename).resolve(".").toString(); |
49 |
1 |
final String actual = URITool.relativizeLink(currentFileDir, absoluteResourceURL); |
50 |
1 |
assertEquals(".", actual); |
51 |
|
} |
52 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
1PASS
|
|
53 |
1 |
@Test... |
54 |
|
public void relativeSubModuleLink() throws IOException { |
55 |
1 |
final String absoluteResourceURL = "https://devacfr.github.io/reflow-maven-skin"; |
56 |
1 |
final String currentFilename = "index.html"; |
57 |
1 |
final String projectUrl = "https://devacfr.github.io/reflow-maven-skin/skin/"; |
58 |
|
|
59 |
1 |
final String currentFileDir = URITool.toURI(projectUrl).resolve(currentFilename).resolve(".").toString(); |
60 |
1 |
final String actual = URITool.relativizeLink(currentFileDir, absoluteResourceURL); |
61 |
1 |
assertEquals("..", actual); |
62 |
|
} |
63 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
1PASS
|
|
64 |
1 |
@Test... |
65 |
|
public void relativeSubFolderLink() throws IOException { |
66 |
1 |
final String absoluteResourceURL = "https://devacfr.github.io/reflow-maven-skin"; |
67 |
1 |
final String currentFilename = "themes/index.html"; |
68 |
1 |
final String projectUrl = "https://devacfr.github.io/reflow-maven-skin/skin/"; |
69 |
|
|
70 |
1 |
final String currentFileDir = URITool.toURI(projectUrl).resolve(currentFilename).resolve(".").toString(); |
71 |
1 |
final String actual = URITool.relativizeLink(currentFileDir, absoluteResourceURL); |
72 |
1 |
assertEquals("../..", actual); |
73 |
|
} |
74 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
75 |
1 |
@Test... |
76 |
|
public void shouldNormalisedBaseUrlAcceptNullParameter() { |
77 |
1 |
assertNull(URITool.normalisedBaseUrl(null)); |
78 |
|
} |
79 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0,14 |
1PASS
|
|
80 |
1 |
@Test... |
81 |
|
public void rebaseUrlNonInterpolate() { |
82 |
1 |
assertThrows(IllegalArgumentException.class, () -> { |
83 |
1 |
final String childBaseUrl = "https://devacfr.github.io/reflow-maven-skin/"; |
84 |
1 |
final String relativePath = "."; |
85 |
1 |
final URI parent = URI.create(childBaseUrl); |
86 |
1 |
final String parentBaseUrl = parent.resolve(relativePath).normalize().toString(); |
87 |
1 |
final URLRebaser rebaser = URITool.createURLRebaser(parentBaseUrl, childBaseUrl); |
88 |
1 |
rebaser.rebaseLink("${project.path}/reflow.png"); |
89 |
|
}); |
90 |
|
} |
91 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
1PASS
|
|
92 |
1 |
@Test... |
93 |
|
public void rebaseUrlOnRootProject() { |
94 |
1 |
final String childBaseUrl = "https://devacfr.github.io/reflow-maven-skin/"; |
95 |
1 |
final String relativePath = "."; |
96 |
1 |
final URI parent = URI.create(childBaseUrl); |
97 |
1 |
final String parentBaseUrl = parent.resolve(relativePath).normalize().toString(); |
98 |
1 |
final URLRebaser rebaser = URITool.createURLRebaser(parentBaseUrl, childBaseUrl); |
99 |
1 |
assertEquals("images/reflow.png", rebaser.rebaseLink("images/reflow.png")); |
100 |
|
} |
101 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
1PASS
|
|
102 |
1 |
@Test... |
103 |
|
public void rebaseUrlOnChildProject() { |
104 |
1 |
final String childBaseUrl = "https://devacfr.github.io/reflow-maven-skin/skin/"; |
105 |
1 |
final String relativePath = ".."; |
106 |
1 |
final URI parent = URI.create(childBaseUrl); |
107 |
1 |
final String parentBaseUrl = parent.resolve(relativePath).normalize().toString(); |
108 |
1 |
final URLRebaser rebaser = new URLRebaser(parentBaseUrl, childBaseUrl); |
109 |
1 |
assertEquals("../images/reflow.png", rebaser.rebaseLink("images/reflow.png")); |
110 |
|
} |
111 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
1PASS
|
|
112 |
1 |
@Test... |
113 |
|
public void rebaseUrlWithParentNullValue() { |
114 |
1 |
final String childBaseUrl = null; |
115 |
1 |
final String parentBaseUrl = null; |
116 |
|
|
117 |
1 |
final URLRebaser rebaser = new URLRebaser(parentBaseUrl, childBaseUrl); |
118 |
1 |
assertEquals("images/reflow.png", rebaser.rebaseLink("images/reflow.png")); |
119 |
|
} |
120 |
|
} |