Skip to content

Commit 5fa5d97

Browse files
Integration test for Solace OAuth client authentication
1 parent c8c0230 commit 5fa5d97

File tree

18 files changed

+3515
-26
lines changed

18 files changed

+3515
-26
lines changed

integration-tests/pom.xml

+1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
<packaging>pom</packaging>
1313
<modules>
1414
<module>solace-client-integration-tests</module>
15+
<module>solace-client-oauth-integration-tests</module>
1516
</modules>
1617
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>com.solace.quarkus</groupId>
8+
<artifactId>quarkus-solace-integration-tests-parent</artifactId>
9+
<version>1.0.1-SNAPSHOT</version>
10+
</parent>
11+
12+
<artifactId>solace-client-oauth-integration-tests</artifactId>
13+
<name>Quarkus Solace Client - OAuth Integration Tests</name>
14+
15+
<dependencies>
16+
<dependency>
17+
<groupId>io.quarkus</groupId>
18+
<artifactId>quarkus-resteasy-reactive-jackson</artifactId>
19+
</dependency>
20+
<dependency>
21+
<groupId>com.solace.quarkus</groupId>
22+
<artifactId>quarkus-solace-client</artifactId>
23+
<version>${project.version}</version>
24+
</dependency>
25+
<dependency>
26+
<groupId>io.quarkus</groupId>
27+
<artifactId>quarkus-smallrye-health</artifactId>
28+
</dependency>
29+
30+
<dependency>
31+
<groupId>io.quarkus</groupId>
32+
<artifactId>quarkus-junit5</artifactId>
33+
<scope>test</scope>
34+
</dependency>
35+
<dependency>
36+
<groupId>org.testcontainers</groupId>
37+
<artifactId>testcontainers</artifactId>
38+
<scope>test</scope>
39+
</dependency>
40+
<dependency>
41+
<groupId>io.rest-assured</groupId>
42+
<artifactId>rest-assured</artifactId>
43+
<scope>test</scope>
44+
</dependency>
45+
<dependency>
46+
<groupId>org.awaitility</groupId>
47+
<artifactId>awaitility</artifactId>
48+
<scope>test</scope>
49+
</dependency>
50+
<dependency>
51+
<groupId>org.assertj</groupId>
52+
<artifactId>assertj-core</artifactId>
53+
<version>3.24.2</version>
54+
<scope>test</scope>
55+
</dependency>
56+
</dependencies>
57+
58+
<build>
59+
<plugins>
60+
<plugin>
61+
<groupId>io.quarkus</groupId>
62+
<artifactId>quarkus-maven-plugin</artifactId>
63+
<executions>
64+
<execution>
65+
<goals>
66+
<goal>build</goal>
67+
</goals>
68+
</execution>
69+
</executions>
70+
</plugin>
71+
<plugin>
72+
<artifactId>maven-jar-plugin</artifactId>
73+
<executions>
74+
<execution>
75+
<goals>
76+
<goal>test-jar</goal>
77+
</goals>
78+
</execution>
79+
</executions>
80+
</plugin>
81+
<plugin>
82+
<artifactId>maven-surefire-plugin</artifactId>
83+
<configuration>
84+
</configuration>
85+
</plugin>
86+
</plugins>
87+
</build>
88+
89+
<profiles>
90+
<profile>
91+
<id>native-image</id>
92+
<activation>
93+
<property>
94+
<name>native</name>
95+
</property>
96+
</activation>
97+
<build>
98+
<plugins>
99+
<plugin>
100+
<artifactId>maven-failsafe-plugin</artifactId>
101+
<executions>
102+
<execution>
103+
<goals>
104+
<goal>integration-test</goal>
105+
<goal>verify</goal>
106+
</goals>
107+
<configuration>
108+
<systemPropertyVariables>
109+
<native.image.path>
110+
${project.build.directory}/${project.build.finalName}-runner
111+
</native.image.path>
112+
<java.util.logging.manager>org.jboss.logmanager.LogManager
113+
</java.util.logging.manager>
114+
<maven.home>${maven.home}</maven.home>
115+
</systemPropertyVariables>
116+
</configuration>
117+
</execution>
118+
</executions>
119+
</plugin>
120+
</plugins>
121+
</build>
122+
<properties>
123+
<quarkus.package.type>native</quarkus.package.type>
124+
</properties>
125+
</profile>
126+
</profiles>
127+
128+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package com.solace.quarkus;
2+
3+
import java.util.List;
4+
import java.util.concurrent.CopyOnWriteArrayList;
5+
6+
import jakarta.enterprise.context.ApplicationScoped;
7+
import jakarta.enterprise.event.Observes;
8+
9+
import com.solace.messaging.MessagingService;
10+
import com.solace.messaging.config.MissingResourcesCreationConfiguration;
11+
import com.solace.messaging.receiver.DirectMessageReceiver;
12+
import com.solace.messaging.receiver.PersistentMessageReceiver;
13+
import com.solace.messaging.resources.Queue;
14+
import com.solace.messaging.resources.TopicSubscription;
15+
16+
import io.quarkus.runtime.ShutdownEvent;
17+
18+
@ApplicationScoped
19+
public class SolaceConsumer {
20+
21+
private final DirectMessageReceiver directReceiver;
22+
private final PersistentMessageReceiver persistentReceiver;
23+
List<String> direct = new CopyOnWriteArrayList<>();
24+
List<String> persistent = new CopyOnWriteArrayList<>();
25+
26+
public SolaceConsumer(MessagingService solace) {
27+
directReceiver = solace.createDirectMessageReceiverBuilder()
28+
.withSubscriptions(TopicSubscription.of("hello/direct"))
29+
.build().start();
30+
persistentReceiver = solace.createPersistentMessageReceiverBuilder()
31+
.withMissingResourcesCreationStrategy(
32+
MissingResourcesCreationConfiguration.MissingResourcesCreationStrategy.CREATE_ON_START)
33+
.withSubscriptions(TopicSubscription.of("hello/persistent"))
34+
.build(Queue.durableExclusiveQueue("hello/persistent")).start();
35+
36+
directReceiver.receiveAsync(h -> consumeDirect(h.getPayloadAsString()));
37+
persistentReceiver.receiveAsync(h -> consumePersistent(h.getPayloadAsString()));
38+
}
39+
40+
public void shutdown(@Observes ShutdownEvent event) {
41+
directReceiver.terminate(1);
42+
persistentReceiver.terminate(1);
43+
}
44+
45+
public void consumeDirect(String message) {
46+
direct.add(message);
47+
}
48+
49+
public void consumePersistent(String message) {
50+
persistent.add(message);
51+
}
52+
53+
public List<String> direct() {
54+
return direct;
55+
}
56+
57+
public List<String> persistent() {
58+
return persistent;
59+
}
60+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.solace.quarkus;
2+
3+
import jakarta.enterprise.context.ApplicationScoped;
4+
5+
import com.solace.messaging.MessagingServiceClientBuilder;
6+
7+
@ApplicationScoped
8+
public class SolaceCustomizer implements MessagingServiceClientCustomizer {
9+
@Override
10+
public MessagingServiceClientBuilder customize(MessagingServiceClientBuilder builder) {
11+
return builder;
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package com.solace.quarkus;
2+
3+
import java.util.List;
4+
5+
import jakarta.enterprise.event.Observes;
6+
import jakarta.inject.Inject;
7+
import jakarta.ws.rs.GET;
8+
import jakarta.ws.rs.POST;
9+
import jakarta.ws.rs.Path;
10+
import jakarta.ws.rs.Produces;
11+
12+
import com.solace.messaging.MessagingService;
13+
import com.solace.messaging.publisher.DirectMessagePublisher;
14+
import com.solace.messaging.publisher.PersistentMessagePublisher;
15+
import com.solace.messaging.resources.Topic;
16+
17+
import io.quarkus.runtime.StartupEvent;
18+
19+
@Path("/solace")
20+
public class SolaceResource {
21+
22+
@Inject
23+
SolaceConsumer consumer;
24+
25+
@Inject
26+
MessagingService solace;
27+
private DirectMessagePublisher directMessagePublisher;
28+
private PersistentMessagePublisher persistentMessagePublisher;
29+
30+
public void init(@Observes StartupEvent ev) {
31+
directMessagePublisher = solace.createDirectMessagePublisherBuilder().build().start();
32+
persistentMessagePublisher = solace.createPersistentMessagePublisherBuilder().build().start();
33+
}
34+
35+
@GET
36+
@Path("/direct")
37+
@Produces("application/json")
38+
public List<String> getDirectMessages() {
39+
return consumer.direct();
40+
}
41+
42+
@GET
43+
@Path("/persistent")
44+
@Produces("application/json")
45+
public List<String> getPersistentMessages() {
46+
return consumer.persistent();
47+
}
48+
49+
@POST
50+
@Path("/direct")
51+
public void sendDirect(String message) {
52+
directMessagePublisher.publish(message, Topic.of("hello/direct"));
53+
}
54+
55+
@POST
56+
@Path("/persistent")
57+
public void sendPersistent(String message) {
58+
persistentMessagePublisher.publish(message, Topic.of("hello/persistent"));
59+
}
60+
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
quarkus.solace.devservices.enabled=false
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
-----BEGIN CERTIFICATE-----
2+
MIIDxzCCAq+gAwIBAgIJAIHrWDyBHPjWMA0GCSqGSIb3DQEBCwUAMIGJMQswCQYD
3+
VQQGEwJDQTEMMAoGA1UECAwDTi9BMQ8wDQYDVQQHDAZPdHRhd2ExDzANBgNVBAoM
4+
BlNvbGFjZTEgMB4GCSqGSIb3DQEJARYRbXllbWFpbEBlbWFpbC5jb20xEzARBgNV
5+
BAsMCm15b3JnLXVuaXQxEzARBgNVBAMMCm15a2V5Y2xvYWswIBcNMjQwMzExMDky
6+
NjIxWhgPMjEyNDAyMTYwOTI2MjFaMIGJMQswCQYDVQQGEwJDQTEMMAoGA1UECAwD
7+
Ti9BMQ8wDQYDVQQHDAZPdHRhd2ExDzANBgNVBAoMBlNvbGFjZTEgMB4GCSqGSIb3
8+
DQEJARYRbXllbWFpbEBlbWFpbC5jb20xEzARBgNVBAsMCm15b3JnLXVuaXQxEzAR
9+
BgNVBAMMCm15a2V5Y2xvYWswggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB
10+
AQC6zmPMXjha+0jor9iVEQhu2WUKKRKubTS3eAY72ez9IA+ml1HXh2rqVIPv8F5v
11+
GasxUEbHzDgBrsuQyROwpXei69EuDWY6g3w7ifu6rkx+xAB9ipv9DjUXc3sH37nE
12+
2xK5HnB7CO8O/HoSBbxXw0sJ7SYyDaYujn17fOJyr4Rljqfkj20ok7HzmUH/Wph1
13+
9WZ9ShfkaRw0SVIBeNc+3i/KorERgLfnBydyd9fDsrnIjSJxMWOA2PMDsA8lzvEk
14+
lObn5dlLGIN5nMuNBpefnLQ0y5aA5Ikpzn1I3bwzPqQJt4v2fXem2NPSuMOOa042
15+
oJFZQD9GJRsmC5Kf7o7oKejjAgMBAAGjLjAsMCoGA1UdEQQjMCGCCm15a2V5Y2xv
16+
YWuCCWxvY2FsaG9zdIIIa2V5Y2xvYWswDQYJKoZIhvcNAQELBQADggEBALGDHoxV
17+
KGxZ/O81fOPPg8YNrkPkAvZu4kEEKoS/0bW+npzCRDZu9nULxwRDZJdfU7mNqjHx
18+
RbLMk/rwI2F1aBnBXHMV22wqW/3d+0B6JqnJFz+9Mb0453f8+Dn6ZpxgMYPh2rn/
19+
80wW4g8wuofcdcHxqTd/fNbzWN8kRVsjqIysXjD4w2zb9q/yFwRq0+WeOhc6FJiz
20+
PnLINignHS/zqslCPD53T+Crqcx8vLrLSoMucCXCkgJeX/joLYmjhdgG3ewIOz/C
21+
+BWWOT73+mfe8e87rEX4e3hpJ+0ZBkP25u+6Q02OYU9A1PtBLDyZqeEH/WiIrJNO
22+
UaS8kTKbscA5voc=
23+
-----END CERTIFICATE-----

0 commit comments

Comments
 (0)