Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump io.smallrye:smallrye-parent from 45 to 46 #2752

Merged
merged 2 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-parent</artifactId>
<version>45</version>
<version>46</version>
</parent>

<groupId>io.smallrye.reactive</groupId>
Expand Down
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();
}

}
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();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import static org.assertj.core.api.Assertions.assertThat;

import java.io.IOException;
import java.net.URISyntaxException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

Expand All @@ -15,31 +17,24 @@
import org.junit.jupiter.api.Test;

import io.smallrye.config.SmallRyeConfigProviderResolver;
import io.smallrye.reactive.messaging.amqp.AmqpBrokerTestBase;
import io.smallrye.reactive.messaging.amqp.AmqpBrokerHolder;
import io.smallrye.reactive.messaging.amqp.AmqpConnector;
import io.smallrye.reactive.messaging.amqp.AmqpUsage;
import io.smallrye.reactive.messaging.amqp.ProducingBean;
import io.smallrye.reactive.messaging.test.common.config.MapBasedConfig;

public class AmqpSSLSinkCDISSLContextTest extends AmqpBrokerTestBase {
public class AmqpSSLSinkCDISSLContextTest extends AmqpBrokerHolder {

private WeldContainer container;
private AmqpConnector provider;

@BeforeAll
public static void startBroker() {
try {
String brokerXml = SSLBrokerConfigUtil.createSecuredBrokerXml();
System.setProperty(BROKER_XML_LOCATION, brokerXml);
AmqpBrokerTestBase.startBroker();
} catch (Exception e) {
throw new RuntimeException(e);
}
public static void startBroker() throws IOException, URISyntaxException {
startBroker(SSLBrokerConfigUtil.createSecuredBrokerXml());
}

@AfterAll
public static void clearSslBrokerName() {
System.clearProperty(BROKER_XML_LOCATION);
public static void stopBroker() {
AmqpBrokerHolder.stopBroker();
}

@Override
Expand All @@ -51,12 +46,14 @@ public void setup() {
usage = new AmqpUsage(executionHolder.vertx(), host, port + 1, username, password);
}

@Override
@AfterEach
public void cleanup() {
if (provider != null) {
provider.terminate(null);
}
public void tearDown() {
super.tearDown();
}

@AfterEach
public void cleanup() {
if (container != null) {
container.shutdown();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;

import java.io.IOException;
import java.net.URISyntaxException;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
Expand All @@ -15,35 +17,29 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import io.smallrye.config.SmallRyeConfigProviderResolver;
import io.smallrye.reactive.messaging.amqp.AmqpBrokerTestBase;
import io.smallrye.reactive.messaging.amqp.AmqpBrokerHolder;
import io.smallrye.reactive.messaging.amqp.AmqpConnector;
import io.smallrye.reactive.messaging.amqp.AmqpUsage;
import io.smallrye.reactive.messaging.amqp.ConsumptionBean;
import io.smallrye.reactive.messaging.test.common.config.MapBasedConfig;

public class AmqpSSLSourceCDISSLContextTest extends AmqpBrokerTestBase {

private AmqpConnector provider;
@Disabled
public class AmqpSSLSourceCDISSLContextTest extends AmqpBrokerHolder {

private WeldContainer container;

@BeforeAll
public static void startBroker() {
try {
String brokerXml = SSLBrokerConfigUtil.createSecuredBrokerXml();
System.setProperty(BROKER_XML_LOCATION, brokerXml);
AmqpBrokerTestBase.startBroker();
} catch (Exception e) {
throw new RuntimeException(e);
}
public static void startBroker() throws IOException, URISyntaxException {
startBroker(SSLBrokerConfigUtil.createSecuredBrokerXml());
}

@AfterAll
public static void clearSslBrokerName() {
System.clearProperty(BROKER_XML_LOCATION);
public static void stopBroker() {
AmqpBrokerHolder.stopBroker();
}

@Override
Expand All @@ -57,10 +53,6 @@ public void setup() {

@AfterEach
public void cleanup() {
if (provider != null) {
provider.terminate(null);
}

if (container != null) {
container.shutdown();
}
Expand Down
Loading