View Javadoc

1   /*
2    * EL4J, the Extension Library for the J2EE, adds incremental enhancements to
3    * the spring framework, http://el4j.sf.net
4    * Copyright (C) 2010 by ELCA Informatique SA, Av. de la Harpe 22-24,
5    * 1000 Lausanne, Switzerland, http://www.elca.ch
6    *
7    * EL4J is published under the GNU Lesser General Public License (LGPL)
8    * Version 2.1. See http://www.gnu.org/licenses/
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. See the
13   * GNU Lesser General Public License for more details.
14   *
15   * For alternative licensing, please contact info@elca.ch
16   */
17  package ch.elca.el4j.tests.core.context;
18  
19  import java.lang.annotation.Documented;
20  import java.lang.annotation.ElementType;
21  import java.lang.annotation.Inherited;
22  import java.lang.annotation.Retention;
23  import java.lang.annotation.RetentionPolicy;
24  import java.lang.annotation.Target;
25  
26  import org.springframework.test.context.ContextConfiguration;
27  
28  import ch.elca.el4j.core.context.ModuleApplicationContextConfiguration;
29  
30  /**
31   * In addition Spring's {@link @ContextConfiguration}, provides 
32   * settings for the ModuleApplicationContext to be created.
33   * <p>
34   * <strong>WARNING</strong>: For the settings to be applied to the ApplicationContext,
35   * the contextLoader attribute of the <code>@ContextConfiguration</code>
36   * annotation <em>MUST BE A SUBTYPE</em> OF ModuleTestContextLoader.
37   * <p>  
38   * Typically, you would annotate your test classes as follows:
39   * <pre>
40   * &#64;RunWith(EL4JJunit4ClassRunner.class)
41   * &#64;ExtendedContextConfiguration(exclusiveConfigLocations = {
42   * 	   "classpath*:mandatory/refdb-core-config.xml",
43   * 	   "classpath*:mandatory/keyword-core-config.xml" },
44   *     allowBeanDefinitionOverriding = "true")
45   * &#64;ContextConfiguration(
46   *     locations = {
47   * 	       "classpath*:mandatory/*.xml",
48   *	       "classpath*:scenarios/db/raw/*.xml",
49   *         ...
50   *         },
51   *     loader = ModuleTestContextLoader.class)
52   * &#64;Transactional
53   * public abstract class AbstractJpaDaoTest
54   * </pre>
55   * The <code>exclusiveConfigLocations</code> parameter is affected by <code>@ContextConfiguration</code>'s
56   * <code>inheritLocations</code> attribute, i.e. the paths to be excluded are overridden or merged depending
57   * on the value of <code>inheritLocations</code>.
58   * <p>
59   * The boolean properties of {@link ModuleApplicationContextConfiguration} have to be specified as String
60   * values which allows one to only specify the properties whose values vary from the values specified in
61   * the superclasses' <code>@ExtendedContextConfiguration</code> specification. 
62   * 
63   * @see ModuleApplicationContextConfiguration
64   *
65   * @svnLink $Revision: 4253 $;$Date: 2010-12-21 11:08:04 +0100 (Di, 21. Dez 2010) $;$Author: swismer $;$URL: https://el4j.svn.sourceforge.net/svnroot/el4j/branches/el4j_3_1/el4j/framework/modules/core/src/test/java/ch/elca/el4j/tests/core/context/ExtendedContextConfiguration.java $
66   *
67   * @author Simon Stelling (SST)
68   */
69  @Documented
70  @Inherited
71  @Retention(RetentionPolicy.RUNTIME)
72  @Target(ElementType.TYPE)
73  public @interface ExtendedContextConfiguration {
74  
75  	/**
76  	 * Exclusive config locations.
77  	 * The default is an empty string array.
78  	 * 
79  	 * Note that the {@link ContextConfiguration#inheritLocations} property
80  	 * affects the behaviour of exclusiveConfigLocations in the same way
81  	 * it affects the {@link ContextConfiguration#locations}.
82  	 */
83  	String[] exclusiveConfigLocations() default { };
84  
85  	/**
86  	 * Indicates if bean definition overriding is enabled.
87  	 * Must be <code>"true"</code> or <code>"false"</code>.
88  	 */
89  	String allowBeanDefinitionOverriding() default "";
90  	
91  	/**
92  	 * Indicates if unordered/unknown resources should be used.
93  	 * Must be <code>"true"</code> or <code>"false"</code>.
94  	 */
95  	String mergeWithOuterResources() default "";
96  	
97  	/**
98  	 * Indicates if the most specific resource should be the last resource
99  	 * in the fetched resource array. If its value is set to <code>true</code>
100 	 * and only one resource is requested the least specific resource will be
101 	 * returned. 
102 	 * Must be <code>"true"</code> or <code>"false"</code>.
103 	 */
104 	String mostSpecificResourceLast() default "";
105 	
106 	/**
107 	 * Indicates if the most specific bean definition counts.
108 	 * Must be <code>"true"</code> or <code>"false"</code>.
109 	 */
110 	String mostSpecificBeanDefinitionCounts() default "";
111 	
112 }