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

  • Home
  • SEARCH
  • 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 7495135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T17:59:16+00:00 2026-05-29T17:59:16+00:00

I am trying to run integration tests against a REST web service process that

  • 0

I am trying to run integration tests against a REST web service process that is started in an embedded jetty container within the maven integration test phase. That much is working.

I want to configure the server to use an in-memory HSQL DB such that each JUnit test can setup the database (create tables, insert records), and tear it down (delete the records).

The application context of the web services process defines the following datasource:

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="#{applicationProperties['jdbc.driver.class.name']}" />
    <property name="url" value="#{applicationProperties['jdbc.url']}" />
    <property name="username" value="#{applicationProperties['db.user']}" />
    <property name="password" value="#{applicationProperties['db.pass']}" />
</bean>

Properties:

jdbc.driver.class.name=org.hsqldb.jdbcDriver
jdbc.url=jdbc:hsqldb:mem:mytestdb
db.user=sa
db.pass=

When executing unit tests (that did not rely on the embedded Jetty container to be running), this setup worked fine. Each unit test created the database and inserted the records like so:

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.core.io.ClassPathResource;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
public class TestBase {

    @Autowired
    protected ApplicationContext context;

    ...

    @Before
    public void setUp() {
        DriverManagerDataSource ds = (DriverManagerDataSource) context.getBean("dataSource");
        // Create tables
        // Insert records
    }
}

With my integration tests, this is not working -apparently because the datasource that is created when my server is started in Jetty is not accessible by my unit test class to insert/delete the data.

My question:

  • How can I configure HSQL in my embedded Jetty container so that my unit test setUp() method can manipulate the data?
  • 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-05-29T17:59:17+00:00Added an answer on May 29, 2026 at 5:59 pm

    Posting my own solution here in case it’s useful down the road to someone else.

    Allright, so I didn’t end up solving this the way I had hoped.

    I could not find a way to have my integration tests insert data into the in-memory HSQL database that was running on the server.

    So instead of solving my problem this way, I had the server itself just load the data on startup. Under src/test, I added a DB initialization servlet that would start the in-memory HSQL DB, then execute the insert statements to load the test data. I then copied the web.xml from src/main/webapp to src/test/webapp (didn’t like having to do this), and added this test servlet to load on startup.

    So, the tests themselves don’t actually insert the data in between tests, but they call a doget() method on my new test servlet to tell it to refresh the in-memory database.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Spring/Hibernate webapp that has some integration tests that run on an
I'm trying to get Deleporter to do some cross process integration testing. The tests
I am trying to run unit tests in my TeamCity build that require openJPA
I'm trying to use Maven Failsafe Plugin to run my functional/integration tests, according to
I use NUnit integration tests. I am trying to test to make sure that
I am trying to get SpecUnit to run in a continuous integration build using
When trying to run an Eclipse Dynamic Web Project under a Tomcat setup using
I'm trying to run a batch file, as another user, from my web app.
I'm trying to run a LINQ to SQL query that returns a result in
i am trying to run integration test in separate maven profile, so i need

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.