-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix AMQP SSLContext tests trying to start broker twice after junit 5.…
…11 upgrade
- Loading branch information
1 parent
c3ae8a6
commit efd103c
Showing
4 changed files
with
103 additions
and
95 deletions.
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
...ve-messaging-amqp/src/test/java/io/smallrye/reactive/messaging/amqp/AmqpBrokerHolder.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,74 @@ | ||
package io.smallrye.reactive.messaging.amqp; | ||
|
||
import jakarta.enterprise.inject.se.SeContainer; | ||
|
||
import org.eclipse.microprofile.config.ConfigProvider; | ||
|
||
import io.smallrye.config.SmallRyeConfigProviderResolver; | ||
import io.smallrye.reactive.messaging.providers.connectors.ExecutionHolder; | ||
import io.smallrye.reactive.messaging.providers.extension.HealthCenter; | ||
import io.smallrye.reactive.messaging.test.common.config.MapBasedConfig; | ||
import io.vertx.mutiny.core.Vertx; | ||
|
||
public class AmqpBrokerHolder { | ||
|
||
public static final AmqpBroker broker = new AmqpBroker(); | ||
|
||
protected ExecutionHolder executionHolder; | ||
protected final static String host = "127.0.0.1"; | ||
protected final static int port = 5672; | ||
protected final static String username = "artemis"; | ||
protected final static String password = "artemis"; | ||
|
||
protected AmqpUsage usage; | ||
|
||
public static void startBroker(String brokerXmlUrl) { | ||
if (brokerXmlUrl != null) { | ||
broker.setConfigResourcePath(brokerXmlUrl); | ||
} | ||
broker.start(port); | ||
System.setProperty("amqp-host", host); | ||
System.setProperty("amqp-port", Integer.toString(port)); | ||
System.setProperty("amqp-user", username); | ||
System.setProperty("amqp-pwd", password); | ||
} | ||
|
||
public static void stopBroker() { | ||
broker.stop(); | ||
System.clearProperty("amqp-host"); | ||
System.clearProperty("amqp-port"); | ||
} | ||
|
||
public void setup() { | ||
executionHolder = new ExecutionHolder(Vertx.vertx()); | ||
usage = new AmqpUsage(executionHolder.vertx(), host, port, username, password); | ||
SmallRyeConfigProviderResolver.instance().releaseConfig(ConfigProvider.getConfig()); | ||
MapBasedConfig.cleanup(); | ||
} | ||
|
||
public void tearDown() { | ||
usage.close(); | ||
executionHolder.terminate(null); | ||
SmallRyeConfigProviderResolver.instance().releaseConfig(ConfigProvider.getConfig()); | ||
MapBasedConfig.cleanup(); | ||
} | ||
|
||
public boolean isAmqpConnectorReady(SeContainer container) { | ||
HealthCenter health = container.getBeanManager().createInstance().select(HealthCenter.class).get(); | ||
return health.getReadiness().isOk(); | ||
} | ||
|
||
public boolean isAmqpConnectorReady(AmqpConnector connector) { | ||
return connector.getReadiness().isOk(); | ||
} | ||
|
||
public boolean isAmqpConnectorAlive(SeContainer container) { | ||
HealthCenter health = container.getBeanManager().createInstance().select(HealthCenter.class).get(); | ||
return health.getLiveness().isOk(); | ||
} | ||
|
||
public boolean isAmqpConnectorAlive(AmqpConnector connector) { | ||
return connector.getLiveness().isOk(); | ||
} | ||
|
||
} |
65 changes: 5 additions & 60 deletions
65
...-messaging-amqp/src/test/java/io/smallrye/reactive/messaging/amqp/AmqpBrokerTestBase.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 |
---|---|---|
@@ -1,85 +1,30 @@ | ||
package io.smallrye.reactive.messaging.amqp; | ||
|
||
import jakarta.enterprise.inject.se.SeContainer; | ||
|
||
import org.eclipse.microprofile.config.ConfigProvider; | ||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.BeforeEach; | ||
|
||
import io.smallrye.config.SmallRyeConfigProviderResolver; | ||
import io.smallrye.reactive.messaging.providers.connectors.ExecutionHolder; | ||
import io.smallrye.reactive.messaging.providers.extension.HealthCenter; | ||
import io.smallrye.reactive.messaging.test.common.config.MapBasedConfig; | ||
import io.vertx.mutiny.core.Vertx; | ||
|
||
public class AmqpBrokerTestBase { | ||
|
||
public static final AmqpBroker broker = new AmqpBroker(); | ||
protected static final String BROKER_XML_LOCATION = "ampq.broker.xml.name"; | ||
|
||
protected ExecutionHolder executionHolder; | ||
protected final static String host = "127.0.0.1"; | ||
protected final static int port = 5672; | ||
protected final static String username = "artemis"; | ||
protected final static String password = "artemis"; | ||
|
||
protected AmqpUsage usage; | ||
public class AmqpBrokerTestBase extends AmqpBrokerHolder { | ||
|
||
@BeforeAll | ||
public static void startBroker() { | ||
String brokerXmlUrl = System.getProperty(BROKER_XML_LOCATION); | ||
if (brokerXmlUrl != null) { | ||
broker.setConfigResourcePath(brokerXmlUrl); | ||
} | ||
broker.start(port); | ||
System.setProperty("amqp-host", host); | ||
System.setProperty("amqp-port", Integer.toString(port)); | ||
System.setProperty("amqp-user", username); | ||
System.setProperty("amqp-pwd", password); | ||
startBroker(null); | ||
} | ||
|
||
@AfterAll | ||
public static void stopBroker() { | ||
broker.stop(); | ||
System.clearProperty("amqp-host"); | ||
System.clearProperty("amqp-port"); | ||
AmqpBrokerHolder.stopBroker(); | ||
} | ||
|
||
@BeforeEach | ||
public void setup() { | ||
executionHolder = new ExecutionHolder(Vertx.vertx()); | ||
|
||
usage = new AmqpUsage(executionHolder.vertx(), host, port, username, password); | ||
SmallRyeConfigProviderResolver.instance().releaseConfig(ConfigProvider.getConfig()); | ||
MapBasedConfig.cleanup(); | ||
super.setup(); | ||
} | ||
|
||
@AfterEach | ||
public void tearDown() { | ||
usage.close(); | ||
executionHolder.terminate(null); | ||
SmallRyeConfigProviderResolver.instance().releaseConfig(ConfigProvider.getConfig()); | ||
MapBasedConfig.cleanup(); | ||
} | ||
|
||
public boolean isAmqpConnectorReady(SeContainer container) { | ||
HealthCenter health = container.getBeanManager().createInstance().select(HealthCenter.class).get(); | ||
return health.getReadiness().isOk(); | ||
} | ||
|
||
public boolean isAmqpConnectorReady(AmqpConnector connector) { | ||
return connector.getReadiness().isOk(); | ||
} | ||
|
||
public boolean isAmqpConnectorAlive(SeContainer container) { | ||
HealthCenter health = container.getBeanManager().createInstance().select(HealthCenter.class).get(); | ||
return health.getLiveness().isOk(); | ||
} | ||
|
||
public boolean isAmqpConnectorAlive(AmqpConnector connector) { | ||
return connector.getLiveness().isOk(); | ||
super.tearDown(); | ||
} | ||
|
||
} |
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
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