Skip to content

Commit

Permalink
Use username and password from env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
eddumelendez committed Apr 19, 2023
1 parent 9068f0b commit ef69650
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static class PropertiesActiveMQConnectionDetails implements ActiveMQConnectionDe

private final ActiveMQProperties properties;

public PropertiesActiveMQConnectionDetails(ActiveMQProperties properties) {
PropertiesActiveMQConnectionDetails(ActiveMQProperties properties) {
this.properties = properties;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,8 @@ public interface ActiveMQConnectionDetails extends ConnectionDetails {

String getBrokerUrl();

default String getUser() {
return null;
}
String getUser();

default String getPassword() {
return null;
}
String getPassword();

}
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ The following service connection factories are provided in the `spring-boot-test
| Connection Details | Matched on

| `ActiveMQConnectionDetails`
| Containers named "activemq"
| Containers named "symptoma/activemq"

| `CassandraConnectionDetails`
| Containers of type `CassandraContainer`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package org.springframework.boot.testcontainers.service.connection.activemq;

import java.util.Map;

import org.testcontainers.containers.Container;
import org.testcontainers.containers.GenericContainer;

Expand All @@ -35,7 +37,7 @@ class ActiveMQContainerConnectionDetailsFactory
extends ContainerConnectionDetailsFactory<ActiveMQConnectionDetails, Container<?>> {

ActiveMQContainerConnectionDetailsFactory() {
super("activemq");
super("symptoma/activemq");
}

@Override
Expand All @@ -48,17 +50,30 @@ private static final class ActiveMQContainerConnectionDetails extends ContainerC

private final String brokerUrl;

private final Map<String, String> envVars;

private ActiveMQContainerConnectionDetails(ContainerConnectionSource<Container<?>> source) {
super(source);
this.brokerUrl = "tcp://" + source.getContainer().getHost() + ":"
+ source.getContainer().getFirstMappedPort();
this.envVars = source.getContainer().getEnvMap();
}

@Override
public String getBrokerUrl() {
return this.brokerUrl;
}

@Override
public String getUser() {
return this.envVars.get("ACTIVEMQ_USERNAME");
}

@Override
public String getPassword() {
return this.envVars.get("ACTIVEMQ_PASSWORD");
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
class ActiveMQContainerConnectionDetailsFactoryIntegrationTests {

@Container
@ServiceConnection("activemq")
@ServiceConnection
static final ActiveMQContainer activemq = new ActiveMQContainer();

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
class SampleActiveMqTests {

@Container
@ServiceConnection("activemq")
@ServiceConnection
private static final ActiveMQContainer container = new ActiveMQContainer();

@Autowired
Expand Down

0 comments on commit ef69650

Please sign in to comment.