|
28 | 28 | import org.junit.jupiter.api.Test; |
29 | 29 |
|
30 | 30 | import java.io.ByteArrayInputStream; |
| 31 | +import java.io.IOException; |
| 32 | +import java.io.InputStream; |
31 | 33 | import java.util.Arrays; |
32 | 34 | import java.util.HashSet; |
33 | 35 | import java.util.List; |
@@ -113,6 +115,44 @@ public void testGetFileInfo() |
113 | 115 | assertNotEquals( -1, response.jsonPath().getLong( "fileLength" ) ); |
114 | 116 | } |
115 | 117 |
|
| 118 | + @Test |
| 119 | + public void testGetPathsByChecksum() throws Exception |
| 120 | + { |
| 121 | + // filesystem must match the 'deduplicatePattern' |
| 122 | + final String g_filesystem = "generic-http:remote:g_filesystem"; |
| 123 | + final String checksum = "209094962790ca300e4e387f4b3dd130ff06ef9a9c3e08c2f96889334db4cf4c"; |
| 124 | + |
| 125 | + // upload the file to g_filesystem |
| 126 | + try (InputStream in = url.openStream()) |
| 127 | + { |
| 128 | + prepareFile( in, g_filesystem, PATH ); |
| 129 | + } |
| 130 | + |
| 131 | + // test with right checksum |
| 132 | + Response response = given().pathParam( "checksum", checksum ) |
| 133 | + .when() |
| 134 | + .get( API_BASE + "/checksum/{checksum}" ) |
| 135 | + .then() |
| 136 | + .extract() |
| 137 | + .response(); |
| 138 | + |
| 139 | + assertEquals( 200, response.statusCode() ); |
| 140 | + //System.out.println(">>>" + response.jsonPath().getList( "" )); |
| 141 | + assertTrue( response.jsonPath().getList( "" ).contains( g_filesystem + ":/" + PATH ) ); |
| 142 | + |
| 143 | + // test with wrong checksum |
| 144 | + response = given().pathParam( "checksum", "wrong-094962790ca30" ) |
| 145 | + .when() |
| 146 | + .get( API_BASE + "/checksum/{checksum}" ) |
| 147 | + .then() |
| 148 | + .extract() |
| 149 | + .response(); |
| 150 | + |
| 151 | + assertEquals( 200, response.statusCode() ); |
| 152 | + //System.out.println(">>>" + response.getBody().asString() ); |
| 153 | + assertTrue( response.jsonPath().getList( "" ).isEmpty() ); |
| 154 | + } |
| 155 | + |
116 | 156 | @Test |
117 | 157 | public void testList() |
118 | 158 | { |
|
0 commit comments