Skip to content

Commit

Permalink
Fix unstable test
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes Schüth committed Dec 21, 2017
1 parent a508243 commit 077133f
Showing 1 changed file with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ public void testUploadMultipleToBinaryNode() throws IOException {
String value = container.getBinary("binary") == null ? null : container.getBinary("binary").getFileName();
assertEquals("Version {" + container.getVersion() + "} did not contain the old value", oldFilename, value);
assertNotNull("Version {" + newContainer.getVersion() + "} did not contain the updated field.", newContainer.getBinary("binary"));
assertEquals("Version {" + newContainer.getVersion() + "} did not contain the updated value.", newFileName,
newContainer.getBinary("binary").getFileName());
assertEquals("Version {" + newContainer.getVersion() + "} did not contain the updated value.", newFileName, newContainer.getBinary(
"binary").getFileName());
container = newContainer;
}
}
Expand Down Expand Up @@ -277,6 +277,7 @@ public void testUpload() throws Exception {

NodeResponse response = call(() -> uploadRandomData(node, "en", "binary", binaryLen, contentType, fileName));
assertTrue("The upload should have created the tmp folder", uploadFolder.exists());
Thread.sleep(1000);
assertThat(uploadFolder.list()).as("Folder should not contain any remaining tmp upload file").isEmpty();

response = call(() -> client().findNodeByUuid(PROJECT_NAME, uuid, new VersioningParametersImpl().draft()));
Expand Down Expand Up @@ -343,8 +344,8 @@ public void testDeleteBinaryNode() throws IOException {

call(() -> client().deleteNode(PROJECT_NAME, uuid, new DeleteParametersImpl().setRecursive(true)));
try (Tx tx = tx()) {
assertNull("The binary for the hash should have also been removed since only one node used the binary.",
meshRoot().getBinaryRoot().findByHash(hash));
assertNull("The binary for the hash should have also been removed since only one node used the binary.", meshRoot().getBinaryRoot()
.findByHash(hash));
}
assertFalse("The binary file should have been removed.", binaryFile.exists());

Expand Down Expand Up @@ -411,17 +412,17 @@ public void testDeleteBinaryNodeDeuplication() throws IOException {
// Now delete nodeA
call(() -> client().deleteNode(PROJECT_NAME, uuidA, new DeleteParametersImpl().setRecursive(true)));
try (Tx tx = tx()) {
assertNotNull("The binary for the hash should not have been removed since it is still in use.",
meshRoot().getBinaryRoot().findByHash(hashA));
assertNotNull("The binary for the hash should not have been removed since it is still in use.", meshRoot().getBinaryRoot().findByHash(
hashA));
}
assertTrue("The binary file should not have been deleted since there is still one node which uses it.", binaryFileA.exists());

// Now delete nodeB
call(() -> client().deleteNode(PROJECT_NAME, uuidB, new DeleteParametersImpl().setRecursive(true)));

try (Tx tx = tx()) {
assertNull("The binary for the hash should have also been removed since only one node used the binary.",
meshRoot().getBinaryRoot().findByHash(hashA));
assertNull("The binary for the hash should have also been removed since only one node used the binary.", meshRoot().getBinaryRoot()
.findByHash(hashA));
}
assertFalse("The binary file should have been removed.", binaryFileA.exists());

Expand Down Expand Up @@ -452,8 +453,8 @@ public void testUploadWithSegmentfieldConflict() throws IOException {
call(() -> uploadRandomData(folder2014, "en", "binary", binaryLen, contentType, fileName));
}

call(() -> client().findNodeByUuid(PROJECT_NAME, db().tx(() -> folder("2014").getUuid()),
new NodeParametersImpl().setResolveLinks(LinkType.FULL)));
call(() -> client().findNodeByUuid(PROJECT_NAME, db().tx(() -> folder("2014").getUuid()), new NodeParametersImpl().setResolveLinks(
LinkType.FULL)));

try (Tx tx = tx()) {
// try to upload same file to folder 2015
Expand Down Expand Up @@ -508,8 +509,8 @@ private int uploadImage(Node node, String languageTag, String fieldname, String
Buffer buffer = Buffer.buffer(bytes);
String uuid = node.getUuid();
VersionNumber version = node.getGraphFieldContainer(languageTag).getVersion();
NodeResponse response = call(
() -> client().updateNodeBinaryField(PROJECT_NAME, uuid, languageTag, version.toString(), fieldname, buffer, filename, contentType));
NodeResponse response = call(() -> client().updateNodeBinaryField(PROJECT_NAME, uuid, languageTag, version.toString(), fieldname, buffer,
filename, contentType));
assertNotNull(response);
return bytes.length;

Expand Down

0 comments on commit 077133f

Please sign in to comment.