1 package org
.argeo
.slc
.unit
;
3 import junit
.framework
.TestCase
;
5 import org
.springframework
.context
.ApplicationContext
;
6 import org
.springframework
.context
.support
.ClassPathXmlApplicationContext
;
8 /** Helper for tests using a Spring application co,text. */
9 public abstract class SpringBasedTestCase
extends TestCase
{
10 private ApplicationContext context
;
13 * Gets (and create if necessary) the application context to use. Default
14 * implementation uses a class path xml application context and calls
15 * {@link #getApplicationContextLocation()}.
17 protected ApplicationContext
getContext() {
18 if (context
== null) {
19 context
= new ClassPathXmlApplicationContext(
20 getApplicationContextLocation());
26 * Th location of the application to load. The default implementation
27 * returns <i>applicationContext.xml</i> found in the same package as the
30 protected String
getApplicationContextLocation() {
31 return inPackage("applicationContext.xml");
35 * Prefixes the package of the class after converting the '.' to '/' in
36 * order to have a resource path.
38 protected String
inPackage(String suffix
) {
39 String prefix
= getClass().getPackage().getName().replace('.', '/');
40 return prefix
+ '/' + suffix
;