1 /**
2 * Copyright 2005-2006 the original author or authors.
3 *
4 * Licensed under the Gnu General Pubic License, Version 2.0 (the
5 * "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/gpl-license.php
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the Gnu General Public License for more details.
14 */
15 package org.figure8.join.util;
16
17 import org.springframework.test.AbstractSpringContextTests;
18 import org.springframework.context.ConfigurableApplicationContext;
19 /**
20 * This is an abstract super class for JUnit tests using a Spring context.
21 * This class extends test facility provided by Spring (thus the context is
22 * only started once) and automatically starts this context within the setUp()
23 * method.<br/>
24 * Subclasses only have to implement the <code>getConfigLocations()</code>.
25 * Then, the started context will be available through the <code>context</code>
26 * instance field.
27 * @author <a href="mailto:laurent.broudoux@free.fr">Laurent Broudoux</a>
28 * @version $Revision: 1.2 $
29 */
30 public abstract class SpringTestCase extends AbstractSpringContextTests{
31
32
33
34 /** Spring container context */
35 protected ConfigurableApplicationContext context = null;
36
37
38
39
40 /**
41 * Initialize the context using the getContext() method from
42 * AbstractSpringContextTests with getConfigLocations() result
43 * as parameter. Thus, subclasses should only implement getConfigLocations().
44 */
45 public void setUp(){
46
47 context = getContext(getConfigLocations());
48 }
49
50
51
52
53 /**
54 * Subclasses have to implement this method. It should return an
55 * array of Spring container configuration files.
56 * @return An array of locations from Spring configuration files.
57 */
58 public abstract String[] getConfigLocations();
59 }