-
Notifications
You must be signed in to change notification settings - Fork 156
feat!: Remove hard dependency on MicroProfile Config from the core SDK #468
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix README and add test for MP Config Provider
- Loading branch information
commit 01d08e16bf58ceb181a18db3e5bea8b1b2002b3e
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
...config/src/test/java/io/a2a/integrations/microprofile/MicroProfileConfigProviderTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"); | ||
| } | ||
| } | ||
| } | ||
| } | ||
11 changes: 11 additions & 0 deletions
11
integrations/microprofile-config/src/test/resources/application.properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
|
|
||
|
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.* | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.