@NotBlank can generate blank strings containing UTF-8 whitespace characters
The following test generates the " " string, which contains a UTF-8 whitespace character (see https://unicodeplus.com/U+1680).
" ".isBlank() returns true, and Character.isWhitespace(' ') returns true.
import net.jqwik.api.ForAll;
import net.jqwik.api.Property;
import net.jqwik.api.constraints.NotBlank;
public class BlankTest {
@Property(seed = "9077689816503037655")
boolean shouldNotBeBlank(@ForAll @NotBlank String string) {
return !string.isBlank();
}
}
The problem seems to be with this method in NotBlankConfigurator:
public Arbitrary<String> configure(Arbitrary<String> arbitrary, NotBlank notBlank) {
return arbitrary.filter(s -> s != null && !s.trim().isEmpty());
}
s.trim() does not consider UTF-8 whitespace characters. It should use strip instead:
!s.strip().isEmpty()
or just isBlank:
!s.isBlank()
@jacopocav-mollie Makes absolutely sense. My goal is to make a bug fix release shortly and include a fix for that.
Sorry for not addressing this. I would, but I'm currently fighting over getting Maven Central publishing working again. Sonatype have changed their basic publishing mechanism and I haven't succeeded yet in adapting jqwik's configuration to it.
@jlink , I’ve good experience with https://github.com/GradleUp/nmcp. I recently moved to generate the pgp key in github actions, and store it in secrets. It enables one-click releases to Central.
See:
- https://github.com/pgjdbc/pgjdbc/blob/master/.github/workflows/pgp-key-maintenance.yaml
- https://github.com/pgjdbc/pgjdbc/blob/master/.github/workflows/release.yml
- https://github.com/pgjdbc/pgjdbc/blob/master/.github/actions/update_version/action.yaml
@jlink , I’ve good experience with https://github.com/GradleUp/nmcp. I recently moved to generate the pgp key in github actions, and store it in secrets. It enables one-click releases to Central.
Thanks, for the reference. I still hope I can remain using the old approach (Sonatype offers a bridge). I'm currently in conversation with Sonatype support about why it doesn't work.
nmcp will be the next thing I'll look at if the above fails.
I'd tend to prefer releasing from my machine - at least in the beginning. But that should also be possible with nmcp I assume.