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

WebClient used in SE examples and tests #1646

Merged
merged 4 commits into from
May 7, 2020

Conversation

Verdent
Copy link
Member

@Verdent Verdent commented Apr 15, 2020

Signed-off-by: David Kral david.k.kral@oracle.com

@Verdent Verdent self-assigned this Apr 15, 2020
@tomas-langer
Copy link
Member

@romain-grecourt can you please have a look?
I have two issues seeing it now:

  1. The registration of readers and writers is a bit too much. Maybe we should come up with some level of automation?
  2. The tests that need to do toCompletableFuture().get() to make sure the reactive path finishes before the method finishes seems ugly (though necessary) - maybe we should come up with a simple wrapper that would be synchronous (either as a testing support library, or maybe even as API)
    Ideas?

@Verdent
Copy link
Member Author

Verdent commented Apr 15, 2020

I was thinking about some WebClient wrapper for Helidon tests. Because when you look into the PR, it contains a lot of duplicity code ... What I am struggling with currently is, how to make it as simple as possible.

@spericas
Copy link
Member

Perhaps some of these simplications should be offered to developers as well (if not already there!). E.g., if I want to add JSON support, why can't I do that in a single line with reasonable defaults?

.mediaSupport(JsonProcessing.class)

or something similar. CoC can coexist with the no magic style.

@Verdent
Copy link
Member Author

Verdent commented Apr 15, 2020

Yes I definitely agree that some simplification for users is required also.

  • Your proposed simplification would be nice if we want to have reader and writer registered by default. But I am not exactly sure if we can do it currently. It seems to me that media support providers are currently not done the same way and creation of each reader and writer is done differently for each provider.
  • It could be possibly also nice to have something like addReader(MessageBodyReader instance) and the same for writer directly at builder. Because you might want to have reading handled by your own reader but writing handled by some default etc. But to this we probably need to update MediaSupport to allow creation of the new MediaSupport instance based on the previously created one.

@romain-grecourt
Copy link
Contributor

romain-grecourt commented Apr 15, 2020

I agree that MediaSupport needs a way to replicate the current "media support" services.

Shortcut methods on the builder for registering readers and writer also sounds like a good idea.

Also registerDefaults() could also be implied by default, and we'd have a flag to not register the defaults.

E.g.

MediaSupport.create() // MediaSupport with defaults

MediaSupport.builder(false) // does not register defaults
    .reader(FooReader.create()) // shortcut for .readerContext().registerReader(...)

MediaSupport.builder() // registers defaults
    .operators(JsonMediaSupport.create()) // registers all supported operators for JSON

@romain-grecourt
Copy link
Contributor

  1. The tests that need to do toCompletableFuture().get() to make sure the reactive path finishes before the method finishes seems ugly (though necessary) - maybe we should come up with a simple wrapper that would be synchronous (either as a testing support library, or maybe even as API)

Having that as part of the Multi / Single API would be nice. Let's chat with Daniel and David about that. Though I think that this is okay to leave as-is for now.

WebSecurityTestUtil.stopServer(server);
}

abstract String serverBaseUri();

@Test
void basicTestJohn() {
void basicTestJohn() throws ExecutionException, InterruptedException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe these could be changed to just throws Exception ? Or maybe like Tomas said we need to come-up with a small utility and wrap the exceptions.

@danielkec
Copy link
Contributor

Maybe something like utility method await to hide dirty blocking? Its quite common in reactive tcks:

WebClientResponse response = await(webClient.get()
                .path("/employees")
                .request());
response.close();
Assertions.assertEquals(Http.Status.OK_200, response.status(), "HTTP response2");

I would definitely add some timeout

@Verdent
Copy link
Member Author

Verdent commented Apr 30, 2020

Fixes #1668

@romain-grecourt
Copy link
Contributor

@tomas-langer Can this PR go in without the new Single features?

Signed-off-by: David Kral <david.k.kral@oracle.com>
Signed-off-by: David Kral <david.k.kral@oracle.com>
Signed-off-by: David Kral <david.k.kral@oracle.com>
Signed-off-by: David Kral <david.k.kral@oracle.com>
@tomas-langer
Copy link
Member

Follow up: #1748

Copy link
Member

@tomas-langer tomas-langer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants