-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Multipart file not being added to request when karate is executed from jar #1650
Comments
@david-scott-ie it may take me a while to get to this - but I thought the use of classgraph should have solved all these problems: #751 2 questions: a) which version and b) the moment you are in a JAR you must use |
Version is 1.0.1
Note, I did try with and without the leading / both work in IDE but neither in packaged Jar |
@david-scott-ie really appreciate the sample and instructions ! and your investigation helped. I've made the change so jar resources are grabbed as a byte-stream not a can you test if it works, because this is something near impossible to write a unit-test for: https://github.com/intuit/karate/wiki/Developer-Guide |
@ptrthomas - yes it works! Thanks for turning that around so quickly. Thanks again - do you have a date for the next release? |
@david-scott-ie great. we should have 1.1.0.RC4 within a week |
@david-scott-ie 1.1.0.RC4 has been released |
@ptrthomas File uploading finally works for me with RC4. I'm glad it occurred that it wasn't a problem with my script ;) Thanks for fixing that. |
1.1.0 released |
When using multipart file from karate executed from a jar the file content is not added to request
As part of our CICD Process we build out a jar file containing our karate features to run on the deployed code in each envirnment in order to validate the deployment.
We have a test which calls an endpoint to upload a multipart file which runs fine in the IDE.
However when we build the code out to jar and run it form the jar the content of the file is no longer part of the request.
The error we get in the actual test: org.springframework.web.multipart.support.MissingServletRequestPartException
I have attached a sample project which demonstrates this behaviour indirectly (i.e. by showing the content is empty when run from a jar)
Instructions.
unzip the karate-sample.zip file and open up the project in your ide.
Run the file TestApplication as a java app in the IDE.
The output of the test will indicate content:
Mixed: content-disposition: form-data; name="fileUpload"; filename="test.xlsx"
content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=UTF-8
content-length: 8602
Completed: true
IsInMemory: true
Now run the maven clean install
karate-sample.zip
build, this will build out an executable jar called: sample-test-jar-with-dependencies.jar
Run this as a java jar file: java -jar sample-test-jar-with-dependencies.jar
The output of the test now indicates that the file is empty:
content-disposition: form-data; name="fileUpload"; filename="test.xlsx"
content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=UTF-8
content-length: 0
Completed: true
IsInMemory: true
From debugging the issue it seems file is not getting set properly in the ReourceUtils when it is a jar resource, whereas it does when it is a file resource therefore the ScenarioFileReader's call here return null:
karate-sample.zip
The text was updated successfully, but these errors were encountered: