damu11782 / rest-assured

Automatically exported from code.google.com/p/rest-assured
0 stars 0 forks source link

Support for multipart GET #334

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.try to GET for any multipart data
2.
3.

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?

Please provide any additional information below.

Original issue reported on code.google.com by chchakra...@gmail.com on 20 May 2014 at 1:57

GoogleCodeExporter commented 9 years ago
Could you provide an example for this? Or know of a website that I can use to 
try it out?

Original comment by johan.ha...@gmail.com on 21 May 2014 at 1:48

GoogleCodeExporter commented 9 years ago
Also what error message do you get?

Original comment by johan.ha...@gmail.com on 21 May 2014 at 1:49

GoogleCodeExporter commented 9 years ago
Here is my scenario,

I have a form (consider it's like user registration form) where i can enter 
details like
username(String),address(String),photo(octetSteam/inputstream).

for this i can able to 'post' multipart/form-data like as follows using Rest 
assure

File photoFile = new File("test.jpg");
given().multiPart("username", "TestUser").multiPart("photo", 
"testAddress").when().post("/user");

Following are the my scenarios to test
1) To get user details i have a rest API like GET '/user/{userId}' which gives 
user data interms of 'multipart/form-data' 
2) To update only photo rest api PUT '/user/{userID}/photo' which accepts 
'application/octet-stream'
3) After updating i want to GET '/user/{userID}/photo' which give 
'application/octet-stream' 
    so that i can verify whether previous PUT is updated my 'photo' or not?

How i can use Rest assure to test above 3 cases?

thanks in advance

-
Chakrapani.Ch

Original comment by chchakra...@gmail.com on 22 May 2014 at 6:04

GoogleCodeExporter commented 9 years ago
So which part fails? Is it the first operation (1)?

Original comment by johan.ha...@gmail.com on 22 May 2014 at 6:07

GoogleCodeExporter commented 9 years ago
Yes first one is failing and regarding 2nd,3rd is i want to know REST assure is 
supporting these type of operations?

Original comment by chchakra...@gmail.com on 22 May 2014 at 6:35

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
And what error do you get? 2nd and 3rd should work with RA.

Original comment by johan.ha...@gmail.com on 22 May 2014 at 6:42

GoogleCodeExporter commented 9 years ago
here is my sample code
1)InputStream is1 = given().get("/user/{useId}/photo", 123).asInputStream();
2)given().contentType("application/octet-stream").content(IOUtils.toByteArray(is
1)).put("/user/{useId}/photo", 123);
here 1) is working fine (i have verified this inputStream by saving in local 
file system.but in 2)line it's saving 0KB.
after these 2 statements,i can see a file with 0KB.

Original comment by chchakra...@gmail.com on 22 May 2014 at 6:54

GoogleCodeExporter commented 9 years ago
Oh so (1) actually works? Are you having issues with the uploading part? Are 
you sure that you shouldn't use multi-part form data uploading for the PUT 
requests as well?

Original comment by johan.ha...@gmail.com on 22 May 2014 at 6:59

GoogleCodeExporter commented 9 years ago
in comment-8 i have discussed about issue (2) mentioned in comment-3.

Original comment by chchakra...@gmail.com on 22 May 2014 at 7:06

GoogleCodeExporter commented 9 years ago
But you still have problems with (1)? Or is (1) the root of the problem? Is 
IOUtils.toByteArray(..) returning a valid byte-array?

What version of REST Assured are you using?

Original comment by johan.ha...@gmail.com on 22 May 2014 at 7:52

GoogleCodeExporter commented 9 years ago
Closed due to inactivity

Original comment by johan.ha...@gmail.com on 23 Sep 2014 at 9:15