Skip to content
Snippets Groups Projects
Commit 1df198b4 authored by Andreas Romeyke's avatar Andreas Romeyke
Browse files

- added null-checks in parameter getters

- fixed throughput(), return result
- added contractAssert...()
- increased debugging output
- fixed wrong retrieveEntity() call, uses relative paths
- added relativePath()
-
parent e0fda67e
No related branches found
No related tags found
No related merge requests found
Pipeline #3401 passed
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
</fr:x_form> </fr:x_form>
</pl:initParameters> </pl:initParameters>
<pl:description>SLUB Storage Plugin</pl:description> <pl:description>SLUB Storage Plugin</pl:description>
<pl:version>2.822</pl:version> <pl:version>2.836</pl:version>
<pl:materialType>DIGITAL</pl:materialType> <pl:materialType>DIGITAL</pl:materialType>
<pl:module>Repository</pl:module> <pl:module>Repository</pl:module>
<pl:generalType>TASK</pl:generalType> <pl:generalType>TASK</pl:generalType>
......
...@@ -22,6 +22,7 @@ import java.util.ArrayList; ...@@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import static java.nio.file.Path.of;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
...@@ -38,7 +39,7 @@ public class TestSLUBStoragePlugin { ...@@ -38,7 +39,7 @@ public class TestSLUBStoragePlugin {
@Before @Before
public void setUp() throws IOException { public void setUp() throws IOException {
testroot = Files.createTempDirectory("testslubstorage"); testroot = Files.createTempDirectory("testslubstorage");
Files.createFile(Path.of(testroot.toAbsolutePath().toString() + "/foo")); Files.createFile(of(testroot.toAbsolutePath().toString() + "/foo"));
mock = new SLUBStoragePlugin(); mock = new SLUBStoragePlugin();
HashMap<String, String> map = new HashMap<String,String> (); HashMap<String, String> map = new HashMap<String,String> ();
map.put("DIR_ROOT", testroot.toAbsolutePath().toString()); map.put("DIR_ROOT", testroot.toAbsolutePath().toString());
...@@ -66,10 +67,15 @@ public class TestSLUBStoragePlugin { ...@@ -66,10 +67,15 @@ public class TestSLUBStoragePlugin {
assertTrue("checkFixity", result); assertTrue("checkFixity", result);
} }
catch (Exception e) { catch (Exception e) {
assertEquals("checkFixity", "foo", e); assertEquals("checkFixity", "foo", e.getMessage());
} }
} }
@Test
public void relativePath() {
String absolute = testroot.toAbsolutePath().toString()+"/2022";
assertEquals("relativePath", "/2022", mock.relativePath(absolute));
}
@Test @Test
public void getFullFilePath() { public void getFullFilePath() {
assertEquals( "getFullFilePath", testroot.toAbsolutePath().toString()+"/2022", mock.getFullFilePath("/2022")); assertEquals( "getFullFilePath", testroot.toAbsolutePath().toString()+"/2022", mock.getFullFilePath("/2022"));
...@@ -80,7 +86,18 @@ public class TestSLUBStoragePlugin { ...@@ -80,7 +86,18 @@ public class TestSLUBStoragePlugin {
InputStream is = mock.retrieveEntity("/foo"); InputStream is = mock.retrieveEntity("/foo");
assertTrue("retrieveEntity", true); assertTrue("retrieveEntity", true);
} catch (Exception e) { } catch (Exception e) {
assertEquals("retrieveEntity", "", e); assertEquals("retrieveEntity", "", e.getMessage());
}
}
@Test
public void retrieveEntity_dirroot() {
try {
InputStream is = mock.retrieveEntity(testroot.toAbsolutePath().toString() + "/foo");
assertTrue("retrieveEntity", true);
} catch (IllegalArgumentException e) {
assertEquals("retrieveEntity", "", e.getMessage());
} catch (IOException e) {
assertTrue("retrieveEntity", e.getMessage().contains("should be relative, but starts with ROOT"));
} }
} }
@Test @Test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment