dimanche 31 décembre 2017

include external jar dependencies spring boot test

I have spring boot applications which shares the same entities layer, until now the entities were duplicated among all the projects and I had test on each on the modules which worked perfectly. I extracted all the entities into a separated maven artifact and I have added dependencies from my projects to the new artifact. Everything seems to work fine except for my tests which are not able to run. I get the following error when running my tests:

Caused by: org.hsqldb.HsqlException: user lacks privilege or object not found: PIM_SECURITIES
at org.hsqldb.error.Error.error(Unknown Source) ~[hsqldb-2.2.8.jar:2.2.8]
at org.hsqldb.error.Error.error(Unknown Source) ~[hsqldb-2.2.8.jar:2.2.8]
at org.hsqldb.SchemaManager.getTable(Unknown Source) ~[hsqldb-2.2.8.jar:2.2.8]
at org.hsqldb.ParserDQL.readTableName(Unknown Source) ~[hsqldb-2.2.8.jar:2.2.8]
at org.hsqldb.ParserDQL.readSimpleRangeVariable(Unknown Source) ~[hsqldb-2.2.8.jar:2.2.8]
at org.hsqldb.ParserDML.compileInsertStatement(Unknown Source) ~[hsqldb-2.2.8.jar:2.2.8]
at org.hsqldb.ParserCommand.compilePart(Unknown Source) ~[hsqldb-2.2.8.jar:2.2.8]
at org.hsqldb.ParserCommand.compileStatements(Unknown Source) ~[hsqldb-2.2.8.jar:2.2.8]
at org.hsqldb.Session.executeDirectStatement(Unknown Source) ~[hsqldb-2.2.8.jar:2.2.8]
at org.hsqldb.Session.execute(Unknown Source) ~[hsqldb-2.2.8.jar:2.2.8]
at org.hsqldb.jdbc.JDBCStatement.fetchResult(Unknown Source) ~[hsqldb-2.2.8.jar:2.2.8]
at org.hsqldb.jdbc.JDBCStatement.execute(Unknown Source) ~[hsqldb-2.2.8.jar:2.2.8]

below is the definition of my spring boot test class

@ContextConfiguration(classes = {AccountsDao.class, SecuritiesDao.class,  TasksDao.class})
@RunWith(SpringRunner.class)
@DataJpaTest
@Transactional
@ActiveProfiles("test")
public class DalLayerTests extends 
AbstractTransactionalJUnit4SpringContextTests {}

the object not found is in the entities artifact.

I have tried adding the artifact to run with the test scope in maven, but it didn't help. I have tried to add it to the annotation @ContextConfiguration(classes) but it didn't help as well.

Your help will appreciated.

Aucun commentaire:

Enregistrer un commentaire