In-memory test with spring, load sql from same package as Test class
<p>I am currently implemented some repository tests for my application. I setup an in-memory database.</p>

<p>I have the following setup in my test class:</p>

<pre><code>package dk.test

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(Application.class)
@IntegrationTest
public class TestClass {

@Autowired
private Repository repository;

@Test
@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = "classpath:dk/test/seed.sql") //is placed together with the test class in dk.test - does not work
@Sql(executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, scripts = "classpath:truncate-table.sql") //Is placed in /src/test/resources - works fine
public void restRepository() {
    List&lt;Data&gt; result = repository.findData();

    assertThat(result.size(), is(2));
}
</code></pre>

<p>}</p>

<p>When my scripts are placed in /src/test/resources/ everything works fine, my scripts are executed and i get the expected result.</p>

<pre><code>-src
  -test
    -java
      -dk.test
        -TestClass.java
    -resources
      -seed.sql
</code></pre>

<p>But when i place the <code>seed.sql</code> together with the test class like so:</p>

<pre><code>-src
  -test
    -java
      -dk.test
        -TestClass.java
        -seed.sql
</code></pre>

<p>i get the following exception:</p>

<p><code>org.springframework.jdbc.datasource.init.CannotReadScriptException: Cannot read SQL script from class path resource [dk/test/seed.sql]; nested exception is java.io.FileNotFoundException: class path resource [dk/test/seed.sql] cannot be opened because it does not exist</code></p>

<p>I would like this setup, since we're going to have many different sets of data to execute tests on, and it would be easier to see what data combined with the exact test class.</p>