Hello Oleg,
Our test case is asynchronous and our test requires that the testing entity
has to be an HTTP client and an HTTP server but not at the same time.
1) Our testing entity, as an HTTP client, sends a request to our product.
2)Then asynchronously, after a certain amount of time, the product sends an
HTTP request to our testing entity (HTTP server)
3) The testing entity has to check the request received . Test is OK if the
payload received matches the expected payload and KO if not.
In this configuration, this is up to the HTTP server to determine if the
test is OK or KO.
Is it clear ?
We have to perform this several times and have to set a test result each time
=> this is why we have to shut down the HTTP server after receiving a bad or
good HTTP request.
When you said "throwing an unchecked (runtime) exception", where do we have to
do this ? In the HttpRequestHandler.handle method ?
But in such case, will the product received the entire HTTP response ?
BTW, I have another question about HTTPServer shutdown method which takes a
grace period as an argument.
I haven't found so much explanation looking at the java doc. So, could you
explain me please, what is the meaning of this grace period ?
If we want to perform a hard shut down, do we have to set this value to 0 ?
Do we have to perform a stop + shutdown HTTPServer calls or a shutdown call is
sufficient ?
Thanks in advance for your help .
Best Regards.
-----Original Message-----
From: Oleg Kalnichevski [mailto:[email protected]]
Sent: vendredi 16 février 2018 17:22
To: HttpClient User Discussion <[email protected]>
Subject: Re: Advice when using HttpServer for testing purpose
On Fri, 2018-02-16 at 13:01 +0000, COURTAULT Francois wrote:
> Hello everyone,
>
> I want to use HttpServer for testing purpose.
> The way I want to use, it is:
>
> * Start the Httpserver with a HttpRequestHandler registered for
> a dedicated URI
>
> * Receive POST requests on this URI with a payload
>
> * Check the payload
>
> o If the payload doesn't contain a dedicated id, continue to receive
> POST requests until a certain duration is reached.
>
> o If the payload contains the dedicated id but with additional data
> that doesn't match what we are waiting for, return a 400 and then
> stop/shutdown the HttpServer right after.
>
> o If the payload contains the dedicated id with additional data
> that matches what we are waiting for, return 200 and then
> stop/shutdown the HttpServer right after.
>
>
> I have found a way to do this, using some flags, but I have to wait
> for a timeout using awaitTermination method.
>
>
> Is there a way, once I have received either a POST request with a
> right payload or a wrong payload, in the HttpRequestHandler.handle
> method, to return an HTTP response and, right after perform a
> stop/shutdown of the HttpServer ?
>
One should be able to do so by throwing an unchecked (runtime) exception but
why would you want to shut down the server from a request handler in the first
place? Would not it be massively cleaner and easier to just a return a proper
response and let the caller decide whether or not the server should be shut
down?
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
________________________________
This message and any attachments are intended solely for the addressees and
may contain confidential information. Any unauthorized use or disclosure,
either whole or partial, is prohibited.
E-mails are susceptible to alteration. Our company shall not be liable for the
message if altered, changed or falsified. If you are not the intended recipient
of this message, please delete it and notify the sender.
Although all reasonable efforts have been made to keep this transmission free
from viruses, the sender will not be liable for damages caused by a transmitted
virus.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]