Skip to content
Permalink
Browse files
Fix potential Azure Blob test failures when testing against the real …
…service

Fixes #3655
  • Loading branch information
jamesnetherton committed Mar 30, 2022
1 parent 4875c67 commit 152f91743b6c5a9e50bb2181885915ffb598b79d
Showing 2 changed files with 15 additions and 12 deletions.
@@ -348,8 +348,10 @@ public JsonObject listBlobContainers() throws Exception {

List<BlobContainerItem> containers = producerTemplate.requestBody("direct:listBlobContainers", null, List.class);
containers.stream()
.map(container -> Json.createObjectBuilder()
.add("name", container.getName())
.map(BlobContainerItem::getName)
.filter(containerName -> containerName.startsWith("camel-quarkus"))
.map(containerName -> Json.createObjectBuilder()
.add("name", containerName)
.build())
.forEach(arrayBuilder::add);

@@ -43,6 +43,7 @@
import org.junit.jupiter.api.Test;
import org.testcontainers.shaded.org.awaitility.Awaitility;

import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.StringEndsWith.endsWith;
@@ -121,7 +122,7 @@ public void crud() {
// Delete
RestAssured.delete("/azure-storage-blob/blob/delete")
.then()
.statusCode(204);
.statusCode(anyOf(is(204), is(404)));
}
}

@@ -166,7 +167,7 @@ public void download() throws IOException {
// Delete
RestAssured.delete("/azure-storage-blob/blob/delete")
.then()
.statusCode(204);
.statusCode(anyOf(is(204), is(404)));
}
}

@@ -224,7 +225,7 @@ public void blockBlobStageCommit() {
// Delete
RestAssured.delete("/azure-storage-blob/blob/delete")
.then()
.statusCode(204);
.statusCode(anyOf(is(204), is(404)));
}
}

@@ -258,7 +259,7 @@ public void appendBlob() {
// Delete
RestAssured.delete("/azure-storage-blob/blob/delete")
.then()
.statusCode(204);
.statusCode(anyOf(is(204), is(404)));
}
}

@@ -352,13 +353,13 @@ public void pageBlob() {
// Delete
RestAssured.delete("/azure-storage-blob/blob/delete")
.then()
.statusCode(204);
.statusCode(anyOf(is(204), is(404)));
}
}

@Test
public void blobContainer() {
String alternativeContainerName = "cq-test-" + UUID.randomUUID();
String alternativeContainerName = "camel-quarkus-" + UUID.randomUUID();

try {
// Create
@@ -381,13 +382,13 @@ public void blobContainer() {
.queryParam("containerName", alternativeContainerName)
.delete("/azure-storage-blob/blob/container")
.then()
.statusCode(204);
.statusCode(anyOf(is(204), is(404)));
}
}

@Test
public void copyBlob() {
String alternativeContainerName = "cq-test-" + UUID.randomUUID();
String alternativeContainerName = "camel-quarkus-" + UUID.randomUUID();

try {
// Create container to copy to
@@ -443,7 +444,7 @@ public void copyBlob() {

RestAssured.delete("/azure-storage-blob/blob/delete")
.then()
.statusCode(204);
.statusCode(anyOf(is(204), is(404)));
}
}

@@ -512,7 +513,7 @@ public void changeFeed() {
} finally {
RestAssured.delete("/azure-storage-blob/blob/delete")
.then()
.statusCode(204);
.statusCode(anyOf(is(204), is(404)));
}
}
}

0 comments on commit 152f917

Please sign in to comment.