Claude-skill-registry cui-testing-http
CUI MockWebServer standards for HTTP client testing with JUnit 5 integration
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/cui-testing-http" ~/.claude/skills/majiayu000-claude-skill-registry-cui-testing-http && rm -rf "$T"
manifest:
skills/data/cui-testing-http/SKILL.mdsource content
CUI Testing HTTP Skill
REFERENCE MODE: This skill provides reference material. Load specific standards on-demand based on current task.
CUI-specific HTTP testing standards for projects using cui-test-mockwebserver-junit5. This skill covers MockWebServer configuration, HTTPS testing, and request verification patterns.
Prerequisites
This skill requires CUI test library dependencies:
(EnableMockWebServer, MockResponseConfig)de.cuioss.test:cui-test-mockwebserver-junit5
Workflow
Step 1: Load MockWebServer Standards
CRITICAL: Load this standard for any HTTP client testing work.
Read: standards/testing-mockwebserver.md
This provides the foundational rules:
annotation for test classes@EnableMockWebServer
for declarative response mocking@MockResponseConfig
for complex routing scenarios@ModuleDispatcher- HTTPS support with automatic certificate generation
Key Rules Summary
Basic MockWebServer Setup
// CORRECT - Use annotation-based configuration @EnableMockWebServer @MockResponseConfig( path = "/api/users", method = HttpMethodMapper.GET, status = 200, jsonContentKeyValue = "users=[]" ) class SimpleMockWebServerTest { @Test @DisplayName("Should fetch users from API") void shouldFetchUsers(URIBuilder uriBuilder) throws Exception { HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(uriBuilder.addPathSegments("api", "users").build()) .GET() .build(); HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString()); assertEquals(200, response.statusCode()); } }
HTTPS Testing
// CORRECT - Enable HTTPS with auto-generated certificates @EnableMockWebServer(useHttps = true) class HttpsTest { @Test void shouldConnectViaHttps(URIBuilder uriBuilder, SSLContext sslContext) { assertEquals("https", uriBuilder.build().getScheme()); HttpClient client = HttpClient.newBuilder() .sslContext(sslContext) .build(); // Test with HTTPS... } }
Request Verification
// CORRECT - Verify request details with MockWebServer parameter @Test void shouldVerifyRequest(MockWebServer server, URIBuilder uriBuilder) throws Exception { client.fetchSecureResource(uriBuilder.addPathSegments("api", "users").build(), "token"); RecordedRequest request = server.takeRequest(); assertEquals("Bearer token", request.getHeader("Authorization")); assertEquals("GET", request.getMethod()); }
Complex Routing with ModuleDispatcher
// CORRECT - Use @ModuleDispatcher for dynamic responses @EnableMockWebServer @ModuleDispatcher class ComplexRoutingTest { ModuleDispatcherElement getModuleDispatcher() { return new ModuleDispatcherElement() { @Override public String getBaseUrl() { return "/api"; } @Override public Optional<MockResponse> handleGet(RecordedRequest request) { if (request.getPath().endsWith("/api/users/active")) { return Optional.of(new MockResponse.Builder() .code(200) .body("{\"users\":[]}") .build()); } return Optional.empty(); } @Override public Set<HttpMethodMapper> supportedMethods() { return Set.of(HttpMethodMapper.GET); } }; } }
Related Skills
- CUI HTTP client patternspm-dev-java-cui:cui-http
- CUI test generator frameworkpm-dev-java-cui:cui-testing
- General JUnit 5 patternspm-dev-java:junit-core
Standards Reference
| Standard | Purpose |
|---|---|
| testing-mockwebserver.md | MockWebServer configuration and patterns |