Skip to content

Commit

Permalink
Add Azure Service Bus Emulator container to Azure module
Browse files Browse the repository at this point in the history
- Rename container

Signed-off-by: Esta Nagy <[email protected]>
  • Loading branch information
nagyesta committed Jan 24, 2025
1 parent 49beb0d commit 38b685d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 deletions.
12 changes: 6 additions & 6 deletions docs/modules/azure.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Currently, the module supports `Azurite`, `Azure Service Bus` and `CosmosDB` emu
Class | Container Image
-|-
AzuriteContainer | [mcr.microsoft.com/azure-storage/azurite](https://github.com/microsoft/containerregistry)
AzureServiceBusEmulatorContainer | [mcr.microsoft.com/azure-messaging/servicebus-emulator](https://github.com/microsoft/containerregistry)
AzureServiceBusContainer | [mcr.microsoft.com/azure-messaging/servicebus-emulator](https://github.com/microsoft/containerregistry)
CosmosDBEmulatorContainer | [mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator](https://github.com/microsoft/containerregistry)

## Usage example
Expand Down Expand Up @@ -82,27 +82,27 @@ Build Azure Table client:
Start Azure Service Bus Emulator during a test:

<!--codeinclude-->
[Setting up a network](../../modules/azure/src/test/java/org/testcontainers/azure/AzureServiceBusEmulatorContainerTest.java) inside_block:network
[Setting up a network](../../modules/azure/src/test/java/org/testcontainers/azure/AzureServiceBusContainerTest.java) inside_block:network
<!--/codeinclude-->

<!--codeinclude-->
[Starting a SQL Server container as dependency](../../modules/azure/src/test/java/org/testcontainers/azure/AzureServiceBusEmulatorContainerTest.java) inside_block:sqlContainer
[Starting a SQL Server container as dependency](../../modules/azure/src/test/java/org/testcontainers/azure/AzureServiceBusContainerTest.java) inside_block:sqlContainer
<!--/codeinclude-->

<!--codeinclude-->
[Starting a Service Bus Emulator container](../../modules/azure/src/test/java/org/testcontainers/azure/AzureServiceBusEmulatorContainerTest.java) inside_block:emulatorContainer
[Starting a Service Bus Emulator container](../../modules/azure/src/test/java/org/testcontainers/azure/AzureServiceBusContainerTest.java) inside_block:emulatorContainer
<!--/codeinclude-->

#### Using Azure Service Bus clients

Configure the sender and the processor clients:

<!--codeinclude-->
[Configuring the sender client](../../modules/azure/src/test/java/org/testcontainers/azure/AzureServiceBusEmulatorContainerTest.java) inside_block:senderClient
[Configuring the sender client](../../modules/azure/src/test/java/org/testcontainers/azure/AzureServiceBusContainerTest.java) inside_block:senderClient
<!--/codeinclude-->

<!--codeinclude-->
[Configuring the processor client](../../modules/azure/src/test/java/org/testcontainers/azure/AzureServiceBusEmulatorContainerTest.java) inside_block:processorClient
[Configuring the processor client](../../modules/azure/src/test/java/org/testcontainers/azure/AzureServiceBusContainerTest.java) inside_block:processorClient
<!--/codeinclude-->

### CosmosDB
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,30 @@
* <p>
* Exposed port: 5672
*/
public class AzureServiceBusEmulatorContainer extends GenericContainer<AzureServiceBusEmulatorContainer> {
public class AzureServiceBusContainer extends GenericContainer<AzureServiceBusContainer> {

private static final String CONNECTION_STRING_FORMAT =
"Endpoint=sb://%s:%d;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=SAS_KEY_VALUE;UseDevelopmentEmulator=true;";
"Endpoint=sb://%s:%d;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=SAS_KEY_VALUE;UseDevelopmentEmulator=true;";

private static final int DEFAULT_PORT = 5672;

private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse(
"mcr.microsoft.com/azure-messaging/servicebus-emulator"
"mcr.microsoft.com/azure-messaging/servicebus-emulator"
);

private MSSQLServerContainer<?> msSqlServerContainer;

/**
* @param dockerImageName The specified docker image name to run
*/
public AzureServiceBusEmulatorContainer(final String dockerImageName) {
public AzureServiceBusContainer(final String dockerImageName) {
this(DockerImageName.parse(dockerImageName));
}

/**
* @param dockerImageName The specified docker image name to run
*/
public AzureServiceBusEmulatorContainer(final DockerImageName dockerImageName) {
public AzureServiceBusContainer(final DockerImageName dockerImageName) {
super(dockerImageName);
dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME);
withExposedPorts(DEFAULT_PORT);
Expand All @@ -50,9 +50,7 @@ public AzureServiceBusEmulatorContainer(final DockerImageName dockerImageName) {
* @param msSqlServerContainer The MS SQL Server container used by Service Bus as a dependency
* @return this
*/
public AzureServiceBusEmulatorContainer withMsSqlServerContainer(
final MSSQLServerContainer<?> msSqlServerContainer
) {
public AzureServiceBusContainer withMsSqlServerContainer(final MSSQLServerContainer<?> msSqlServerContainer) {
dependsOn(msSqlServerContainer);
this.msSqlServerContainer = msSqlServerContainer;
return this;
Expand All @@ -64,7 +62,7 @@ public AzureServiceBusEmulatorContainer withMsSqlServerContainer(
* @param config The configuration
* @return this
*/
public AzureServiceBusEmulatorContainer withConfig(final Transferable config) {
public AzureServiceBusContainer withConfig(final Transferable config) {
withCopyToContainer(config, "/ServiceBus_Emulator/ConfigFiles/Config.json");
return this;
}
Expand All @@ -74,17 +72,17 @@ public AzureServiceBusEmulatorContainer withConfig(final Transferable config) {
*
* @return this
*/
public AzureServiceBusEmulatorContainer acceptLicense() {
public AzureServiceBusContainer acceptLicense() {
return withEnv("ACCEPT_EULA", "Y");
}

@Override
protected void configure() {
if (msSqlServerContainer == null) {
throw new IllegalStateException(
"The image " +
getDockerImageName() +
" requires a Microsoft SQL Server container. Please provide one with the withMsSqlServerContainer method!"
"The image " +
getDockerImageName() +
" requires a Microsoft SQL Server container. Please provide one with the withMsSqlServerContainer method!"
);
}
withEnv("SQL_SERVER", msSqlServerContainer.getNetworkAliases().get(0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;

public class AzureServiceBusEmulatorContainerTest {
public class AzureServiceBusContainerTest {

@Rule
// network {
Expand All @@ -45,7 +45,7 @@ public class AzureServiceBusEmulatorContainerTest {

@Rule
// emulatorContainer {
public AzureServiceBusEmulatorContainer emulator = new AzureServiceBusEmulatorContainer(
public AzureServiceBusContainer emulator = new AzureServiceBusContainer(
"mcr.microsoft.com/azure-messaging/servicebus-emulator:1.0.1"
)
.acceptLicense()
Expand Down

0 comments on commit 38b685d

Please sign in to comment.