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
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,9 @@ class BindOptionsTest {
assertFailsWith<IllegalArgumentException> { BindOptions(maxDepth = 0) }
assertFailsWith<IllegalArgumentException> { BindOptions(maxDepth = 513) }
}

@Test
fun `accepts a maxDepth of exactly 512`() {
assertEquals(512, BindOptions(maxDepth = 512).maxDepth)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,12 @@ private fun requireRoot(
Profile.URI -> target::class.hasAnnotation<UriMarker>()
}
if (!marked) {
throw KuriBindException("root ${target::class.simpleName} is not annotated @${profile.name.lowercase()}")
val markerName =
when (profile) {
Profile.URL -> "Url"
Profile.URI -> "Uri"
}
throw KuriBindException("root ${target::class.simpleName} is not annotated @$markerName")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ private fun escapeLiteralPercent(text: String): String = text.replace("%", "%25"
/**
* The narrow set of builder operations the binder needs, abstracting the two profiles.
*
* All profile-specific differences — userinfo split vs. verbatim-join, and fragment encoding — live
* in the concrete implementations rather than in the binder. Callers pass decoded (raw) values; each
* [UrlBuilderSink] and [UriBuilderSink] both split-encode-then-join userinfo, forwarding to their
* underlying builder's `username`/`password` setters identically; there is no verbatim-join path in
* either sink. Fragment encoding is likewise shared, implemented once as the [fragmentDecoded] default
* on this interface rather than overridden per profile. Callers pass decoded (raw) values; each
* implementation decides how to encode before forwarding to the underlying builder.
*/
internal interface BuilderSink {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@
import org.dexpace.kuri.bind.Scheme;

/**
* A plain Java bean used to verify that {@code KotlinReflectMemberScanner} discovers annotated
* getter functions ({@code get*}/{@code is*}) for types that do not expose properties via
* Kotlin's {@code memberProperties}. The annotations live on the getters, not on the fields.
* A plain Java bean used to verify that {@code KotlinReflectMemberScanner} merges getter-level
* annotations onto the corresponding {@code memberProperties} entry. Kotlin-reflect exposes a
* {@code scheme}/{@code host} property for this bean, but with an empty annotation list — the
* {@code @Scheme}/{@code @Host} annotations live only on the getter functions — so discovery of them
* exercises the getter-to-property annotation-merge branch rather than reading annotations straight
* off the property.
*/
public final class JavaBean {
private final String scheme;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ class IntegrationTest {
@Test
fun `rejects a uri root bound through the url entry point`() {
val failure = assertFailsWith<KuriBindException> { KuriBind.toUrl(UriOnly()) }
assertTrue(failure.message.orEmpty().contains("@url"))
assertTrue(failure.message.orEmpty().contains("@Url"))
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class KuriBindTest {
@Test
fun `toUrl throws when the root lacks the url marker`() {
val failure = assertFailsWith<KuriBindException> { KuriBind.toUrl(NoRootMarker("x")) }
assertEquals(true, failure.message?.contains("@url"))
assertEquals(true, failure.message?.contains("@Url"))
}

@Test
Expand All @@ -98,7 +98,7 @@ class KuriBindTest {
@Test
fun `toUri throws when a url root is bound through the uri entry point`() {
val failure = assertFailsWith<KuriBindException> { KuriBind.toUri(Absolute(host = "example.com")) }
assertEquals(true, failure.message?.contains("@uri"))
assertEquals(true, failure.message?.contains("@Uri"))
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class BuilderSinkTest {
assertEquals("https", url.scheme)
}

// UriBuilderSink — verbatim-join userinfo and fragment encoding
// UriBuilderSink — split-encode-then-join userinfo and fragment encoding

@Test
fun `uri sink joins userinfo with encoded parts and a literal colon`() {
Expand Down