我有一个加特林模拟代码,该代码读取txt文件及其多部分数据类型,我正在尝试替换txt文件,并使用txt文件的数据编辑代码,这里是我所在的txt文件复制数据
-----------------------------73099146617107112852100862312
Content-Disposition: form-data; name="artistName"
Julian Schnabel
-----------------------------73099146617107112852100862312
Content-Disposition: form-data; name="genreIdSet"
Nature
-----------------------------73099146617107112852100862312
Content-Disposition: form-data; name="genreIdSet"
Abstract
-----------------------------73099146617107112852100862312
Content-Disposition: form-data; name="origin"
new york
-----------------------------73099146617107112852100862312
Content-Disposition: form-data; name="uuid"
-----------------------------73099146617107112852100862312
Content-Disposition: form-data; name="picture"; filename="artist.jpg"
Content-Type: image/jpeg
\FF\D8\FF\E0\00JFIF\00,,\00\00\FF\E1-Exif\00\00MM\00*\00\00\00\00\00\00\00\00\00\00\00\92\00\00\00\00\00\00\00\A4\00\00\00\00\00\00\00\00\00\00\00\00\00\00\B0\00\00\00\00\00\00\00\B8(\00\00\00\00\00\00\001\00\00\00\00\00\00\00\C02\00\00\00\00\00\00\00\D4\00\00\00\00\00\00\00\87i\00\00\00\00\00\00\00\E8\88%\00\00\00\00\00\00X\00\00lNIKON CORPORATION\00NIKON D5000\00\00\00,\00\00\00\00\00,\00\00\00Adobe Photoshop 7.0\002011:03:03 20:20:46\00\00'\82\9A\00\00\00\00\00\00\9D\00\00\00\00\00\00ʈ"\00\00\00\00\00\00\00\00\88'\00\00\00\00\C2\00\00\90\00\00\00\00\000221\90\00\00\00\00\00\00Ґ\00\00\00\00\00\00\E6\91\00\00\00\00\00\91\00\00\00\00\00\00\FA\92\00
\00\00\00\00\00\92\00\00\00\00\00\00
\92\00\00\00\00\00\00\00\92\00\00\00\00\00\00\00\00\92 \00\00\00\00\00\00\00\92
\00\00\00\00\00\00\92\86\00\00\00\00,\00\00\92\90\00\00\00\0050\00\00\92\91\00\00\00\0050\00\00\92\92\00\00\00\0050\00\00\A0\00\00\00\00\000100\A0\00\00\00\00\00\00\00\A0\00\00\00\00\00\00\80\A0\00\00\00\00\00\00X\A2\00\00\00\00\00\00\00\A3\00\00\00\00\00\00\00\00\A3\00\00\00\00\00\00\00\A3\00\00\00\00\00\00F\A4\00\00\00\00\00\00\00\00\A4\00\00\00\00\00\00\00\00\A4\00\00\00\00\00\00\00\00\A4\00\00\00\00\00\00N\A4\00\00\00\00\00\C3\00\00\A4\00\00\00\00\00\00\00\00\A4\00\00\00\00\00\00\00\A4\00\00\00\00\00\00\00\00\A4 \00\00\00\00\00\00\00\00\A4
\00\00\00\00\00\00\00\00\A4\00\00\00\00\00\00\00\00\EA\00 \00\00\00\FF\FF\FF\EE\00\00\00\00\00\00\00
\00\00 \C4\00\00\002\00\00\00
-----------------------------73099146617107112852100862312
Content-Disposition: form-data; name="review"
Julian Schnabel (born October 26, 1951) is an American painter and filmmaker.
-----------------------------73099146617107112852100862312--
这部分
\00\00\00\FF\FF\FF\EE\00\00\00\00\00\00\00
\00\00 \C4\00\00\002\00\00\00
非常长,我只是粘贴了一部分 这是我的模拟代码
package simulation
import scala.concurrent.duration._
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._
class AddArtistSimulation extends Simulation {
val httpProtocol = http
.baseUrl("https://www.mywebapp.com")
.inferHtmlResources()
.acceptHeader("*/*")
.acceptEncodingHeader("gzip, deflate")
.acceptLanguageHeader("en-US,en;q=0.5")
.userAgentHeader("Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0")
val headers_0 = Map("Accept" -> "application/json, text/plain, */*")
val headers_1 = Map(
"content-Type" -> "application/json",
"token" -> "eyJ...")
val headers_3 = Map("Accept" -> "image/webp,*/*")
val headers_6 = Map(
"Accept" -> "application/font-woff2;q=1.0,application/font-woff;q=0.9,*/*;q=0.8",
"Accept-Encoding" -> "identity")
val headers_7 = Map(
"Accept" -> "application/dns-message",
"Content-Type" -> "application/dns-message")
val headers_9 = Map(
"Content-Type" -> "multipart/form-data; boundary=---------------------------73099146617107112852100862312",
"X-Requested-With" -> "XMLHttpRequest",
"token" -> "eyJ...")
val uri1 = "https://www.mywebapp.com:443"
val scn = scenario("AddArtistSimulation")
.exec(http("/public/app/views/addartist.html")
.get("/public/app/views/addartist.html")
.headers(headers_0)
.resources(http("/check-active-user")
.post("/check-active-user")
.headers(headers_1)
.body(StringBody("""{"token":"eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyVXVpZCI6IjNkNTU4MTBlLTdkMDEtNGU3NS04ZGY1LTVkNTE2ZmVhNzUzZiIsInN0YXJ0VGltZSI6MTU2ODE5OTQxNTU4OCwic2Vzc2lvbklkIjoiNGM3ZDJiODgtODI2Ny00Y2ZmLThmYzMtYTc0YTRhMjBhZjRmIiwidXNlclR5cGUiOiJTVVBFUl9BRE1JTiIsImV4cGlyZVRpbWUiOjE1OTk4MjE4MTU1ODd9.0WfixTfclazz1yMf8N3Bn2O9DDOOmdFE61BSIq0gjyb3gZDIikiYUo614oLEtyZz8iZnXB5O7vfPlp31rPi_-Q"}""")),
http("/artist/list")
.post("/artist/list")
.headers(headers_1)
.body(StringBody("""{}""")),
http("/public/app/images/sort_both.png")
.get("/public/app/images/sort_both.png")
.headers(headers_3)
.check(status.is(404)),
http("/public/app/images/sort_desc.png")
.get("/public/app/images/sort_desc.png")
.headers(headers_3)
.check(status.is(404))))
.pause(2)
.exec(http("/public/app/styles/chosen-sprite.png")
.get("/public/app/styles/chosen-sprite.png")
.headers(headers_3)
.resources(http("/public/app/fonts/glyphicons-halflings-regular.woff2")
.get("/public/app/fonts/glyphicons-halflings-regular.woff2")
.headers(headers_6)
.check(status.is(304)))
.check(status.is(404)))
.pause(5)
.exec(http("/artist/signup-processing")
.post("/artist/signup-processing")
.headers(headers_9)
.bodyPart(StringBodyPart("""{"artistName":"Julian Schnabel","genreIdSet":"["Nature","Abstract"]","origin":"new york","uuid":"565asdsad-6a5d6as5as-5453sa4d3as5da","picture":"artist.jpeg","review":"Julian Schnabel (born October 26, 1951) is an American painter and filmmaker."}"""))
.bodyPart(RawFileBodyPart("file", "artist.jpg")
.fileName("/home/Pictures/artist.jpg")
.transferEncoding("binary")).asMultipartForm)
.pause(5)
.exec(http("request_10")
.post("/")
.headers(headers_7)
.body(RawFileBody("AddArtistSimulation_0010_request.txt"))
.check(status.is(404)))
setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol)
}
我应该如何添加图像?同样,当我使用txt文件运行模拟时,我的/artist/signup-processing
路由可以正常工作,但是使用上述代码,路由失败,并在加特林测试报告文件中显示消息/artist/signup-processing: Failed to build request: artist.jpg