I have sql file with insert statements like below
insert into demo.course (col1, col2) VALUES( 'Val 1', 'KS1')
My unit test
@ExtendWith(SpringExtension.class)
@DataJpaTest
@AutoConfigureTestDatabase //h2
@ActiveProfiles("test")
class TopicRepositoryTest extends BaseRepositoryTest {
@Test
public void newTopicCreationShouldBePossible() {
Topics newTopic = createTopics("STEAM"); //from base
assertNotNull(newTopic.getId());
}
}
Application-test.props
spring.datasource.url=jdbc:h2:mem:testdb;IGNORECASE=TRUE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;DATABASE_TO_UPPER=false
spring.jpa.properties.hibernate.default_schema=DEMO
spring.datasource.hikari.schema=DEMO
Error:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of class path resource [maria/importcommon.sql]: insert into demo.mytable (col1, col2) VALUES( 'Val 1', 'KS1'); nested exception is org.h2.jdbc.JdbcSQLSyntaxErrorException: Schema "DEMO" not found; SQL statement:
Reading some posts , I added the below, but it is not working
spring.jpa.properties.hibernate.default_schema=DEMO
spring.datasource.hikari.schema=DEMO
How can I fix this issue and pass my tests?