Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fixture methods that strip leading/trailing whitespace #407

Closed
sleberknight opened this issue Aug 1, 2023 · 2 comments · Fixed by #408
Closed

Add fixture methods that strip leading/trailing whitespace #407

sleberknight opened this issue Aug 1, 2023 · 2 comments · Fixed by #408
Assignees
Labels
new feature A new feature such as a new class, method, package, group of classes, etc.
Milestone

Comments

@sleberknight
Copy link
Member

We created the Fixtures class because Dropwizard deprecated its FixtureHelpers. Until yesterday I had never seen any differences or problems when changing from FixtureHelpers to Fixtures. But in several services, some tests started failing. The reason is that FixtureHelpers trims leading and trailing whitespace while Fixtures does not. (FixtureHelpers does not mention this in its javadoc, but it clearly calls String#trim in the code.)

This issue is adds one or more methods to Fixtures that strip leading and/or trailing whitespace. Also, since Java 11 added the strip, stripLeading, and stripTrailing methods, these are generally preferred over the (much older) trim method which only handles ASCII whitespace. We could also have methods that use one or the other, but that's probably not necessary right now.

Some example method signatures:

String fixtureStrippingLeadingAndTrailingWhitespace(String resourceName);
String fixtureStrippingLeadingAndTrailingWhitespace(String resourceName, Charset charset);

String fixtureStrippingLeadingWhitespace(String resourceName);
String fixtureStrippingLeadingWhitespace(String resourceName, Charset charset);

String fixtureStrippingTrailingWhitespace(String resourceName);
String fixtureStrippingTrailingWhitespace(String resourceName, Charset charset);

The above names are pretty long, so need to think whether there are shorter names that still convey the intent.

@sleberknight sleberknight added the new feature A new feature such as a new class, method, package, group of classes, etc. label Aug 1, 2023
@sleberknight sleberknight added this to the 2.4.0 milestone Aug 1, 2023
@sleberknight sleberknight self-assigned this Aug 1, 2023
@sleberknight
Copy link
Member Author

In the above method names, I think they are still meaningful, and a tad shorter, by replacing "Stripping" with just "Strip", so fixtureStripLeadingAndTrailingWhitespace

@sleberknight
Copy link
Member Author

The fixtureStripLeadingAndTrailingWhitespace could also omit "LeadingAndTrailing" resulting in fixtureStripWhitespace, which is then similar to the String class, which has strip for removing leading and trailing whitespace. However, leaving it in the method name is probably more clear.

@sleberknight sleberknight added in progress A task that is actively being worked on and removed in progress A task that is actively being worked on labels Aug 1, 2023
chrisrohr pushed a commit that referenced this issue Aug 1, 2023
* Add fixture methods that strip leading/trailing whitespace

Closes #407

* Add tests of the Charset overloaded methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature A new feature such as a new class, method, package, group of classes, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant