This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
If I run all(31) the unittest together, I get following connection error in 2 - 3 unit tests, however if I run those tests indvidually, the run successfully. Can you please guide me on this strange behaviour. I am using Spring 3.0.6, Spring batch 2.1.7 and orcale XE database.
below is the error
"Know where to find the solution and how to use it - that's the secret of success."
Are your tests closing the dataSource? calling the close() method. It looks like after running a few of the tests and those past tests shutdown Spring container but not closing the connections in the datasources, therefore the backend database has all these connections being used and is probably then reaching its max connections and can't create any new ones for the later tests.
Basically you can configure your datasource to have a <bean … destroy-method="close"/>
How are you creating your Spring ApplicationContext are you using the annotation @ContextConfiguration and @RunWith? Or are you creating it yourself in the setup method?
I am using @ContextConfiguration and @RunWith in the tests. I am not calling close() method of DataSource. My understanding was that all the connection handling is taken care by Spring itself. I have tested it by adding the close() call but of no gain. Below is my datasource config
How many connections does your database allow. Can you post some of your test code? The cause network connection could not be made would be either because the network went down, but I doubt that, or that you are trying to create too many connections than the server/database can start up. So it isn't exactly a Spring or Unit Test problem as a configuration for your database.
Mark Spritzler wrote:How many connections does your database allow. Can you post some of your test code? The cause network connection could not be made would be either because the network went down, but I doubt that, or that you are trying to create too many connections than the server/database can start up. So it isn't exactly a Spring or Unit Test problem as a configuration for your database.
What database are you using?
I am using Orcale XE database installed on my local machine(No network db call). I am not sure how I should check the connection allowed by the db. Please guide me on this. It is the case of connection exhausting but I am not sure where is the problem. I my unit test I am get simpleJdbcTemplate injected. My unit test are calling Spring Batch Job. The job reads table containting 100 reacords, call some transformation logic and write them back in new table.
Joined: Nov 14, 2005
If I run unit test from maven, they work fine. The problems only seems with tests run from eclipse.