Skip to content

Commit b4b5195

Browse files
committed
fix: restore HTTP config aliases and main verification
1 parent d615591 commit b4b5195

3 files changed

Lines changed: 50 additions & 2 deletions

File tree

‎pom.xml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
<!-- Dependency versions -->
6262
<commons-exec.version>1.4.0</commons-exec.version>
6363
<commons-lang.version>2.6</commons-lang.version>
64-
<jackson.version>2.17.2</jackson.version>
64+
<jackson.version>2.18.12</jackson.version>
6565
<junit-jupiter.version>6.1.0</junit-jupiter.version>
6666
<junit.version>4.13.2</junit.version>
6767
<lombok.version>1.18.46</lombok.version>
@@ -359,7 +359,7 @@
359359
<configuration>
360360
<skip>false</skip>
361361
<skipTests>false</skipTests>
362-
<argLine>-Xmx1024m -Dfile.encoding=UTF-8</argLine>
362+
<argLine>@{argLine} -Xmx1024m -Dfile.encoding=UTF-8</argLine>
363363
<additionalClasspathElements>
364364
<additionalClasspathElement>${basedir}/target/test-classes</additionalClasspathElement>
365365
</additionalClasspathElements>

‎src/main/java/io/github/easy4j/opencode/OpenCodeHttpClientConfig.java‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,26 @@ public class OpenCodeHttpClientConfig {
130130
*/
131131
private String defaultAgent;
132132

133+
/** Legacy bean alias for {@link #getBaseUrl()}. */
134+
public String getServerUrl() {
135+
return baseUrl;
136+
}
137+
138+
/** Sets the server URL through the legacy bean property. */
139+
public void setServerUrl(String serverUrl) {
140+
this.baseUrl = serverUrl;
141+
}
142+
143+
/** Legacy bean alias for {@link #getStreamEventQueueCapacity()}. */
144+
public int getSseEventQueueCapacity() {
145+
return streamEventQueueCapacity;
146+
}
147+
148+
/** Sets the event queue capacity through the legacy bean property. */
149+
public void setSseEventQueueCapacity(int capacity) {
150+
this.streamEventQueueCapacity = capacity;
151+
}
152+
133153
/**
134154
* 解析用于 HTTP Basic Auth 的密码。
135155
*

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,32 @@ void shouldKeepLegacySseEventQueueAlias() {
5858
config.setSseEventQueueCapacity(17);
5959
assertEquals(17, config.getStreamEventQueueCapacity());
6060
}
61+
62+
@Test
63+
void aliasesShareCanonicalState() {
64+
OpenCodeHttpClientConfig config = new OpenCodeHttpClientConfig();
65+
config.setServerUrl("http://legacy:4096");
66+
assertEquals("http://legacy:4096", config.getBaseUrl());
67+
config.setBaseUrl("http://canonical:4096");
68+
assertEquals("http://canonical:4096", config.getServerUrl());
69+
config.setStreamEventQueueCapacity(23);
70+
assertEquals(23, config.getSseEventQueueCapacity());
71+
config.setSseEventQueueCapacity(31);
72+
assertEquals(31, config.getStreamEventQueueCapacity());
73+
}
74+
75+
@Test
76+
void jsonBindsBothPropertyNamesAndRoundTrips() throws Exception {
77+
com.fasterxml.jackson.databind.ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper();
78+
for (String names : new String[]{"serverUrl,sseEventQueueCapacity", "baseUrl,streamEventQueueCapacity"}) {
79+
String[] properties = names.split(",");
80+
String json = "{\"" + properties[0] + "\":\"http://json:4096\",\"" + properties[1] + "\":37}";
81+
OpenCodeHttpClientConfig config = mapper.readValue(json, OpenCodeHttpClientConfig.class);
82+
assertEquals("http://json:4096", config.getBaseUrl());
83+
assertEquals(config.getBaseUrl(), config.getServerUrl());
84+
assertEquals(37, config.getStreamEventQueueCapacity());
85+
assertEquals(37, config.getSseEventQueueCapacity());
86+
assertEquals(config, mapper.readValue(mapper.writeValueAsString(config), OpenCodeHttpClientConfig.class));
87+
}
88+
}
6189
}

0 commit comments

Comments
 (0)