forked from karatelabs/karate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
multipart/form-data endpoint success from REST client but fails in Ka…
…rate tests karatelabs#797
- Loading branch information
1 parent
7b5438f
commit bb3ed91
Showing
2 changed files
with
56 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
karate-mock-servlet/src/test/java/com/intuit/karate/mock/servlet/test/MockMultiPartTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.intuit.karate.mock.servlet.test; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.springframework.http.HttpHeaders; | ||
|
||
import com.intuit.karate.ScriptValue; | ||
import com.intuit.karate.http.MultiPartItem; | ||
import com.intuit.karate.mock.servlet.MockMultiPart; | ||
|
||
/** | ||
* @author nsehgal | ||
* | ||
* Test for different StandardMultipartHttpServletRequest implementation | ||
* in spring. Below test checks both the implementation should return | ||
* the CONTENT_DISPOSITION header details when asked via getHeader(). | ||
* | ||
*/ | ||
public class MockMultiPartTest { | ||
|
||
private MockMultiPart mockMultiPart = null; | ||
|
||
private static final String CONTENT_DISPOSITION = "content-disposition"; | ||
|
||
@Before | ||
public void init() { | ||
ScriptValue NULL = new ScriptValue(null); | ||
MultiPartItem item = new MultiPartItem("file", NULL); | ||
item.setContentType("text/csv"); | ||
item.setFilename("test.csv"); | ||
mockMultiPart = new MockMultiPart(item); | ||
} | ||
|
||
@Test | ||
public void testSpring2MultipartHeader() { | ||
String headerValue = mockMultiPart.getHeader(HttpHeaders.CONTENT_DISPOSITION); | ||
Assert.assertNotNull(headerValue); | ||
Assert.assertEquals("form-data; filename=\"test.csv\"; name=\"file\"", headerValue); | ||
} | ||
|
||
@Test | ||
public void testSpring1MultipartHeader() { | ||
String headerValue = mockMultiPart.getHeader(CONTENT_DISPOSITION); | ||
Assert.assertNotNull(headerValue); | ||
Assert.assertEquals("form-data; filename=\"test.csv\"; name=\"file\"", headerValue); | ||
} | ||
} |