-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #376 - Separate Docker container into Maven profile for Azure S… (
#377)
- Loading branch information
Showing
3 changed files
with
173 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
azure-storage/src/main/java/storage/ContainerResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package storage; | ||
|
||
import jakarta.inject.Singleton; | ||
import jakarta.ws.rs.PUT; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.PathParam; | ||
import jakarta.ws.rs.core.Response; | ||
import static jakarta.ws.rs.core.Response.Status.CREATED; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* @author Manfred Riem ([email protected]) | ||
*/ | ||
@Path("") | ||
@Singleton | ||
public class ContainerResource { | ||
|
||
/** | ||
* Stores the secrets. | ||
*/ | ||
private final List<String> containerNames = new ArrayList<>(); | ||
|
||
/** | ||
* Create the container. | ||
* | ||
* @param containerName the container name. | ||
* @return the response. | ||
*/ | ||
@Path("{containerName}?restype=container") | ||
@PUT | ||
public Response createContainer( | ||
@PathParam("containerName") String containerName) { | ||
|
||
if (!containerNames.contains(containerName)) { | ||
containerNames.add(containerName); | ||
return Response.status(CREATED).header("Connection", "close").build(); | ||
} | ||
return Response.serverError().build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package storage; | ||
|
||
import com.azure.core.credential.BasicAuthenticationCredential; | ||
import com.azure.core.credential.TokenCredential; | ||
import static com.azure.core.http.policy.HttpLogDetailLevel.BODY_AND_HEADERS; | ||
import com.azure.core.http.policy.HttpLogOptions; | ||
import com.azure.storage.blob.BlobContainerClient; | ||
import com.azure.storage.blob.BlobContainerClientBuilder; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
* The integration tests to test our simulated Azure Storage. | ||
* | ||
* @author Manfred Riem ([email protected]) | ||
*/ | ||
public class StorageIT { | ||
|
||
/** | ||
* Stores the credential. | ||
*/ | ||
private TokenCredential credential; | ||
|
||
/** | ||
* Setup the credential. | ||
*/ | ||
@BeforeEach | ||
public void setUp() { | ||
credential = new BasicAuthenticationCredential("username", "password"); | ||
} | ||
|
||
/** | ||
* Test creating blob container. | ||
*/ | ||
@Test | ||
@Disabled | ||
public void testCreateBlobContainer() { | ||
|
||
BlobContainerClient blobContainerClient = new BlobContainerClientBuilder() | ||
.endpoint("https://localhost:8203") | ||
.credential(credential) | ||
.containerName("myBlobContainer") | ||
.httpLogOptions(new HttpLogOptions().setLogLevel(BODY_AND_HEADERS)) | ||
.buildClient(); | ||
|
||
blobContainerClient.create(); | ||
assertEquals("myBlobContainer", blobContainerClient.getBlobContainerName()); | ||
} | ||
} |