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
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<!-- Dependency versions -->
<commons-exec.version>1.4.0</commons-exec.version>
<commons-lang.version>2.6</commons-lang.version>
<jackson.version>2.17.2</jackson.version>
<jackson.version>2.18.12</jackson.version>
<junit-jupiter.version>6.1.0</junit-jupiter.version>
<junit.version>4.13.2</junit.version>
<lombok.version>1.18.46</lombok.version>
Expand Down Expand Up @@ -359,7 +359,7 @@
<configuration>
<skip>false</skip>
<skipTests>false</skipTests>
<argLine>-Xmx1024m -Dfile.encoding=UTF-8</argLine>
<argLine>@{argLine} -Xmx1024m -Dfile.encoding=UTF-8</argLine>
<additionalClasspathElements>
<additionalClasspathElement>${basedir}/target/test-classes</additionalClasspathElement>
</additionalClasspathElements>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,26 @@ public class OpenCodeHttpClientConfig {
*/
private String defaultAgent;

/** Legacy bean alias for {@link #getBaseUrl()}. */
public String getServerUrl() {
return baseUrl;
}

/** Sets the server URL through the legacy bean property. */
public void setServerUrl(String serverUrl) {
this.baseUrl = serverUrl;
}

/** Legacy bean alias for {@link #getStreamEventQueueCapacity()}. */
public int getSseEventQueueCapacity() {
return streamEventQueueCapacity;
}

/** Sets the event queue capacity through the legacy bean property. */
public void setSseEventQueueCapacity(int capacity) {
this.streamEventQueueCapacity = capacity;
}

/**
* 解析用于 HTTP Basic Auth 的密码。
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,32 @@ void shouldKeepLegacySseEventQueueAlias() {
config.setSseEventQueueCapacity(17);
assertEquals(17, config.getStreamEventQueueCapacity());
}

@Test
void aliasesShareCanonicalState() {
OpenCodeHttpClientConfig config = new OpenCodeHttpClientConfig();
config.setServerUrl("http://legacy:4096");
assertEquals("http://legacy:4096", config.getBaseUrl());
config.setBaseUrl("http://canonical:4096");
assertEquals("http://canonical:4096", config.getServerUrl());
config.setStreamEventQueueCapacity(23);
assertEquals(23, config.getSseEventQueueCapacity());
config.setSseEventQueueCapacity(31);
assertEquals(31, config.getStreamEventQueueCapacity());
}

@Test
void jsonBindsBothPropertyNamesAndRoundTrips() throws Exception {
com.fasterxml.jackson.databind.ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper();
for (String names : new String[]{"serverUrl,sseEventQueueCapacity", "baseUrl,streamEventQueueCapacity"}) {
String[] properties = names.split(",");
String json = "{\"" + properties[0] + "\":\"http://json:4096\",\"" + properties[1] + "\":37}";
OpenCodeHttpClientConfig config = mapper.readValue(json, OpenCodeHttpClientConfig.class);
assertEquals("http://json:4096", config.getBaseUrl());
assertEquals(config.getBaseUrl(), config.getServerUrl());
assertEquals(37, config.getStreamEventQueueCapacity());
assertEquals(37, config.getSseEventQueueCapacity());
assertEquals(config, mapper.readValue(mapper.writeValueAsString(config), OpenCodeHttpClientConfig.class));
}
}
}
Loading