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 .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ jobs:
- name: Build and verify with JaCoCo coverage gate
run: mvn -B --no-transfer-progress clean verify

- name: Verify direct Surefire without agent initialization
run: mvn -B --no-transfer-progress surefire:test

- name: Verify tests with JaCoCo disabled
run: mvn -B --no-transfer-progress test -Djacoco.skip=true

- name: Upload JaCoCo coverage report
if: always()
uses: actions/upload-artifact@v7
Expand Down
2 changes: 2 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@

<!-- 版本属性定义:Java 版本、依赖版本与 Maven 插件版本统一管理 -->
<properties>
<!-- Safe when Surefire runs without JaCoCo prepare-agent. -->
<argLine></argLine>
<java.version>17</java.version>
<maven.compiler.release>${java.version}</maven.compiler.release>
<maven.compiler.source>${java.version}</maven.compiler.source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,44 @@ void jsonBindsBothPropertyNamesAndRoundTrips() throws Exception {
assertEquals(config, mapper.readValue(mapper.writeValueAsString(config), OpenCodeHttpClientConfig.class));
}
}

@Test
void jsonOutputExposesEqualCanonicalAndLegacyValues() throws Exception {
com.fasterxml.jackson.databind.ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper();
OpenCodeHttpClientConfig config = new OpenCodeHttpClientConfig();
config.setBaseUrl("http://output:4096");
config.setStreamEventQueueCapacity(41);
com.fasterxml.jackson.databind.JsonNode json = mapper.valueToTree(config);
assertEquals("http://output:4096", json.get("baseUrl").asText());
assertEquals(json.get("baseUrl"), json.get("serverUrl"));
assertEquals(41, json.get("streamEventQueueCapacity").asInt());
assertEquals(json.get("streamEventQueueCapacity"), json.get("sseEventQueueCapacity"));
}

@Test
void conflictingJsonNamesUseLastValueInDocumentOrder() throws Exception {
com.fasterxml.jackson.databind.ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper();
OpenCodeHttpClientConfig canonicalLast = mapper.readValue("""
{"serverUrl":"http://legacy:4096","baseUrl":"http://canonical:4096",
"sseEventQueueCapacity":11,"streamEventQueueCapacity":22}
""", OpenCodeHttpClientConfig.class);
assertEquals("http://canonical:4096", canonicalLast.getServerUrl());
assertEquals(22, canonicalLast.getSseEventQueueCapacity());
OpenCodeHttpClientConfig legacyLast = mapper.readValue("""
{"baseUrl":"http://canonical:4096","serverUrl":"http://legacy:4096",
"streamEventQueueCapacity":22,"sseEventQueueCapacity":11}
""", OpenCodeHttpClientConfig.class);
assertEquals("http://legacy:4096", legacyLast.getBaseUrl());
assertEquals(11, legacyLast.getStreamEventQueueCapacity());
}

@Test
void jsonAliasesAlsoBindNestedHttpConfiguration() throws Exception {
com.fasterxml.jackson.databind.ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper();
OpenCodeClientConfig config = mapper.readValue("""
{"http":{"serverUrl":"http://nested:4096","sseEventQueueCapacity":19}}
""", OpenCodeClientConfig.class);
assertEquals("http://nested:4096", config.getHttp().getBaseUrl());
assertEquals(19, config.getHttp().getStreamEventQueueCapacity());
}
}
Loading