Skip to content

Commit be11861

Browse files
kabirehsavoie
andauthored
chore: move sdk-jakarta to use WildFly as the server (#166)
# Description Although quarkus-resteasy uses non-reactive RestEasy, Quarkus's CDi container is more lenient than the spec. ------ Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [x] Follow the [`CONTRIBUTING` Guide](../CONTRIBUTING.md). - [x] Make your Pull Request title in the <https://www.conventionalcommits.org/> specification. - Important Prefixes for [release-please](https://github.com/googleapis/release-please): - `fix:` which represents bug fixes, and correlates to a [SemVer](https://semver.org/) patch. - `feat:` represents a new feature, and correlates to a SemVer minor. - `feat!:`, or `fix!:`, `refactor!:`, etc., which represent a breaking change (indicated by the `!`) and will result in a SemVer major. - [x] Ensure the tests pass - [x] Appropriate READMEs were updated (if necessary) Fixes #<issue_number_goes_here> 🦕 --------- Signed-off-by: Emmanuel Hugonnet <[email protected]> Co-authored-by: Emmanuel Hugonnet <[email protected]>
1 parent a31d73a commit be11861

File tree

14 files changed

+321
-23
lines changed

14 files changed

+321
-23
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beans xmlns="https://jakarta.ee/xml/ns/jakartaee"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/beans_4_0.xsd"
5+
bean-discovery-mode="all">
6+
</beans>

sdk-jakarta/pom.xml

Lines changed: 152 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,43 @@
1515

1616
<name>Java A2A SDK for Jakarta</name>
1717
<description>Java SDK for the Agent2Agent Protocol (A2A) - SDK - Jakarta</description>
18-
18+
<properties>
19+
<version.org.wildfly.arquillian>5.1.0.Beta11</version.org.wildfly.arquillian>
20+
<version.org.jboss.arquillian>1.10.0.Final</version.org.jboss.arquillian>
21+
<!-- <version.org.jboss.arquillian>1.9.3.Final</version.org.jboss.arquillian>
22+
<version.org.wildfly.arquillian>5.1.0.Beta9</version.org.wildfly.arquillian>-->
23+
<version.org.jboss.shrinkwrap.shrinkwrap>1.2.6</version.org.jboss.shrinkwrap.shrinkwrap>
24+
<version.org.jboss.arquillian.jakarta>10.0.0.Final</version.org.jboss.arquillian.jakarta>
25+
<version.shrinkwrap.resolvers>3.3.4</version.shrinkwrap.resolvers>
26+
<jboss.home>${project.build.directory}${file.separator}wildfly</jboss.home>
27+
<arquillian.java.vm.args></arquillian.java.vm.args>
28+
<server.debug.port>8787</server.debug.port>
29+
</properties>
30+
<dependencyManagement>
31+
<dependencies>
32+
<dependency>
33+
<groupId>org.jboss.shrinkwrap</groupId>
34+
<artifactId>shrinkwrap-bom</artifactId>
35+
<version>${version.org.jboss.shrinkwrap.shrinkwrap}</version>
36+
<type>pom</type>
37+
<scope>import</scope>
38+
</dependency>
39+
<dependency>
40+
<groupId>org.jboss.arquillian</groupId>
41+
<artifactId>arquillian-bom</artifactId>
42+
<version>${version.org.jboss.arquillian}</version>
43+
<type>pom</type>
44+
<scope>import</scope>
45+
</dependency>
46+
<dependency>
47+
<groupId>org.wildfly.arquillian</groupId>
48+
<artifactId>wildfly-arquillian-bom</artifactId>
49+
<version>${version.org.wildfly.arquillian}</version>
50+
<type>pom</type>
51+
<scope>import</scope>
52+
</dependency>
53+
</dependencies>
54+
</dependencyManagement>
1955
<dependencies>
2056
<dependency>
2157
<groupId>${project.groupId}</groupId>
@@ -65,40 +101,142 @@
65101
<artifactId>jakarta.ws.rs-api</artifactId>
66102
<scope>provided</scope>
67103
</dependency>
68-
<dependency>
104+
<dependency>
69105
<groupId>com.fasterxml.jackson.datatype</groupId>
70106
<artifactId>jackson-datatype-jsr310</artifactId>
71107
<scope>test</scope>
72108
</dependency>
73109
<dependency>
74-
<groupId>io.quarkus</groupId>
75-
<artifactId>quarkus-junit5</artifactId>
110+
<groupId>io.rest-assured</groupId>
111+
<artifactId>rest-assured</artifactId>
76112
<scope>test</scope>
77113
</dependency>
78114
<dependency>
79-
<groupId>io.quarkus</groupId>
80-
<artifactId>quarkus-resteasy-jackson</artifactId>
115+
<groupId>org.jboss.arquillian.junit5</groupId>
116+
<artifactId>arquillian-junit5-container</artifactId>
81117
<scope>test</scope>
82118
</dependency>
83119
<dependency>
84-
<groupId>io.quarkus</groupId>
85-
<artifactId>quarkus-resteasy-client-jackson</artifactId>
120+
<groupId>org.wildfly.arquillian</groupId>
121+
<artifactId>wildfly-arquillian-container-managed</artifactId>
86122
<scope>test</scope>
87123
</dependency>
88-
<dependency>
89-
<groupId>org.jboss.resteasy</groupId>
90-
<artifactId>resteasy-client</artifactId>
124+
<dependency>
125+
<groupId>org.jboss.shrinkwrap</groupId>
126+
<artifactId>shrinkwrap-api</artifactId>
91127
<scope>test</scope>
92128
</dependency>
93129
<dependency>
94130
<groupId>org.junit.jupiter</groupId>
95-
<artifactId>junit-jupiter-api</artifactId>
131+
<artifactId>junit-jupiter</artifactId>
96132
<scope>test</scope>
97133
</dependency>
98134
<dependency>
99-
<groupId>io.rest-assured</groupId>
100-
<artifactId>rest-assured</artifactId>
135+
<groupId>org.jboss.threads</groupId>
136+
<artifactId>jboss-threads</artifactId>
137+
<version>3.9.1</version>
138+
<scope>test</scope>
139+
</dependency>
140+
<dependency>
141+
<groupId>org.hamcrest</groupId>
142+
<artifactId>hamcrest</artifactId>
101143
<scope>test</scope>
102144
</dependency>
103145
</dependencies>
146+
<build>
147+
<plugins>
148+
<plugin>
149+
<groupId>org.wildfly.glow</groupId>
150+
<artifactId>wildfly-glow-arquillian-plugin</artifactId>
151+
<version>1.4.1.Final</version>
152+
<configuration>
153+
<feature-packs>
154+
<feature-pack>
155+
<groupId>org.wildfly</groupId>
156+
<artifactId>wildfly-galleon-pack</artifactId>
157+
<version>36.0.1.Final</version>
158+
</feature-pack>
159+
</feature-packs>
160+
<config-name>standalone.xml</config-name>
161+
</configuration>
162+
<executions>
163+
<execution>
164+
<id>scan</id>
165+
<goals>
166+
<goal>scan</goal>
167+
</goals>
168+
<phase>test-compile</phase>
169+
</execution>
170+
</executions>
171+
</plugin>
172+
<plugin>
173+
<groupId>org.wildfly.plugins</groupId>
174+
<artifactId>wildfly-maven-plugin</artifactId>
175+
<version>5.1.3.Final</version>
176+
<configuration>
177+
<provisioning-file>${project.build.directory}/glow-scan/provisioning.xml</provisioning-file>
178+
<jboss-home>${jboss.home}</jboss-home>
179+
<provisioning-dir>${jboss.home}</provisioning-dir>
180+
<packagingScripts>
181+
<packaging-script>
182+
<scripts>
183+
<script>./src/scripts/configure_logger.cli</script>
184+
</scripts>
185+
</packaging-script>
186+
</packagingScripts>
187+
</configuration>
188+
<executions>
189+
<execution>
190+
<id>test-provisioning</id>
191+
<goals>
192+
<goal>package</goal>
193+
</goals>
194+
<phase>test-compile</phase>
195+
</execution>
196+
</executions>
197+
</plugin>
198+
<plugin>
199+
<groupId>org.apache.maven.plugins</groupId>
200+
<artifactId>maven-surefire-plugin</artifactId>
201+
<version>3.5.3</version>
202+
<configuration>
203+
<systemPropertyVariables>
204+
<jboss.home>${jboss.home}</jboss.home>
205+
<arquillian.xml>arquillian.xml</arquillian.xml>
206+
<arquillian.java.vm.args>${arquillian.java.vm.args}</arquillian.java.vm.args>
207+
</systemPropertyVariables>
208+
</configuration>
209+
</plugin>
210+
<plugin>
211+
<groupId>org.apache.maven.plugins</groupId>
212+
<artifactId>maven-dependency-plugin</artifactId>
213+
<version>3.8.1</version>
214+
<configuration>
215+
<outputDirectory>${project.build.directory}/lib</outputDirectory>
216+
</configuration>
217+
<executions>
218+
<execution>
219+
<id>copy</id>
220+
<phase>generate-test-resources</phase>
221+
<goals>
222+
<goal>copy-dependencies</goal>
223+
</goals>
224+
<configuration>
225+
<includeScope>test</includeScope>
226+
<excludeScope>provided</excludeScope>
227+
</configuration>
228+
</execution>
229+
</executions>
230+
</plugin>
231+
</plugins>
232+
</build>
233+
<profiles>
234+
<profile>
235+
<id>debug.profile</id>
236+
<activation><property><name>debug</name></property></activation>
237+
<properties>
238+
<arquillian.java.vm.args>-agentlib:jdwp=transport=dt_socket,address=*:${server.debug.port},server=y,suspend=y</arquillian.java.vm.args>
239+
</properties>
240+
</profile>
241+
</profiles>
104242
</project>

sdk-jakarta/src/main/java/io/a2a/server/apps/jakarta/A2ARequestFilter.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@
1818
import jakarta.ws.rs.core.MediaType;
1919
import jakarta.ws.rs.ext.Provider;
2020

21+
import org.slf4j.Logger;
22+
import org.slf4j.LoggerFactory;
23+
2124
@Provider
2225
@PreMatching
2326
public class A2ARequestFilter implements ContainerRequestFilter {
27+
private static final Logger LOGGER = LoggerFactory.getLogger(A2ARequestFilter.class);
2428

2529
@Override
2630
public void filter(ContainerRequestContext requestContext) {
@@ -31,8 +35,10 @@ public void filter(ContainerRequestContext requestContext) {
3135
// ensure the request is treated as a streaming request or a non-streaming request
3236
// based on the method in the request body
3337
if (isStreamingRequest(requestBody)) {
38+
LOGGER.debug("Handling request as streaming: {}", requestBody);
3439
putAcceptHeader(requestContext, MediaType.SERVER_SENT_EVENTS);
3540
} else if (isNonStreamingRequest(requestBody)) {
41+
LOGGER.debug("Handling request as non-streaming: {}", requestBody);
3642
putAcceptHeader(requestContext, MediaType.APPLICATION_JSON);
3743
}
3844
// reset the entity stream

sdk-jakarta/src/main/resources/META-INF/beans.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
<beans xmlns="https://jakarta.ee/xml/ns/jakartaee"
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/beans_4_0.xsd"
5-
bean-discovery-mode="annotated">
5+
bean-discovery-mode="all">
66
</beans>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/subsystem=logging/logger=org.jboss.weld:add(level=DEBUG)
2+
/subsystem=logging/logger=io.a2a:add(level=DEBUG)

sdk-jakarta/src/test/java/io/a2a/server/apps/jakarta/JakartaA2AServerTest.java

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,76 @@
11
package io.a2a.server.apps.jakarta;
22

3-
import jakarta.inject.Inject;
3+
44

55
import io.a2a.server.apps.common.AbstractA2AServerTest;
6+
import io.a2a.server.apps.common.AgentCardProducer;
7+
import io.a2a.server.apps.common.AgentExecutorProducer;
68
import io.a2a.server.events.InMemoryQueueManager;
79
import io.a2a.server.tasks.TaskStore;
8-
import io.quarkus.test.junit.QuarkusTest;
10+
import jakarta.enterprise.context.ApplicationScoped;
11+
import jakarta.inject.Inject;
12+
import java.io.File;
13+
import java.io.IOException;
14+
import java.nio.file.DirectoryStream;
15+
import java.nio.file.Files;
16+
import java.nio.file.Path;
17+
import java.nio.file.Paths;
18+
import java.util.ArrayList;
19+
import java.util.Iterator;
20+
import java.util.List;
21+
import org.jboss.arquillian.container.test.api.Deployment;
22+
import org.jboss.arquillian.junit5.container.annotation.ArquillianTest;
23+
import org.jboss.shrinkwrap.api.ShrinkWrap;
24+
import org.jboss.shrinkwrap.api.spec.WebArchive;
925

10-
@QuarkusTest
26+
@ArquillianTest
27+
@ApplicationScoped
1128
public class JakartaA2AServerTest extends AbstractA2AServerTest {
29+
30+
public JakartaA2AServerTest() {
31+
super(8080);
32+
}
33+
34+
@Deployment
35+
public static WebArchive createTestArchive() throws IOException {
36+
final List<String> prefixes = List.of(
37+
"a2a-java-sdk-core",
38+
"a2a-java-sdk-server-common",
39+
"jackson",
40+
"mutiny",
41+
"slf4j",
42+
"rest-assured",
43+
"groovy",
44+
"http",
45+
"commons",
46+
"xml-path",
47+
"json-path",
48+
"hamcrest"
49+
);
50+
List<File> libraries = new ArrayList<>();
51+
try (DirectoryStream<Path> stream = Files.newDirectoryStream(Paths.get("target").resolve("lib"))) {
52+
for (Path file : stream) {
53+
String fileName = file.getFileName().toString();
54+
if (prefixes.stream().anyMatch(fileName::startsWith)) {
55+
libraries.add(file.toFile());
56+
}
57+
}
58+
}
59+
WebArchive archive = ShrinkWrap.create(WebArchive.class, "ROOT.war")
60+
.addAsLibraries(libraries.toArray(new File[libraries.size()]))
61+
.addClass(AbstractA2AServerTest.class)
62+
.addClass(AgentCardProducer.class)
63+
.addClass(AgentExecutorProducer.class)
64+
.addClass(JakartaA2AServerTest.class)
65+
.addClass(A2ARequestFilter.class)
66+
.addClass(A2AServerResource.class)
67+
.addClass(RestApplication.class)
68+
.addAsManifestResource("META-INF/beans.xml", "beans.xml")
69+
.addAsWebInfResource("META-INF/beans.xml", "beans.xml")
70+
.addAsWebInfResource("WEB-INF/web.xml", "web.xml");
71+
return archive;
72+
}
73+
1274
@Inject
1375
TaskStore taskStore;
1476

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package io.a2a.server.apps.jakarta;
2+
3+
import jakarta.ws.rs.ApplicationPath;
4+
import jakarta.ws.rs.core.Application;
5+
6+
@ApplicationPath("/")
7+
public class RestApplication extends Application {
8+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<web-app xmlns="https://jakarta.ee/xml/ns/jakartaee"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee
5+
https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd"
6+
version="6.0">
7+
<session-config>
8+
<session-timeout>
9+
30
10+
</session-timeout>
11+
</session-config>
12+
</web-app>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<arquillian xmlns="http://jboss.org/schema/arquillian" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
4+
5+
<engine>
6+
<!-- Uncomment to inspect created deployments -->
7+
<!--<property name="deploymentExportPath">target/deployments</property>-->
8+
</engine>
9+
10+
<container qualifier="jboss" default="true">
11+
<configuration>
12+
<property name="jbossHome">${basedir}/target/wildfly</property>
13+
<!-- Set http port to 8081, so it is the same as for Quarkus -->
14+
<property name="javaVmArguments">${arquillian.java.vm.args}</property>
15+
<property name="allowConnectingToRunningServer">true</property>
16+
</configuration>
17+
</container>
18+
19+
</arquillian>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#
2+
# Copyright The WildFly Authors
3+
# SPDX-License-Identifier: Apache-2.0
4+
#
5+
6+
# Additional logger names to configure (root logger is always configured)
7+
loggers=sun.rmi,org.jboss.shrinkwrap,org.apache.http.wire
8+
logger.org.jboss.shrinkwrap.level=INFO
9+
logger.sun.rmi.level=WARNING
10+
logger.org.apache.http.wire.level=WARN
11+
12+
# Root logger level
13+
logger.level=WARN
14+
15+
# Root logger handlers
16+
logger.handlers=FILE
17+
18+
# File handler configuration
19+
handler.FILE=org.jboss.logmanager.handlers.FileHandler
20+
handler.FILE.properties=autoFlush,append,fileName
21+
handler.FILE.autoFlush=true
22+
handler.FILE.fileName=./target/test.log
23+
handler.FILE.formatter=PATTERN
24+
handler.FILE.append=true
25+
26+
# Formatter pattern configuration
27+
formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter
28+
formatter.PATTERN.properties=pattern
29+
formatter.PATTERN.pattern=%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n

0 commit comments

Comments
 (0)