1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.qedeq.base.io; |
17 |
|
|
18 |
|
import java.io.File; |
19 |
|
import java.net.URI; |
20 |
|
import java.net.URL; |
21 |
|
|
22 |
|
import org.qedeq.base.test.QedeqTestCase; |
23 |
|
import org.qedeq.base.test.WebServer; |
24 |
|
|
25 |
|
|
26 |
|
@link |
27 |
|
|
28 |
|
@author |
29 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (23) |
Complexity: 5 |
Complexity Density: 0.28 |
|
30 |
|
public class UrlUtilityTest extends QedeqTestCase { |
31 |
|
|
32 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1
PASS
|
|
33 |
1
|
public void testToUrl() throws Exception {... |
34 |
1
|
final URL url = UrlUtility.toUrl(new File(".")); |
35 |
1
|
final URI uri = new URI(url.toString()); |
36 |
1
|
assertEquals(new File(".").getCanonicalPath(), |
37 |
|
new File(uri).getCanonicalPath()); |
38 |
|
} |
39 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1
PASS
|
|
40 |
1
|
public void testToFile() throws Exception {... |
41 |
1
|
final File start = new File("empty path"); |
42 |
1
|
assertEquals(UrlUtility.transformURLPathToFilePath(UrlUtility.toUrl(start)).getCanonicalPath(), |
43 |
|
start.getCanonicalPath()); |
44 |
|
} |
45 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1
PASS
|
|
46 |
1
|
public void testEasyUrl() throws Exception {... |
47 |
1
|
final String url1 = "http://www.qedeq.org/sample.html#poke"; |
48 |
1
|
assertEquals(url1, UrlUtility.easyUrl(url1)); |
49 |
1
|
final String file = "/user/home/qedeq/sample1.qedeq"; |
50 |
1
|
assertEquals(new File(file.replace('/', File.separatorChar)).getCanonicalPath(), |
51 |
|
UrlUtility.easyUrl("file://" + file)); |
52 |
|
} |
53 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1
PASS
|
|
54 |
1
|
public void testSaveUrlToFile() throws Exception {... |
55 |
1
|
final File original = new File(getOutdir(), "testSaveUrlToFile1.txt"); |
56 |
1
|
IoUtility.saveFile(original, "we don't need another hero"); |
57 |
1
|
final File save = new File(getOutdir(), "testSaveUrlToFile2.txt"); |
58 |
1
|
final WebServer server = new WebServer(8082, getOutdir(), 5000, true); |
59 |
1
|
server.start(); |
60 |
1
|
UrlUtility.saveUrlToFile("http://localhost:8082/" + original.getName(), save, null, null, null, 0, 0, |
61 |
|
new LoadingListener() { |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
62 |
2
|
public void loadingCompletenessChanged(double completeness) {... |
63 |
2
|
System.out.println(completeness); |
64 |
|
} |
65 |
|
} |
66 |
|
); |
67 |
1
|
assertTrue(IoUtility.compareFilesBinary(original, save)); |
68 |
1
|
server.stop(); |
69 |
|
} |
70 |
|
|
71 |
|
} |