Skip to content
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
6 changes: 6 additions & 0 deletions core/src/main/resources/META-INF/beans.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/beans_4_0.xsd"
bean-discovery-mode="all">
</beans>
166 changes: 152 additions & 14 deletions sdk-jakarta/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,43 @@

<name>Java A2A SDK for Jakarta</name>
<description>Java SDK for the Agent2Agent Protocol (A2A) - SDK - Jakarta</description>

<properties>
<version.org.wildfly.arquillian>5.1.0.Beta11</version.org.wildfly.arquillian>
<version.org.jboss.arquillian>1.10.0.Final</version.org.jboss.arquillian>
<!-- <version.org.jboss.arquillian>1.9.3.Final</version.org.jboss.arquillian>
<version.org.wildfly.arquillian>5.1.0.Beta9</version.org.wildfly.arquillian>-->
<version.org.jboss.shrinkwrap.shrinkwrap>1.2.6</version.org.jboss.shrinkwrap.shrinkwrap>
<version.org.jboss.arquillian.jakarta>10.0.0.Final</version.org.jboss.arquillian.jakarta>
<version.shrinkwrap.resolvers>3.3.4</version.shrinkwrap.resolvers>
<jboss.home>${project.build.directory}${file.separator}wildfly</jboss.home>
<arquillian.java.vm.args></arquillian.java.vm.args>
<server.debug.port>8787</server.debug.port>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.shrinkwrap</groupId>
<artifactId>shrinkwrap-bom</artifactId>
<version>${version.org.jboss.shrinkwrap.shrinkwrap}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>${version.org.jboss.arquillian}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.wildfly.arquillian</groupId>
<artifactId>wildfly-arquillian-bom</artifactId>
<version>${version.org.wildfly.arquillian}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
Expand Down Expand Up @@ -65,40 +101,142 @@
<artifactId>jakarta.ws.rs-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
<groupId>org.jboss.arquillian.junit5</groupId>
<artifactId>arquillian-junit5-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-client-jackson</artifactId>
<groupId>org.wildfly.arquillian</groupId>
<artifactId>wildfly-arquillian-container-managed</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<dependency>
<groupId>org.jboss.shrinkwrap</groupId>
<artifactId>shrinkwrap-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<groupId>org.jboss.threads</groupId>
<artifactId>jboss-threads</artifactId>
<version>3.9.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.wildfly.glow</groupId>
<artifactId>wildfly-glow-arquillian-plugin</artifactId>
<version>1.4.1.Final</version>
<configuration>
<feature-packs>
<feature-pack>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-galleon-pack</artifactId>
<version>36.0.1.Final</version>
</feature-pack>
</feature-packs>
<config-name>standalone.xml</config-name>
</configuration>
<executions>
<execution>
<id>scan</id>
<goals>
<goal>scan</goal>
</goals>
<phase>test-compile</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>5.1.3.Final</version>
<configuration>
<provisioning-file>${project.build.directory}/glow-scan/provisioning.xml</provisioning-file>
<jboss-home>${jboss.home}</jboss-home>
<provisioning-dir>${jboss.home}</provisioning-dir>
<packagingScripts>
<packaging-script>
<scripts>
<script>./src/scripts/configure_logger.cli</script>
</scripts>
</packaging-script>
</packagingScripts>
</configuration>
<executions>
<execution>
<id>test-provisioning</id>
<goals>
<goal>package</goal>
</goals>
<phase>test-compile</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.3</version>
<configuration>
<systemPropertyVariables>
<jboss.home>${jboss.home}</jboss.home>
<arquillian.xml>arquillian.xml</arquillian.xml>
<arquillian.java.vm.args>${arquillian.java.vm.args}</arquillian.java.vm.args>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
<executions>
<execution>
<id>copy</id>
<phase>generate-test-resources</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeScope>test</includeScope>
<excludeScope>provided</excludeScope>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>debug.profile</id>
<activation><property><name>debug</name></property></activation>
<properties>
<arquillian.java.vm.args>-agentlib:jdwp=transport=dt_socket,address=*:${server.debug.port},server=y,suspend=y</arquillian.java.vm.args>
</properties>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.ext.Provider;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Provider
@PreMatching
public class A2ARequestFilter implements ContainerRequestFilter {
private static final Logger LOGGER = LoggerFactory.getLogger(A2ARequestFilter.class);

@Override
public void filter(ContainerRequestContext requestContext) {
Expand All @@ -31,8 +35,10 @@ public void filter(ContainerRequestContext requestContext) {
// ensure the request is treated as a streaming request or a non-streaming request
// based on the method in the request body
if (isStreamingRequest(requestBody)) {
LOGGER.debug("Handling request as streaming: {}", requestBody);
putAcceptHeader(requestContext, MediaType.SERVER_SENT_EVENTS);
} else if (isNonStreamingRequest(requestBody)) {
LOGGER.debug("Handling request as non-streaming: {}", requestBody);
putAcceptHeader(requestContext, MediaType.APPLICATION_JSON);
}
// reset the entity stream
Expand Down
2 changes: 1 addition & 1 deletion sdk-jakarta/src/main/resources/META-INF/beans.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
<beans xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/beans_4_0.xsd"
bean-discovery-mode="annotated">
bean-discovery-mode="all">
</beans>
2 changes: 2 additions & 0 deletions sdk-jakarta/src/scripts/configure_logger.cli
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/subsystem=logging/logger=org.jboss.weld:add(level=DEBUG)
/subsystem=logging/logger=io.a2a:add(level=DEBUG)
Original file line number Diff line number Diff line change
@@ -1,14 +1,76 @@
package io.a2a.server.apps.jakarta;

import jakarta.inject.Inject;


import io.a2a.server.apps.common.AbstractA2AServerTest;
import io.a2a.server.apps.common.AgentCardProducer;
import io.a2a.server.apps.common.AgentExecutorProducer;
import io.a2a.server.events.InMemoryQueueManager;
import io.a2a.server.tasks.TaskStore;
import io.quarkus.test.junit.QuarkusTest;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import java.io.File;
import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit5.container.annotation.ArquillianTest;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;

@QuarkusTest
@ArquillianTest
@ApplicationScoped
public class JakartaA2AServerTest extends AbstractA2AServerTest {

public JakartaA2AServerTest() {
super(8080);
}

@Deployment
public static WebArchive createTestArchive() throws IOException {
final List<String> prefixes = List.of(
"a2a-java-sdk-core",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to update this to a2a-java-sdk-spec for #149. I'll add a note there after merging this one.

"a2a-java-sdk-server-common",
"jackson",
"mutiny",
"slf4j",
"rest-assured",
"groovy",
"http",
"commons",
"xml-path",
"json-path",
"hamcrest"
);
List<File> libraries = new ArrayList<>();
try (DirectoryStream<Path> stream = Files.newDirectoryStream(Paths.get("target").resolve("lib"))) {
for (Path file : stream) {
String fileName = file.getFileName().toString();
if (prefixes.stream().anyMatch(fileName::startsWith)) {
libraries.add(file.toFile());
}
}
}
WebArchive archive = ShrinkWrap.create(WebArchive.class, "ROOT.war")
.addAsLibraries(libraries.toArray(new File[libraries.size()]))
.addClass(AbstractA2AServerTest.class)
.addClass(AgentCardProducer.class)
.addClass(AgentExecutorProducer.class)
.addClass(JakartaA2AServerTest.class)
.addClass(A2ARequestFilter.class)
.addClass(A2AServerResource.class)
.addClass(RestApplication.class)
.addAsManifestResource("META-INF/beans.xml", "beans.xml")
.addAsWebInfResource("META-INF/beans.xml", "beans.xml")
.addAsWebInfResource("WEB-INF/web.xml", "web.xml");
return archive;
}

@Inject
TaskStore taskStore;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package io.a2a.server.apps.jakarta;

import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application;

@ApplicationPath("/")
public class RestApplication extends Application {
}
12 changes: 12 additions & 0 deletions sdk-jakarta/src/test/resources/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee
https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd"
version="6.0">
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
</web-app>
19 changes: 19 additions & 0 deletions sdk-jakarta/src/test/resources/arquillian.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>

<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">

<engine>
<!-- Uncomment to inspect created deployments -->
<!--<property name="deploymentExportPath">target/deployments</property>-->
</engine>

<container qualifier="jboss" default="true">
<configuration>
<property name="jbossHome">${basedir}/target/wildfly</property>
<!-- Set http port to 8081, so it is the same as for Quarkus -->
<property name="javaVmArguments">${arquillian.java.vm.args}</property>
<property name="allowConnectingToRunningServer">true</property>
</configuration>
</container>

</arquillian>
29 changes: 29 additions & 0 deletions sdk-jakarta/src/test/resources/logging.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#
# Copyright The WildFly Authors
# SPDX-License-Identifier: Apache-2.0
#

# Additional logger names to configure (root logger is always configured)
loggers=sun.rmi,org.jboss.shrinkwrap,org.apache.http.wire
logger.org.jboss.shrinkwrap.level=INFO
logger.sun.rmi.level=WARNING
logger.org.apache.http.wire.level=WARN

# Root logger level
logger.level=WARN

# Root logger handlers
logger.handlers=FILE

# File handler configuration
handler.FILE=org.jboss.logmanager.handlers.FileHandler
handler.FILE.properties=autoFlush,append,fileName
handler.FILE.autoFlush=true
handler.FILE.fileName=./target/test.log
handler.FILE.formatter=PATTERN
handler.FILE.append=true

# Formatter pattern configuration
formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter
formatter.PATTERN.properties=pattern
formatter.PATTERN.pattern=%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n
Loading