Reputation: 9150
I have this folder structure similar to this one:
main
|--
test
|-- java
|-- com.my.app
|-- unit
|-- integration
|-- resources
|-- sql
|-- // some folder with sql files
Inside integration
, I have several classes with tests that look like this:
@Test
@Sql(value = "/sql/test_data.sql")
public void test() {...}
So far, so good.
But now, I added a table that has a blob
field, used to store images, and in my app I convert that image (using a converter) to base64
and return that base64
string.
I'm able to unit test that converter, but now I want to test the class that use that converter, and I need to insert some images in the h2 db.
How can I do that? I'm not about the syntax, I'm asking where to put that images? inside test/resources? how to use the images inside the sql files in test/resources/sql?
Upvotes: 1
Views: 626
Reputation: 9150
I found the solution :) I created a test/resources/images
folder, and inside test/resources/sql/test_data.sql
:
INSERT INTO table (id, encoded64px) VALUES (1, FILE_READ('classpath:images/image-64px.jpg'));
Also, make sure you have permissions over the images.
Upvotes: 1