Newcomer to Spring here, so pardon me if this is a stupid question.
I have a relatively small Java library that implements a few dozen beans (no database or GUI). I have created a Spring Bean configuration file that other Java projects use to inject my beans into their stuff.
I am now for the first time trying to use Spring Test to inject some of these beans into my junit test classes (rather than simply instantiating them).
I am doing this partly to learn Spring Test and partly to force the tests to use the same bean configuration file I provide for others.
In the Spring documentation is says I need to create an application context using the "TestContext" class that comes with Spring. I believe this should be done in a spring XML file that I reference via the @ContextConfiguration annotation on my test class.
@ContextConfiguration({"/test-applicationContext.xml"})
However, there is no hint as to what to put in the file!
When I go to run my tests from within Eclipse it errors out saying "failed to load Application Context"....of course.
Update:
Here is test-applicationContext.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<description>Holds application context for testing of the domain module.</description>
<!-- Imports the uuid generator bean definitions -->
<import resource="resources/domain-uuid.xml"/>
</beans>
My project directory is like this:
domain/
src/
main/
java/
resources/
test/
java/
resources/ (location of test-applicationContext.xml)
Just for fun I also tried to build from the mvn command line via "mvn clean test" and I got the following errors which may be my real problem:
package org.springframework.test.context does not exist
package org.springframework.test.context.junit4 does not exist
cannot find symbol
symbol: class ContextConfiguration
@ContextConfiguration({"/resources/test-applicationContext.xml"})
cannot find symbol
symbol: class SpringJUnit4ClassRunner
@RunWith(SpringJUnit4ClassRunner.class)