It seems @BeforeClass means any static method annotated with @BeforeClass runs before any test method in the class. So if you have a test suite with several classes, it runs as many times as the quantity of your test classes.
Why not init your embedded database and real database in seperate applicationContexts and add only the embedded database applicationContext in your test?
For example(Sorry, I'm not familiar with the java config style):
Listing-1:embedded-database.xml
<jdbc:embedded-database id="dataSource">
<jdbc:script location="classpath:schema.sql"/>
<jdbc:script location="classpath:test-data.sql"/>
</jdbc:embedded-database>
Listing-2:BaseItegration.java
@RunWith( SpringJUnit4ClassRunner.class )
@ContextConfiguration( locations = { "classpath:your-application-without-a-real-database.xml", "classpath:"embedded-database.xml" } )
public class BaseItegration {
}
The embedded database is then initiated with the applicationContext(therefore only once).
Another solutin is using Spring Profile and you don't have to seperate databases in seperate xmls.
Listing-1:your-application-context.xml
<bean profile="integrationTest">
<jdbc:embedded-database id="dataSource">
<jdbc:script location="classpath:schema.sql"/>
<jdbc:script location="classpath:test-data.sql"/>
</jdbc:embedded-database>
<bean>
<bean profile="production">
//omitted
</bean>
Listing-2:BaseItegration.java
@RunWith( SpringJUnit4ClassRunner.class )
@ContextConfiguration( locations = { "classpath:your-application-context.xml" } )
@ActiveProfiles("integrationTest")
public class BaseItegration {
}
Remember to active production in your web.xml.
Update:
Modify your BaseIntegration as abstract class to solve no @Test method problem. And is the dataSource created in your log?