marketplace/bundles/pm-dev-java-cui/skills/cui-http-testing/SKILL.md
CUI MockWebServer standards for HTTP client testing with JUnit 5 integration
npx skillsauth add cuioss/plan-marshall cui-http-testingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
REFERENCE MODE: This skill provides reference material. Load specific standards on-demand based on current task.
CUI-specific HTTP testing standards using cui-test-mockwebserver-junit5. Covers MockWebServer configuration, HTTPS testing, and request verification.
Execution mode: Reference library; load standards on-demand for HTTP testing tasks.
Prohibited actions:
@EnableMockWebServer annotationConstraints:
@EnableMockWebServer with @MockResponseConfig annotationsde.cuioss.test:cui-test-mockwebserver-junit5CRITICAL: Load these standards for any HTTP testing work.
Read: standards/testing-mockwebserver.md
This provides the complete reference for annotations, dispatchers, HTTPS, and request verification.
Simple response mocking — Use @MockResponseConfig annotation:
@EnableMockWebServer
@MockResponseConfig(
path = "/api/users",
method = HttpMethodMapper.GET,
status = 200,
jsonContentKeyValue = "users=[]"
)
class UserClientTest {
@Test
void shouldFetchUsers(URIBuilder uriBuilder) throws Exception {
HttpResponse<String> response = client.send(
HttpRequest.newBuilder()
.uri(uriBuilder.addPathSegments("api", "users").build())
.GET().build(),
HttpResponse.BodyHandlers.ofString());
assertEquals(200, response.statusCode());
}
}
Complex routing — Use @ModuleDispatcher with ModuleDispatcherElement:
@EnableMockWebServer
@ModuleDispatcher
class RoutingTest {
ModuleDispatcherElement getModuleDispatcher() {
return new ModuleDispatcherElement() {
@Override
public String getBaseUrl() { return "/api"; }
@Override
public Optional<mockwebserver3.MockResponse> handleGet(
@NonNull mockwebserver3.RecordedRequest request) {
return Optional.of(new mockwebserver3.MockResponse.Builder()
.code(200).body("{\"status\":\"ok\"}").build());
}
@Override
public @NonNull Set<HttpMethodMapper> supportedMethods() {
return Set.of(HttpMethodMapper.GET);
}
};
}
}
HTTPS testing — Add useHttps = true and inject SSLContext:
@EnableMockWebServer(useHttps = true)
class HttpsTest {
@Test
void shouldConnectViaHttps(URIBuilder uriBuilder, SSLContext sslContext) {
assertEquals("https", uriBuilder.build().getScheme());
HttpClient client = HttpClient.newBuilder().sslContext(sslContext).build();
// ...
}
}
Request verification — Inject MockWebServer and inspect recorded requests:
@Test
void shouldIncludeAuthHeader(MockWebServer server, URIBuilder uriBuilder) throws Exception {
client.fetchSecure(uriBuilder.addPathSegments("api", "data").build(), "token");
mockwebserver3.RecordedRequest request = server.takeRequest();
assertEquals("Bearer token", request.getHeader("Authorization"));
}
@MockResponseConfig is repeatable — use multiple annotations for multiple endpoints@MockResponseConfig extends class-level config, no leaking between methodsURIBuilder parameter injection for constructing URIs — never hard-code ports@ExplicitParamInjection when combining with WeldUnit| Standard | Purpose |
|----------|---------|
| standards/testing-mockwebserver.md | @EnableMockWebServer, @MockResponseConfig, @ModuleDispatcher, HTTPS, request verification |
pm-dev-java-cui:cui-http — CUI HTTP client patternspm-dev-java-cui:cui-testing — CUI test generator frameworkpm-dev-java:junit-core — General JUnit 5 patternstesting
A test skill for README generation
testing
A test skill with existing references
tools
Skill without references directory
development
Test skill with table-format references