Skip to content

Commit 987c36a

Browse files
committed
build: trim sdk-example to the plain mockwebserver3 artifact
Depend on the non-junit5 `mockwebserver3` in the sample: it manages the embedded server's lifecycle by hand from main() and the smoke test, so the JUnit 5 extension — and the JUnit it would otherwise drag onto the runtime classpath — is not needed. Also document the retry pillar's idempotency behavior in the sample (the POST is retried because its in-memory body is replayable, so point readers at IdempotencyKeyStep for non-idempotent writes) and update the module count in CLAUDE.md to eleven, noting sdk-example as an unpublished usage sample.
1 parent 42497b3 commit 987c36a

4 files changed

Lines changed: 14 additions & 5 deletions

File tree

CLAUDE.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ modules) to skip it. See that module's `build.gradle.kts` for the pipeline.
2929

3030
## Repository Layout
3131

32-
Ten Gradle modules (see `settings.gradle.kts`). `gradle/libs.versions.toml` is the single source of truth
33-
for dependency and plugin versions. Group `org.dexpace`, version `0.0.1-alpha.1`. (The tenth,
34-
`sdk-shrink-test`, is a test-only, unpublished R8 shrink-survival guard — not listed below.)
32+
Eleven Gradle modules (see `settings.gradle.kts`). `gradle/libs.versions.toml` is the single source of
33+
truth for dependency and plugin versions. Group `org.dexpace`, version `0.0.1-alpha.1`. (Two are
34+
unpublished and not listed below: `sdk-shrink-test`, a test-only R8 shrink-survival guard, and
35+
`sdk-example`, a runnable end-to-end usage sample.)
3536

3637
| Module | Purpose | JVM target |
3738
|---|---|---|

gradle/libs.versions.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-t
2828
okio = { module = "com.squareup.okio:okio", version.ref = "okio" }
2929
okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
3030
okhttp-tls = { module = "com.squareup.okhttp3:okhttp-tls", version.ref = "okhttp" }
31+
okhttp-mockwebserver = { module = "com.squareup.okhttp3:mockwebserver3", version.ref = "mockwebserver" }
3132
okhttp-mockwebserver-junit5 = { module = "com.squareup.okhttp3:mockwebserver3-junit5", version.ref = "mockwebserver" }
3233
reactor-core = { module = "io.projectreactor:reactor-core", version.ref = "reactor" }
3334
reactor-test = { module = "io.projectreactor:reactor-test", version.ref = "reactor" }

sdk-example/build.gradle.kts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ dependencies {
3838

3939
// MockWebServer ships in the OkHttp project as a generic embedded HTTP server. The sample
4040
// drives it from `main()` so the end-to-end exchange runs deterministically with no network.
41-
implementation(libs.okhttp.mockwebserver.junit5)
41+
// The plain `mockwebserver3` artifact is used (not the `-junit5` variant): the sample manages
42+
// the server lifecycle by hand from `main()` and the smoke test, so no JUnit 5 extension — and
43+
// none of the JUnit it would drag onto the runtime classpath — is needed here.
44+
implementation(libs.okhttp.mockwebserver)
4245
// okhttp-tls mints a self-signed certificate so the embedded server can speak HTTPS — the
4346
// AUTH pillar step refuses to stamp credentials over plaintext, so the sample uses TLS exactly
4447
// as a production caller would. `OkHttpClient` is configured directly here, hence the explicit

sdk-example/src/main/kotlin/org/dexpace/sdk/example/ExampleApp.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,11 @@ public fun buildPipeline(transport: HttpClient): HttpPipeline =
139139
HttpPipelineBuilder(transport)
140140
// REDIRECT pillar — follow 3xx responses within a hop budget.
141141
.append(DefaultRedirectStep())
142-
// RETRY pillar — exponential backoff that honours `Retry-After`.
142+
// RETRY pillar — exponential backoff that honours `Retry-After`. This re-sends a request
143+
// when its method is idempotent or its body is replayable; the sample's POST carries a
144+
// replayable (in-memory) body, so it qualifies. A real caller retrying a non-idempotent
145+
// write should pair this with an idempotency key (see `IdempotencyKeyStep`) so a retried
146+
// POST cannot create a duplicate server-side.
143147
.append(DefaultRetryStep())
144148
// AUTH pillar — stamp a static API key into the `Authorization` header.
145149
.append(

0 commit comments

Comments
 (0)