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
83
84
85
86
87
88
89
90
91
92
93
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package it.inaf.oats.vospace.datamodel;
import java.util.ArrayList;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
public class NodeUtilsTest {
//@Test
public void getPathFromRequestURLStringTest() {
String urlForTest = "http://server.example.com/vospace/";
String result = NodeUtils.getPathFromRequestURLString(urlForTest);
assertEquals("/", result);
urlForTest = "http://server.example.com/vospace/nodes";
result = NodeUtils.getPathFromRequestURLString(urlForTest);
assertEquals("/", result);
urlForTest = "http://server.example.com/vospace/nodes/mydata";
result = NodeUtils.getPathFromRequestURLString(urlForTest);
assertEquals("/mydata", result);
urlForTest = "http://server.example.com/vospace/nodes/mydata1/uffi/nonso/pappa.txt";
result = NodeUtils.getPathFromRequestURLString(urlForTest);
assertEquals("/mydata1/uffi/nonso/pappa.txt", result);
}
/* Is it a possible case?
@Test
public void subPathComponentsTest1() {
//assertArrayEquals(expected, actual)
String pathForTest = "";
List result = NodeUtils.subPathComponents(pathForTest);
List expected = new ArrayList(); // expected empty
assertArrayEquals(expected.toArray(), result.toArray());
}
*/
@Test
public void subPathComponentsTest2() {
String pathForTest = "/";
List result = NodeUtils.subPathComponents(pathForTest);
List expected = new ArrayList();
expected.add("/");
assertArrayEquals(expected.toArray(), result.toArray());
}
@Test
public void subPathComponentsTest3() {
String pathForTest = "/mynode1";
List result = NodeUtils.subPathComponents(pathForTest);
List expected = new ArrayList();
expected.add("/mynode1");
assertArrayEquals(expected.toArray(), result.toArray());
}
@Test
public void subPathComponentsTest4() {
//assertArrayEquals(expected, actual)
String pathForTest = "/mydata1/uffi/nonso/pappa.txt";
List result = NodeUtils.subPathComponents(pathForTest);
List expected = new ArrayList();
expected.add("/mydata1");
expected.add("/mydata1/uffi");
expected.add("/mydata1/uffi/nonso");
expected.add("/mydata1/uffi/nonso/pappa.txt");
assertArrayEquals(expected.toArray(), result.toArray());
}
}