Re: [rest-assured] addResponseSpecification overwrites StatusLine expectation - how to avoid it?

21 views
Skip to first unread message

Johan Haleby

unread,
May 10, 2013, 2:31:30 AM5/10/13
to rest-a...@googlegroups.com
Hmm not quite sure what you're trying to achieve but there's only one status line in the HTTP response afaik. If either one is ok you could do:

.expectStatusLine(anyOf(containsString("HTTP/1.1"), containsString("BAD REQUEST"))). .. 

Regards
/Johan




On Wed, May 8, 2013 at 7:35 PM, <atla...@gmail.com> wrote:
Hello!
Thanks a lot for RA-library, it's very usefull!

I use RA to check a set of HTTP requests and faced such a problem:
addResponseSpecification overwrites StatusLine expectations, but I'd like to check it twice, cause any response has common part and particular part. like this:

    private static ResponseSpecification failRespSpec = new ResponseSpecBuilder()
            .expectStatusLine(containsString("HTTP/1.1"))
             .....
            .build();

    private static ResponseSpecification emptyloginRespSpec = new ResponseSpecBuilder()
            .addResponseSpecification(getFailRespSpec())
            .expectStatusLine(containsString("BAD REQUEST"))
             ......
            .build();

So I'd like to check protocol once for any requests - is there any way to do it? Thanks!



--
You received this message because you are subscribed to the Google Groups "REST assured" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

atla...@gmail.com

unread,
May 11, 2013, 11:52:04 AM5/11/13
to rest-a...@googlegroups.com
You are absolutely right about Status Line - it is the only in reply. Ma question has another reason:

Status line contains common part: protocol (HTTP/1.1) and part that changes depending on responce: Status describtion (like "Bad request" and so on).
So my idea was to group all common parts (like protocol from Status Line, context type and some specific constant headers) into Common ResponseSpecification and in tests join it with current Resp.Spec for current test.
 
Regards / J.A.

Johan Haleby

unread,
May 13, 2013, 1:13:07 AM5/13/13
to rest-a...@googlegroups.com
Oh I see. In that case I suggest you to write you're own custom Hamcrest matcher and use it something in the lines of this:

...expectStatusLine(statusLineWithReasonPharse("BAD REQUEST")). ..

Regards,
/Johan


--

atla...@gmail.com

unread,
May 15, 2013, 3:10:44 AM5/15/13
to rest-a...@googlegroups.com
Thank you! I realy can solve my problem in this way.

среда, 8 мая 2013 г., 21:35:12 UTC+4 пользователь atla...@gmail.com написал:
Reply all
Reply to author
Forward
0 new messages