Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8232587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:52:58+00:00 2026-06-07T17:52:58+00:00

I am trying to do the following : execute some database scripts during mvn

  • 0

I am trying to do the following :

  • execute some database scripts during mvn test phase into hsqldb

  • use that database for test purpose

    I was able to configure maven so that each time test phase is called all scripts are executed successfully, but (of course there is a BUT), all my tests failed.

My configurations :

pom.xml

<build>
    <plugins>
        <!-- Plugin maven for sql -->
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>sql-maven-plugin</artifactId>

            <dependencies>
                <!-- Dependency to jdbc driver -->
                <dependency>
                    <groupId>org.hsqldb</groupId>
                    <artifactId>hsqldb</artifactId>
                    <version>${hsql-version}</version>
                </dependency>
            </dependencies>
            <configuration>
                <source>1.5</source>
                <target>1.5</target>
                <encoding>UTF-8</encoding>
                <driver>org.hsqldb.jdbcDriver</driver>
                <url>jdbc:hsqldb:mem:sweetdev_skill_db;shutdown=false</url>
                <settingsKey>hsql-db-test</settingsKey>
                <!--all executions are ignored if -Dmaven.test.skip=true-->
                <skip>${maven.test.skip}</skip>
            </configuration>
            <executions>
                <!--  Create integration test data before running the tests -->
                <execution>
                    <id>create-integration-test-data</id>
                    <phase>process-test-resources</phase>
                    <inherited>true</inherited>
                    <goals>
                        <goal>execute</goal>
                    </goals>
                    <configuration>
                        <url>jdbc:hsqldb:mem:db;shutdown=false</url>
                        <autocommit>true</autocommit>
                        <orderFile>ascending</orderFile>
                        <fileset>
                            <basedir>${basedir}/src/test/resources/sql</basedir>
                            <includes>
                                <include>create.sql</include>
                                <include>insert.sql</include>
                            </includes>
                        </fileset>
                    </configuration>
                </execution>

                <!--  Drop data after executing tests -->
                <execution>
                    <id>drop-db-after-test</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>execute</goal>
                    </goals>
                    <configuration>
                        <orderFile>ascending</orderFile>
                        <fileset>
                            <basedir>${basedir}/src/test/resources/sql</basedir>
                            <includes>
                                <include>drop.sql</include>
                            </includes>
                        </fileset>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

spring config for test :

<bean id="datasource"
    class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="org.hsqldb.jdbcDriver">
    </property>
    <property name="url" value="jdbc:hsqldb:mem:db"></property>
    <property name="username" value="sa">
    </property>
    <property name="password" value="">
    </property>
</bean>

<bean id="entityManagerFactory"
    class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="dataSource" ref="datasource" />
    <!-- use testingSetup pu -->
    <property name="persistenceUnitName" value="testingSetup" />
    <property name="persistenceXmlLocation" value="persistence.xml" />
    <property name="jpaVendorAdapter">
        <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
            <property name="showSql" value="true" />
            <property name="databasePlatform" value="org.hibernate.dialect.HSQLDialect" />
            <property name="generateDdl" value="true" />
        </bean>
    </property>
</bean>


<tx:annotation-driven transaction-manager="transactionManager" />
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>

Output :

    [INFO] ------------------------------------------------------------------------
    [INFO] [clean:clean]
    [INFO] Deleting directory D:\dev\projects\project-data\target
    [INFO] [resources:resources]
    [INFO] Using default encoding to copy filtered resources.
    [INFO] [compiler:compile]
    [INFO] Compiling 62 source files to D:\dev\projects\project-data\target\classes
    [INFO] [resources:testResources]
    [INFO] Using default encoding to copy filtered resources.
    [INFO] [sql:execute {execution: create-integration-test-data}]
    [INFO] Executing file: D:\dev\projects\project-data\src\test\resources\sql\create.sql
    [INFO] Executing file: D:\dev\projects\project-data\src\test\resources\sql\insert.sql
    [INFO] 230 of 230 SQL statements executed successfully
    [INFO] [compiler:testCompile]
    [INFO] Compiling 12 source files to D:\dev\projects\project-data\target\test-classes
    [INFO] [surefire:test]
    [INFO] Surefire report directory: D:\dev\projects\project-data\target\surefire-reports

But then all my test fail. I need your help to figure out why it doesn’t work and help me find solution. Thank you


@AndrewLogvinov

Here is one of test output :

    -------------------------------------------------------------------------------
    Test set: com.ideo.sweetdevskill.data.impl.TestAcquisitionDAOImpl
    -------------------------------------------------------------------------------
    Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.17 sec <<< FAILURE!
    testGetListAcquisitionByUser(com.ideo.sweetdevskill.data.impl.TestAcquisitionDAOImpl)  Time elapsed: 0.148 sec  <<< ERROR!
    java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
        at java.util.ArrayList.RangeCheck(ArrayList.java:547)
        at java.util.ArrayList.get(ArrayList.java:322)
        at com.ideo.sweetdevskill.data.impl.TestAcquisitionDAOImpl.testGetListAcquisitionByUser(TestAcquisitionDAOImpl.java:100)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
        at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
        at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
        at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
        at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
        at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
        at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)
        at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
        at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
        at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
        at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:338)
        at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:997)

Thanks !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T17:53:02+00:00Added an answer on June 7, 2026 at 5:53 pm

    Compare these lines in your config. The database names are different, therefore two different databases are being used.

    <url>jdbc:hsqldb:mem:sweetdev_skill_db;shutdown=false</url>
    
    <property name="url" value="jdbc:hsqldb:mem:db"></property>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to execute following query: Insert into pligg_links_temp select * from pligg_links
I'm trying to execute the following line: exit | sqlplus username/password@sid @test.sql Works great
I'm trying to insert data into a database that I have on my server.
I'm trying to load some java stored procedures into an Oracle 10g database through
I'm trying to create an ANT task that takes some database properties and executes
I have following piece of code which posts some data into database: $post =
I'm trying to insert some Binary data into a MySQL database without using prepared
I'm trying the following code to execute a search and it's not working. On
When I am trying to execute following code to email the contact form details,
While trying to execute the following lines only the last two statements are displayed(Here

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.