Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
* This file is part of vospace-datamodel
* Copyright (C) 2021 Istituto Nazionale di Astrofisica
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package it.inaf.oats.vospace;
import it.inaf.oats.vospace.exception.InvalidURIException;
import java.util.ArrayList;
import java.util.List;
import net.ivoa.xml.vospace.v2.DataNode;
import net.ivoa.xml.vospace.v2.LinkNode;
import net.ivoa.xml.vospace.v2.Node;
import net.ivoa.xml.vospace.v2.Property;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
public class URIUtilsTest {
private final String authority = "example.com!vospace";
@Test
public void testReturnVosPathFromNodeURI() {
String test1 = "vos://example.com!wrong/";
assertThrows(InvalidURIException.class, () -> {
URIUtils.returnVosPathFromNodeURI(test1, authority);
});
String test2 = "wrong://example.com!wrong/";
assertThrows(InvalidURIException.class, () -> {
URIUtils.returnVosPathFromNodeURI(test2, authority);
});
String test3 = "vos://example.com!vospace";
assertThrows(InvalidURIException.class, () -> {
URIUtils.returnVosPathFromNodeURI(test3, authority);
});
String test4 = "vos://example.com!vospace/n1/n2/n3/n%2F4";
assertThrows(InvalidURIException.class, () -> {
URIUtils.returnVosPathFromNodeURI(test4, authority);
});
String test5 = "vos://example.com!vospace/n1/n2/n3//n4";
assertThrows(InvalidURIException.class, () -> {
URIUtils.returnVosPathFromNodeURI(test5, authority);
});
String test6 = "vos://example.com!vospace/n1/n2/n3/n4/";
assertThrows(InvalidURIException.class, () -> {
URIUtils.returnVosPathFromNodeURI(test6, authority);
});
String test7 = "vos://example.com!vospace/n1/n2/n*3/n4/";
assertThrows(InvalidURIException.class, () -> {
URIUtils.returnVosPathFromNodeURI(test7, authority);
});
String test8 = "vos://example.com!vospace/n1/n2/n3/n4";
assertEquals("/n1/n2/n3/n4",
URIUtils.returnVosPathFromNodeURI(test8, authority));
}
}