Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix README and add test for MP Config Provider
  • Loading branch information
kabir committed Nov 20, 2025
commit 01d08e16bf58ceb181a18db3e5bea8b1b2002b3e
11 changes: 8 additions & 3 deletions integrations/microprofile-config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,18 @@ The `MicroProfileConfigProvider` implementation:
```
MicroProfile Config Sources (application.properties, env vars, -D flags)
↓ (not found?)
META-INF/a2a-defaults.properties (from server-common)
↓ (not found?)
META-INF/a2a-defaults.properties (from extras modules)
DefaultValuesConfigProvider
→ Scans classpath for ALL META-INF/a2a-defaults.properties files
→ Merges all discovered properties together
→ Throws exception if duplicate keys found
↓ (property exists?)
Return merged default value
↓ (not found?)
IllegalArgumentException
```

**Note**: All `META-INF/a2a-defaults.properties` files (from server-common, extras modules, etc.) are loaded and merged together by `DefaultValuesConfigProvider` at startup. This is not a sequential fallback chain, but a single merged set of defaults.

## Available Configuration Properties

See the [main README](../../README.md#configuration-system) for a complete list of configuration properties.
Expand Down
17 changes: 17 additions & 0 deletions integrations/microprofile-config/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,22 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>

<!-- Test dependencies -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package io.a2a.integrations.microprofile;

import io.a2a.server.config.A2AConfigProvider;
import io.quarkus.test.junit.QuarkusTest;
import jakarta.inject.Inject;
import org.junit.jupiter.api.Test;

import java.util.Optional;

import static org.junit.jupiter.api.Assertions.*;

/**
* CDI-based test to verify that MicroProfileConfigProvider is properly selected
* and works correctly with MicroProfile Config and fallback to defaults.
*/
@QuarkusTest
public class MicroProfileConfigProviderTest {

@Inject
A2AConfigProvider configProvider;

@Test
public void testIsMicroProfileConfigProvider() {
// Verify that when microprofile-config module is on classpath,
// the injected A2AConfigProvider is the MicroProfile implementation
assertInstanceOf(MicroProfileConfigProvider.class, configProvider,
"A2AConfigProvider should be MicroProfileConfigProvider when module is present");
}

@Test
public void testGetValueFromMicroProfileConfig() {
// Test that values from application.properties override defaults
// The test application.properties sets a2a.executor.core-pool-size=15
String value = configProvider.getValue("a2a.executor.core-pool-size");
assertEquals("15", value, "Should get value from MicroProfile Config (application.properties)");
}

@Test
public void testGetValueFallbackToDefaults() {
// Test that values not in application.properties fall back to META-INF/a2a-defaults.properties
// a2a.executor.max-pool-size is not in test application.properties, so should use default
String value = configProvider.getValue("a2a.executor.max-pool-size");
assertEquals("50", value, "Should fall back to default value from META-INF/a2a-defaults.properties");
}

@Test
public void testGetValueAnotherDefault() {
// Test another default property to ensure fallback works
String value = configProvider.getValue("a2a.executor.keep-alive-seconds");
assertEquals("60", value, "Should fall back to default value");
}

@Test
public void testGetOptionalValueFromMicroProfileConfig() {
// Test optional value that exists in application.properties
Optional<String> value = configProvider.getOptionalValue("a2a.executor.core-pool-size");
assertTrue(value.isPresent(), "Optional value should be present");
assertEquals("15", value.get(), "Should get overridden value from MicroProfile Config");
}

@Test
public void testGetOptionalValueFallbackToDefaults() {
// Test optional value that falls back to defaults
Optional<String> value = configProvider.getOptionalValue("a2a.executor.max-pool-size");
assertTrue(value.isPresent(), "Optional value should be present from defaults");
assertEquals("50", value.get(), "Should get default value");
}

@Test
public void testGetOptionalValueNotFound() {
// Test optional value that doesn't exist anywhere
Optional<String> value = configProvider.getOptionalValue("non.existent.property");
assertFalse(value.isPresent(), "Optional value should be empty for non-existent property");
}

@Test
public void testGetValueThrowsForNonExistent() {
// Test that required getValue() throws for non-existent property
assertThrows(IllegalArgumentException.class,
() -> configProvider.getValue("non.existent.property"),
"Should throw IllegalArgumentException for non-existent required property");
}

@Test
public void testSystemPropertyOverride() {
// System properties should have higher priority than application.properties
// Set a system property and verify it's used
String originalValue = System.getProperty("a2a.test.system.property");
try {
System.setProperty("a2a.test.system.property", "from-system-property");
String value = configProvider.getValue("a2a.test.system.property");
assertEquals("from-system-property", value,
"System property should override application.properties");
} finally {
if (originalValue != null) {
System.setProperty("a2a.test.system.property", originalValue);
} else {
System.clearProperty("a2a.test.system.property");
}
}
}
Comment thread
kabir marked this conversation as resolved.
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Test configuration for MicroProfileConfigProviderTest
# This overrides the default value to verify MicroProfile Config integration works

# Override default value (default is 5)
a2a.executor.core-pool-size=15

# Note: a2a.executor.max-pool-size is NOT set here to test fallback to defaults
# Default value should be 50 from META-INF/a2a-defaults.properties

Comment thread
kabir marked this conversation as resolved.
# Exclude beans that aren't needed for config testing
quarkus.arc.exclude-types=io.a2a.server.requesthandlers.*,io.a2a.server.agentexecution.*,io.a2a.server.tasks.*,io.a2a.server.events.*,io.a2a.server.util.*