Question

I am using Playframework 2.1 with Scala. I would like to test my function , in view part i have to input files. image and music. I am able to test just musicfile perfectly but when it comes to test both of them. I am having java.lang.IndexOutOfBoundsException: 1. I think the problem is defining the multipartformfilesdata. I tried to create a list of fileparts.

val data = new MultipartFormData(
  Map(
    "checkbox" -> Seq("test-1"),
    "tracktitle" -> Seq("test-1"),
    "releasename" -> Seq("test-1"),
    "trackartist" -> Seq("test-1"),
    "tracksubtitle" -> Seq("test-1"),
    "tracklabel" -> Seq("test-1"),
    "releaseartist" -> Seq("test-1"),
    "releasegenre" -> Seq("test-1"),
    "releasesubtitle" -> Seq("test-1"),
    "releaselabel" -> Seq("test-1"),
    "select" -> Seq("1"),
    "format" -> Seq("SINGLE"),
    "trackgenre" -> Seq("test-1")),
  List(FilePart("musicFile", "musicFile", Some("Content-Type:multipart/form-data"), play.api.libs.Files.TemporaryFile(new java.io.File("/tmp/pepe.txt"))),
      FilePart("imageFile","imageFile",Some("Content-Type:multipart/form-data"), play.api.libs.Files.TemporaryFile(new java.io.File("/tmp/pepe.txt")))),        
  List(),
  List())
Was it helpful?

Solution

We can test it like that first one is fileparts , second one is missingFileparts, third one is badFileParts

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top