Powered By Blogger
Showing posts with label fitnesse. Show all posts
Showing posts with label fitnesse. Show all posts

Friday, January 31, 2014

Multipart Fitnesse fixture for Restful Apis

Fitnesse Fixture to handle Multipart/mixed Requests



Just wrote a fitnesse fixture for multipart mixed content types.
The already existing smartrics rest fixtures can handle only multipart/form-data not multipart/mixed.

It is also strange that the Httpcomponent 3.2  does not support multipart/mixed, but only multipart/form-data. Worse enough, I see no documentation that it does not support multipart/mixed. Going through the source code, I could see that the 'multipart/form-data' content type is hard-coded all over the place.

My fixture is written using :
Http component 4.3 : I have added additional support for multipart/mixed, apart from the already existing multipart/form-data
Smartrics rest fixutre 3.0 : Extended the already existing restfixture class and the partfactory class to support multipart/mixed

See my Google code Repository

Sample request to handle Multipart Mixed :


!|smartrics.rest.fitnesse.fixture.RestFixtureConfig|
|http.client.connection.timeout|55000|
|restfixture.display.actual.on.right|true|
|restfixture.default.headers|defHeader : 1|
|restfixture.xml.namespace.context|!-xsalias=${namespace1}
ysalias=${namespace2}
-!|
|restfixture.content.handlers.map|application/xml=XML|
!|com.goraksh.fitnesse.fixture.FitMultipartRestFixture|http://${BASE_URI}|
|setBody|....|
|uploadFile|D:\testcase\hello.txt|
|setHeader|X-session-header : %sessionId%|
|POST|/${RESOURCE_PATH}?${QUERY_PARAMS}|201|!-Cache-Control : no-cache
pragma : no-cache
Content-Type : application/xml-!||

Sample Request to handle Multipart/form-data


!|smartrics.rest.fitnesse.fixture.RestFixtureConfig|
|http.client.connection.timeout|55000|
|restfixture.display.actual.on.right|true|
|restfixture.default.headers|defHeader : 1|
|restfixture.xml.namespace.context|!-xsalias=${namespace1}
ysalias=${namespace2}
-!|
|restfixture.content.handlers.map|application/x-www-form-urlencoded=FORM-DATA|
!|com.goraksh.fitnesse.fixture.FitMultipartRestFixture|http://${BASE_URI}|
|setBody|....
|uploadFile|D:\testcase\hello.txt|
|setHeader|X-session-header : %sessionId%|
|POST|/${RESOURCE_PATH}?${QUERY_PARAMS}|201|!-Cache-Control : no-cache
pragma : no-cache
Content-Type : application/xml-!||