Skip to content

Commit 80b6ce3

Browse files
committed
fix: support Surefire without coverage agent initialization
1 parent 4a00ea2 commit 80b6ce3

3 files changed

Lines changed: 48 additions & 0 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ jobs:
3737
- name: Build and verify with JaCoCo coverage gate
3838
run: mvn -B --no-transfer-progress clean verify
3939

40+
- name: Verify direct Surefire without agent initialization
41+
run: mvn -B --no-transfer-progress surefire:test
42+
43+
- name: Verify tests with JaCoCo disabled
44+
run: mvn -B --no-transfer-progress test -Djacoco.skip=true
45+
4046
- name: Upload JaCoCo coverage report
4147
if: always()
4248
uses: actions/upload-artifact@v7

‎pom.xml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252

5353
<!-- 版本属性定义:Java 版本、依赖版本与 Maven 插件版本统一管理 -->
5454
<properties>
55+
<!-- Safe when Surefire runs without JaCoCo prepare-agent. -->
56+
<argLine></argLine>
5557
<java.version>17</java.version>
5658
<maven.compiler.release>${java.version}</maven.compiler.release>
5759
<maven.compiler.source>${java.version}</maven.compiler.source>

‎src/test/java/io/github/easy4j/opencode/OpenCodeHttpClientConfigTest.java‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,44 @@ void jsonBindsBothPropertyNamesAndRoundTrips() throws Exception {
8686
assertEquals(config, mapper.readValue(mapper.writeValueAsString(config), OpenCodeHttpClientConfig.class));
8787
}
8888
}
89+
90+
@Test
91+
void jsonOutputExposesEqualCanonicalAndLegacyValues() throws Exception {
92+
com.fasterxml.jackson.databind.ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper();
93+
OpenCodeHttpClientConfig config = new OpenCodeHttpClientConfig();
94+
config.setBaseUrl("http://output:4096");
95+
config.setStreamEventQueueCapacity(41);
96+
com.fasterxml.jackson.databind.JsonNode json = mapper.valueToTree(config);
97+
assertEquals("http://output:4096", json.get("baseUrl").asText());
98+
assertEquals(json.get("baseUrl"), json.get("serverUrl"));
99+
assertEquals(41, json.get("streamEventQueueCapacity").asInt());
100+
assertEquals(json.get("streamEventQueueCapacity"), json.get("sseEventQueueCapacity"));
101+
}
102+
103+
@Test
104+
void conflictingJsonNamesUseLastValueInDocumentOrder() throws Exception {
105+
com.fasterxml.jackson.databind.ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper();
106+
OpenCodeHttpClientConfig canonicalLast = mapper.readValue("""
107+
{"serverUrl":"http://legacy:4096","baseUrl":"http://canonical:4096",
108+
"sseEventQueueCapacity":11,"streamEventQueueCapacity":22}
109+
""", OpenCodeHttpClientConfig.class);
110+
assertEquals("http://canonical:4096", canonicalLast.getServerUrl());
111+
assertEquals(22, canonicalLast.getSseEventQueueCapacity());
112+
OpenCodeHttpClientConfig legacyLast = mapper.readValue("""
113+
{"baseUrl":"http://canonical:4096","serverUrl":"http://legacy:4096",
114+
"streamEventQueueCapacity":22,"sseEventQueueCapacity":11}
115+
""", OpenCodeHttpClientConfig.class);
116+
assertEquals("http://legacy:4096", legacyLast.getBaseUrl());
117+
assertEquals(11, legacyLast.getStreamEventQueueCapacity());
118+
}
119+
120+
@Test
121+
void jsonAliasesAlsoBindNestedHttpConfiguration() throws Exception {
122+
com.fasterxml.jackson.databind.ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper();
123+
OpenCodeClientConfig config = mapper.readValue("""
124+
{"http":{"serverUrl":"http://nested:4096","sseEventQueueCapacity":19}}
125+
""", OpenCodeClientConfig.class);
126+
assertEquals("http://nested:4096", config.getHttp().getBaseUrl());
127+
assertEquals(19, config.getHttp().getStreamEventQueueCapacity());
128+
}
89129
}

0 commit comments

Comments
 (0)