Commit Graph

2374 Commits

Author SHA1 Message Date
Sam Brannen d01d95118b Stop suppressing warnings for deleted deprecations
This commit removes the use of @SuppressWarnings("deprecation") for
code in the spring-test module that no longer references deprecated code.

Issue: SPR-10499
2013-05-06 21:29:49 +02:00
Rossen Stoyanchev e7f38e5b17 Merge branch 'websocket' 2013-05-06 14:46:29 -04:00
Sam Brannen 72d5a32104 Added schema version to test XML config file
This commit adds an explicit version to the updated XML configuration
file in order to avoid build errors in IntelliJ IDEA 12.
2013-05-05 21:50:34 +02:00
Sam Brannen 88e514bd56 Delete deprecated code in the TestContext framework
This commit deletes the deprecated SimpleJdbcTestUtils class as well as
remaining usage of SimpleJdbcTemplate within the TestContext framework
and its test suite.

Issue: SPR-10499
2013-04-28 19:10:53 +02:00
Sam Brannen 2685818e91 Delete deprecated code in the TestContext framework
This commit deletes the deprecated @ExpectedException and
@NotTransactional annotations, supporting code, and related Javadoc and
reference documentation.

Issue: SPR-10499
2013-04-28 17:31:54 +02:00
Sam Brannen eb65b2b083 Delete deprecated code in the TestContext framework
This commit deletes the deprecated JUnit 3.8 support in the TestContext
Framework.

Issue: SPR-10499
2013-04-28 16:05:49 +02:00
Sam Brannen 4525068f56 Remove JUnit 3.8 based test class hierarchy
This commit picks up where 74021b9 left off.
2013-04-28 13:00:09 +02:00
Rossen Stoyanchev 88447e503b Add first cut of SockJS server support 2013-04-15 11:03:24 -04:00
Sam Brannen 41737e827c Remove warning suppression in mocks
This commit removes the suppression of warnings in Servlet and Portlet
mocks since such suppression is no longer necessary with the upgrade to
version 3.0 of the Servlet specification.
2013-03-26 15:15:37 +01:00
Juergen Hoeller deba32cad9 Upgraded all Servlet API mocks to Servlet 3.0 (with a little bit of Servlet 3.1 support in MockHttpServletResponse) 2013-03-20 17:19:34 +01:00
Juergen Hoeller 74021b9e4a Removed JUnit 3.8 based test class hierarchy 2013-03-19 15:10:59 +01:00
Phillip Webb 4e1cab28df Merge branch '3.2.x'
* 3.2.x: (28 commits)
  Hide 'doc' changes from jdiff reports
  Document @Bean 'lite' mode vs @Configuration
  Final preparations for 3.2.2
  Remove Tiles 3 configuration method
  Polishing
  Extracted buildRequestAttributes template method from FrameworkServlet
  Added "beforeExistingAdvisors" flag to AbstractAdvisingBeanPostProcessor
  Minor refinements along the way of researching static CGLIB callbacks
  Compare Kind references before checking log levels
  Polish Javadoc in RequestAttributes
  Fix copy-n-paste errors in NativeWebRequest
  Fix issue with restoring included attributes
  Add additional test for daylight savings glitch
  Document context hierarchy support in the TCF
  Fix test for daylight savings glitch
  Make the methodParameter field of HandlerMethod final
  Disable AsyncTests in spring-test-mvc
  Reformat the testing chapter
  Document context hierarchy support in the TCF
  Document context hierarchy support in the TCF
  ...
2013-03-13 14:01:46 -07:00
Sam Brannen ccdb48210a Document context hierarchy support in the TCF
This commit polishes the Javadoc for @ContextHierarchy and
@ContextConfiguration.

Issue: SPR-10357
2013-03-10 14:26:19 +01:00
Sam Brannen 4e7098dc63 Document context hierarchy support in the TCF
This commit adds examples to the Javadoc for @ContextHierarchy and
updates the Javadoc for @ContextConfiguration accordingly.

Issue: SPR-10357
2013-03-10 01:39:14 +01:00
Rossen Stoyanchev 8e4e0f3531 Use null in MockServletContext for unknown mime types
MockServletContext.getMimeTypes now returns null if the Java Activation
Framework returns "application/octet-stream", which is the default
media type it returns if the mime type is unknown. This enforces the
contract for ServletContext.getMimeTypes (return null for uknown mime
types) but does mean "application/octet-stream" cannot be returned.

Issue: SPR-10334
2013-03-07 12:33:44 -05:00
Sam Brannen 98074e7762 Provide support for context hierarchies in the TCF
Prior to this commit the Spring TestContext Framework supported creating
only flat, non-hierarchical contexts. There was no easy way to create
contexts with parent-child relationships.

This commit addresses this issue by introducing a new @ContextHierarchy
annotation that can be used in conjunction with @ContextConfiguration
for declaring hierarchies of application contexts, either within a
single test class or within a test class hierarchy. In addition,
@DirtiesContext now supports a new 'hierarchyMode' attribute for
controlling context cache clearing for context hierarchies.

- Introduced a new @ContextHierarchy annotation.
- Introduced 'name' attribute in @ContextConfiguration.
- Introduced 'name' property in ContextConfigurationAttributes.
- TestContext is now aware of @ContextHierarchy in addition to
  @ContextConfiguration.
- Introduced findAnnotationDeclaringClassForTypes() in AnnotationUtils.
- Introduced resolveContextHierarchyAttributes() in ContextLoaderUtils.
- Introduced buildContextHierarchyMap() in ContextLoaderUtils.
- @ContextConfiguration and @ContextHierarchy may not be used as
  top-level, class-level annotations simultaneously.
- Introduced reference to the parent configuration in
  MergedContextConfiguration and WebMergedContextConfiguration.
- Introduced overloaded buildMergedContextConfiguration() methods in
  ContextLoaderUtils in order to handle context hierarchies separately
  from conventional, non-hierarchical contexts.
- Introduced hashCode() and equals() in ContextConfigurationAttributes.
- ContextLoaderUtils ensures uniqueness of @ContextConfiguration
  elements within a single @ContextHierarchy declaration.
- Introduced CacheAwareContextLoaderDelegate that can be used for
  loading contexts with transparent support for interacting with the
  context cache -- for example, for retrieving the parent application
  context in a context hierarchy.
- TestContext now delegates to CacheAwareContextLoaderDelegate for
  loading contexts.
- Introduced getParentApplicationContext() in MergedContextConfiguration
- The loadContext(MergedContextConfiguration) methods in
  AbstractGenericContextLoader and AbstractGenericWebContextLoader now
  set the parent context as appropriate.
- Introduced 'hierarchyMode' attribute in @DirtiesContext with a
  corresponding HierarchyMode enum that defines EXHAUSTIVE and
  CURRENT_LEVEL cache removal modes.
- ContextCache now internally tracks the relationships between contexts
  that make up a context hierarchy. Furthermore, when a context is
  removed, if it is part of a context hierarchy all corresponding
  contexts will be removed from the cache according to the supplied
  HierarchyMode.
- AbstractGenericWebContextLoader will set a loaded context as the
  ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE in the MockServletContext when
  context hierarchies are used if the context has no parent or if the
  context has a parent that is not a WAC.
- Where appropriate, updated Javadoc to refer to the
  ServletTestExecutionListener, which was introduced in 3.2.0.
- Updated Javadoc to avoid and/or suppress warnings in spring-test.
- Suppressed remaining warnings in code in spring-test.

Issue: SPR-5613, SPR-9863
2013-03-07 02:11:11 +01:00
Phillip Webb 05765d7520 Replace EasyMock with Mockito
Issue: SPR-10126
2013-03-06 11:06:15 -08:00
Chris Beams ce4be3b46b Merge branch '3.2.x' into master
Conflicts:
	gradle.properties
	spring-beans/src/main/java/org/springframework/beans/factory/support/StaticListableBeanFactory.java
	spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheManagerFactoryBean.java
	spring-core/src/main/java/org/springframework/core/convert/support/StringToEnumConverterFactory.java
	spring-core/src/main/java/org/springframework/core/env/ReadOnlySystemAttributesMap.java
	spring-jdbc/src/main/java/org/springframework/jdbc/datasource/LazyConnectionDataSourceProxy.java
	spring-jdbc/src/main/java/org/springframework/jdbc/support/lob/AbstractLobHandler.java
	spring-web/src/main/java/org/springframework/http/client/BufferingClientHttpRequestWrapper.java
	spring-web/src/main/java/org/springframework/http/client/SimpleBufferingClientHttpRequest.java
	spring-web/src/main/java/org/springframework/http/converter/BufferedImageHttpMessageConverter.java
	spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java
2013-03-04 15:41:15 +01:00
Sam Brannen 381f7fe6df Suppress warnings for resource leaks 2013-02-28 13:48:15 +01:00
Sam Brannen 4bdf382714 Update spring-test re: deprecated queryForInt()
Now invoking JdbcTemplate's queryForObject() method instead
of the deprecated queryForInt() method within the test suite.

Issue: SPR-10257
2013-02-28 13:46:56 +01:00
Sam Brannen 013c894c25 Update JdbcTestUtils re: deprecated queryForInt()
JdbcTestUtils now invokes JdbcTemplate's queryForObject() method instead
of the deprecated queryForInt() method.

Issue: SPR-10257
2013-02-28 01:56:13 +01:00
Sam Brannen 301628811f Update JdbcTestUtils re: deprecated queryForInt()
JdbcTestUtils now invokes JdbcTemplate's queryForObject() method instead
of the deprecated queryForInt() method.

Issue: SPR-10257
2013-02-28 01:36:03 +01:00
Phillip Webb 720714b434 Add JdbcTestUtils.deleteRowsInTableWhere method
Issue: SPR-10302
2013-02-25 11:26:59 -08:00
Phillip Webb f464a45ba4 Polish formatting
Minor formatting polish across that codebase. Primarily fixing
whitespace issues.
2013-02-04 10:35:25 -08:00
Phillip Webb aac6b913d6 Merge branch 'cleanup-3.2.x' into 3.2.x
* cleanup-3.2.x:
  Fix unnecessary @SupressWarnings annotations
  Fix Javadoc warnings
  Fix unused local variable warnings
  Fix unused type compiler warnings
  Fix 'is already an instance of type' warnings
2013-01-31 12:52:51 -08:00
Juergen Hoeller 6a98b40e1c Consistent use of LinkedHashMaps and independent getAttributeNames Enumeration in Servlet/Portlet mocks
Issue: SPR-10224
2013-01-30 14:57:36 +01:00
Sam Brannen 321004143b Improve Javadoc for ContextLoaderUtils
- class-level Javadoc now mentions application context initializers.
- avoided and suppressed warnings in method-level Javadoc.

Issue: SPR-10232
2013-01-29 17:48:14 +01:00
Phillip Webb 6a1e841952 Fix unused type compiler warnings 2013-01-25 14:35:07 -08:00
Phillip Webb 05ba366edc Polish AbstractContextLoader Javadoc
Fix unnecessary HTML escaping from {@code} Javadoc.
2013-01-22 14:36:38 -08:00
Juergen Hoeller 5a773b771d MockHttpServletResponse's getHeaderNames declares Collection instead of Set for Servlet 3.0 compatibility
Issue: SPR-9885
2013-01-22 21:12:03 +01:00
Juergen Hoeller c1a4f5c0fe MockHttpServletRequest's getParameter(Values) returns null for null parameter name
Issue: SPR-10192
2013-01-22 21:12:02 +01:00
Chris Beams c97f26d516 Merge branch 'SPR-9984' into 3.2.x
* SPR-9984:
  Add TimedSpringRunnerTests to performance test group
2013-01-21 12:45:03 +01:00
Chris Beams fc6377cc53 Add TimedSpringRunnerTests to performance test group
Issue: SPR-9984
2013-01-21 12:44:47 +01:00
Sam Brannen 8a37521a3c Fix copyright year & method names in spring-test
This commit fixes the copyright year for changes made in commit
5b147bfba8. In addition, method names
have been changed to reflect the semantic changes made in that same
commit.
2013-01-14 11:40:21 +01:00
Sam Brannen 5b147bfba8 Improve speed of spring-test build
- Now excluding *TestSuite classes from the JUnit test task.
- Renamed SpringJUnit4SuiteTests to SpringJUnit4TestSuite so that it is
  no longer executed in the build.
- Reduced sleep time in various timing related tests.
2013-01-11 21:31:46 +01:00
Sam Brannen 4ae9cf7cf1 Ensure JUnit & TestNG tests run in spring-test
Prior to this commit, the Gradle build configuration only executed
TestNG-based tests and effectively disabled all JUnit-based tests in the
spring-test module. Furthermore, TestNG-based tests were not properly
reported in Bamboo CI builds.

This commit ensures that both JUnit and TestNG tests are executed in the
Gradle build by defining a new testNG task within the spring-test
configuration. The test task now depends on the new testNG task.
Furthermore, the testNG task makes use of Gradle 1.3's support for
generating test reports for TestNG tests alongside reports for JUnit
tests. The net effect is that all tests are executed and reportedly
properly in Bamboo builds on the CI server.

- Enabled both JUnit and TestNG tests for the spring-test module.
- Corrected bugs in FailingBeforeAndAfterMethodsTests introduced in
  commit 3d1b3868fe.
- Deleted the now obsolete SPR-9398.txt file.

Issue: SPR-9398
2013-01-10 16:42:44 +01:00
Chris Beams b836e14b5f Merge branch 'cleanup-test-duplicates' into cleanup-3.2.x
* cleanup-test-duplicates:
  Update Apache license headers for affected sources
  Remove duplicate test classes
  Replace test beans with test objects

Conflicts:
	spring-beans/src/test/java/org/springframework/beans/factory/ConcurrentBeanFactoryTests.java
	spring-beans/src/test/java/org/springframework/beans/support/PagedListHolderTests.java
2013-01-04 10:31:31 +01:00
Phillip Webb 42b5d6dd7e Remove duplicate test classes
Prior to this commit many test utility classes and sample beans were
duplicated across projects. This was previously necessary due to the
fact that dependent test sources were not shared during a gradle
build. Since the introduction of the 'test-source-set-dependencies'
gradle plugin this is no longer the case.

This commit attempts to remove as much duplicate code as possible,
co-locating test utilities and beans in the most suitable project.
For example, test beans are now located in the 'spring-beans'
project.

Some of the duplicated code had started to drift apart when
modifications made in one project where not ported to others. All
changes have now been consolidated and when necessary existing tests
have been refactored to account for the differences.

Conflicts:
	spring-beans/src/test/java/org/springframework/beans/factory/ConcurrentBeanFactoryTests.java
	spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java
	spring-beans/src/test/java/org/springframework/beans/support/PagedListHolderTests.java
2013-01-04 10:02:29 +01:00
Chris Beams 7a737bebdd Merge branch '3.2.x' into master
* 3.2.x:
  Fix ClassCastException when setting media types
  Enable execution of TestNG tests in spring-test
  Polish support for topic branch-specific versions
  Segregate add'l long-running and performance tests
  Eliminate EBR dependencies and repository config
  Skip creation of IDEA metadata for spring-aspects
  Fix Eclipse compilation error in Gradle plugin
  Polish build.gradle
  Fix null parameterName issue in content negotiation
  Recursively add test dependencies
2013-01-03 22:31:52 +01:00
Chris Beams 3cbb136861 Enable execution of TestNG tests in spring-test
Both JUnit- and TestNG-based tests are once again executed in the
spring-test module.

Note that two lines in FailingBeforeAndAfterMethodsTests had to be
commented out. See diff or `git grep 'See SPR-8116'` for details.

Issue: SPR-8116
2013-01-03 19:34:29 +01:00
Chris Beams 961dbdb68a Merge branch '3.2.x' into master
* 3.2.x:
  Exclude spring-build-src from maven publish
  Move spring-build-junit into spring-core
  Relocate MergePlugin package
  Develop a gradle plugin to add test dependencies
  Expose Gradle buildSrc for IDE support
  Fix [deprecation] compiler warnings
  Upgrade to xmlunit version 1.3
  Improve 'build' folder ignores
  Fix regression in static setter method support
  Fix SpEL JavaBean compliance for setters

Conflicts:
	spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java
2013-01-02 10:36:57 +01:00
Chris Beams 70eaf02b7f Revert "Merge branch 'SPR-10130' into cleanup-master"
This reverts commit 45fa50821a, reversing
changes made to a312d900f8.
2013-01-02 10:33:59 +01:00
Phillip Webb 6626a38730 Fix [deprecation] compiler warnings
Fix deprecation compiler warnings by refactoring code or applying
@SuppressWarnings("deprecation") annotations. JUnit tests of
internally deprecated classes are now themselves marked as
@Deprecated.

Numerous EasyMock deprecation warnings will remain until the
migration to mockito can be completed.
2013-01-01 13:42:15 -08:00
Chris Beams b2a048b6f3 Update Apache license headers for affected sources 2012-12-28 23:57:33 +01:00
Chris Beams 3b40ce76bf Add @Override annotations to main sources
Issue: SPR-10130
2012-12-28 23:53:24 +01:00
Chris Beams 8472a2b2ab Update Apache license headers for affected sources 2012-12-28 23:09:31 +01:00
Chris Beams 4c8cd7b0bd Add @Override annotations to test sources
Issue: SPR-10129
2012-12-28 23:05:44 +01:00
Chris Beams 4c7cafbde6 Fix "unnecessary @SuppressWarnings" warnings 2012-12-28 22:50:46 +01:00
Phillip Webb 6c14eaad61 Fix [cast] compiler warnings 2012-12-28 22:41:06 +01:00
Chris Beams 9540d2c81b Replace <code> with {@code} throughout Javadoc
Issue: SPR-10128
2012-12-28 22:36:02 +01:00
Phillip Webb 2cf45bad86 Replace space indentation with tabs
Issue: SPR-10127
2012-12-28 20:49:56 +01:00
Phillip Webb 1762157ad1 Remove trailing whitespace in source files
find . -type f -name "*.java" -or -name "*.aj" | \
    xargs perl -p -i -e "s/[ \t]*$//g" {} \;

Issue: SPR-10127
2012-12-28 20:49:45 +01:00
Juergen Hoeller b9df7d68d9 Consistent fine-tuning of synchronized and concurrent data structures
In particular, avoiding synchronized Sets and Maps wherever possible (preferring a ConcurrentHashMap even instead of a synchronized Set) and specifying appropriate ConcurrentHashMap initial capacities (even if we end up choosing 16).
2012-12-12 23:46:26 +01:00
Chris Beams f26534700a Eliminate all Javadoc warnings
- Support external Javadoc links using Gradle's javadoc.options.links

 - Fix all other Javadoc warnings, such as typos, references to
   non-existent (or no longer existent) types and members, etc,
   including changes related to the Quartz 2.0 upgrade (SPR-8275) and
   adding the HTTP PATCH method (SPR-7985).

 - Suppress all output for project-level `javadoc` tasks in order to
   hide false-negative warnings about cross-module @see and @link
   references (e.g. spring-core having a @see reference to spring-web).
   Use the `--info` (-i) flag to gradle at any time to see project-level
   javadoc warnings without running the entire `api` task. e.g.
   `gradle :spring-core:javadoc -i`

 - Favor root project level `api` task for detection of legitimate
   Javadoc warnings. There are now zero Javadoc warnings across the
   entirety of spring-framework. Goal: keep it that way.

 - Remove all @link and @see references to types and members that exist
   only in Servlet <= 2.5 and Hibernate <= 4.0, favoring 3.0+ and 4.0+
   respectively. This is necessary because only one version of each of
   these dependencies can be present on the global `api` javadoc task's
   classpath. To that end, the `api` task classpath has now been
   customized to ensure that the Servlet 3 API and Hibernate Core 4 jars
   have precedence.

 - SPR-8896 replaced our dependency on aspectjrt with a dependency on
   aspectjweaver, which is fine from a POM point of view, but causes
   a spurious warning to be emitted from the ant iajc task that it
   "cannot find aspectjrt on the classpath" - even though aspectjweaver
   is perfectly sufficient. In the name of keeping the console quiet, a
   new `rt` configuration has been added, and aspectjrt added as a
   dependency to it. In turn, configurations.rt.asPath is appended to
   the iajc classpath during both compileJava and compileTestJava for
   spring-aspects.

Issue: SPR-10078, SPR-8275, SPR-7985, SPR-8896
2012-12-12 12:55:10 +01:00
Sam Brannen a6387dc725 Document WebApplicationContext support in the TCF
This commit adds Javadoc documentation for the WebApplicationContext
testing support that was recently introduced in the Spring TestContext
Framework.

Issue: SPR-9864
2012-12-11 01:58:10 +01:00
Sam Brannen a436a57503 Move tests to spring-test module
When Spr9799XmlConfigTests and Spr9799AnnotationConfigTests were
created, there were issues with the classpath related to slf4j
dependencies that made it impossible for these classes to reside in the
spring-test module. Consequently, these tests were added to the
spring-test-mvc module. However, the issues with slf4j have since been
resolved in the Gradle build, and this commit therefore moves these test
classes to the spring-test module where they belong.

Issue: SPR-9799
2012-12-08 14:26:47 +01:00
Sam Brannen 69ace01640 Clean up warnings in spring-test
- Deleted unused imports.

 - Switched from junit.framework.Assert to org.junit.Assert, since the
   former is deprecated as of JUnit 4.11.

 - Suppressed warnings for continued deprecated usage of
   junit.framework.Assert.
2012-12-07 12:26:27 +01:00
Sam Brannen d0f687f028 Support comments in statements in JdbcTestUtils
Prior to this commit, executing an SQL script with JdbcTestUtils would
fail if a statement in the script contained a line comment within the
statement.

This commit ensures that standard SQL comments (i.e., any text beginning
with two hyphens and extending to the end of the line) are properly
omitted from the statement before executing it.

In addition, multiple adjacent whitespace characters within a statement
but outside a literal are now collapsed into a single space.

Issue: SPR-9982
2012-12-05 16:58:26 +01:00
Sam Brannen 025d111efc Re-enable and document @Ignore'd tests
Documented why static nested test cases in the spring-test module are
ignored, explaining that such "TestCase classes are run manually by the
enclosing test class". Prior to the migration to Gradle (i.e., with
Spring Build), these tests would not have been picked up by the test
suite since they end with a "TestCase" suffix instead of "Test" or
"Tests".

Re-enabled HibernateMultiEntityManagerFactoryIntegrationTests.

For the remaining tests that were disabled as a result of the migration
to Gradle, comments have been added to the @Ignore declarations.

Issue: SPR-8116, SPR-9398
2012-12-05 10:31:31 +01:00
Sam Brannen 19d7cedcf2 Fix classpaths regarding slf4j versions
- Defined global slf4jVersion as '1.6.1' in the Gradle build.

 - Replaced dependencies on slf4j-log4j12 with slf4j-jcl where possible;
   however, spring-test-mvc still depends on jcl-over-slf4j and
   slf4j-log4j12 (see SPR-10070).

 - Reenabled HibernateSessionFlushingTests.

 - Verified that the following tests pass in the Gradle build and within
   Eclipse:
   - HibernateSessionFlushingTests
   - HibernateTransactionManagerTests (Hibernate 3)
   - HibernateTransactionManagerTests (Hibernate 4)
   - RequestResponseBodyMethodProcessorTests

Issue: SPR-9421, SPR-10066
2012-12-04 19:52:37 +01:00
Sam Brannen 57e6e0881d Introduce isExecuted() in MockClientHttpRequest
This commit introduces the missing isExecuted() method in
MockClientHttpRequest and improves the documentation for execute()
and executeInternal().
2012-12-04 01:03:20 +01:00
Sam Brannen d0503ab733 Relocate web artifacts in the TCF to web package
This commit relocates recently introduced web artifacts in the
TestContext framework to the ~.test.context.web package and renames some
classes for consistency with the existing code base.

 - introduced package-info.java in the web package.

 - ServletTestExecutionListener now extends
   AbstractTestExecutionListener instead of implementing
   TestExecutionListener.

 - relocated AbstractGenericWebContextLoader,
   AnnotationConfigWebContextLoader, XmlWebContextLoader, and
   WebDelegatingSmartContextLoader to the web package.

 - renamed XmlWebContextLoader to GenericXmlWebContextLoader for
   consistency with GenericXmlContextLoader.

 - changed the visibility of AbstractDelegatingSmartContextLoader and
   AnnotationConfigContextLoaderUtils to public.

Issue: SPR-10067
2012-12-03 23:29:10 +01:00
Sam Brannen e0e3143dd5 Fix Javadoc errors in TransactionalTEL
This commit fixes recently introduced formatting errors in the Javadoc
of TransactionalTestExecutionListener.
2012-12-03 22:52:19 +01:00
Rossen Stoyanchev 3a50dafc90 Add MockMvcClientHttpRequestFactory
Issue: SPR-9917
2012-11-26 14:23:12 -05:00
Sam Brannen f5080f7d70 Suppress warnings for java.io.Closeable resources
Issue: SPR-9962
2012-11-10 19:22:26 +01:00
Sam Brannen f833366a7f Update package-info for test.util package 2012-11-10 19:08:18 +01:00
Rossen Stoyanchev 4812fcccc4 Remove dependency on hamcrest-lib from spring-mvc-test
The change removes the use of concrete Matcher implementations and thus
the dependency on hamcrest-lib leaving hamcrest-core as the only
(optional) hamcrest dependency.

Issue: SPR-9961
2012-11-07 17:06:56 -05:00
Rossen Stoyanchev 242bf7c4e3 Refine hamcrest dependency in spring-test-mvc project
1) removed the hamcrest-all dependency requirement and replaced it with
the more focused hamcrest-library dependency

2) added MatcherAssertionErrors as a replacement of
org.hamcrest.MatcherAssert, which in hamcrest 1.1 is only available
through the hamcrest-all dependency (and not in hamcrest-core nor in
the hamcrest embedded in JUnit 4.4 through 4.8)

3) changed the required hamcrest version from 1.1 to 1.3 and made sure
the spring-test-mvc project does not rely on newer hamcrest
functionality without checking if it is available first

Applications that already depend on older versions of hamcrest
(in particular 1.1) via hamcrest-library, hamcrest-all or as part of
junit 4.4 through 4.8 should not be disrupted if they add spring-test
but may wish to exclude the hamcrest-library transitive dependency
from spring-test in order to avoid extra jars in the classpath

Applications that depend on hamcrest 1.3 should not have to do anything

Issue: SPR-9940
2012-11-01 23:58:50 -04:00
Sam Brannen 404ea7adcf Polish Javadoc in ContextLoaderUtils 2012-10-28 19:15:10 +01:00
Sam Brannen d4e7d19237 Consistent class loading in ContextLoaderUtils 2012-10-28 16:23:49 +01:00
Sam Brannen 461d99af29 Fix package cycles in spring-test
Code introduced in conjunction with SPR-5243 introduced package cycles
between the ~.test.context and ~.test.context.web packages. This was
caused by the fact that ContextLoaderUtils worked directly with the
@WebAppConfiguration and WebMergedContextConfiguration types.

To address this, the following methods have been introduced in
ContextLoaderUtils. These methods use reflection to circumvent hard
dependencies on the @WebAppConfiguration and
WebMergedContextConfiguration types.

 - loadWebAppConfigurationClass()
 - buildWebMergedContextConfiguration()

Issue: SPR-9924
2012-10-28 00:13:01 +02:00
Sam Brannen 33d5b011d3 Reduce code duplication in ContextLoaderUtils
Prior to this commit, the following two methods in ContextLoaderUtils
contained almost identical loops for traversing the test class
hierarchy:

 - resolveContextLoaderClass(Class<?>, String)
 - resolveContextConfigurationAttributes(Class<?>)

With this commit, resolveContextLoaderClass() no longer traverses the
class hierarchy. Instead, it now works directly with the resolved list
of ContextConfigurationAttributes, thereby removing code duplication.

Issue: SPR-9918
2012-10-27 22:29:55 +02:00
Sam Brannen 90c5f226b6 Fix package cycles in spring-test
Code introduced in conjunction with SPR-5243 introduced package cycles
between the ~.test.context.web and ~.test.context.support packages. This
was caused by the fact that ServletTestExecutionListener extended
AbstractTestExecutionListener.

To address this, ServletTestExecutionListener now implements
TestExecutionListener directly.

Issue: SPR-9924
2012-10-27 20:42:06 +02:00
Sam Brannen 591aa01741 Configurable locales in MockHttpServletRequest
Prior to this commit the MockHttpServletRequest constructor chain set
the preferred local to Locale.ENGLISH. Furthermore, it was possible to
add additional preferred locales "in front" of ENGLISH; however, it was
not possible to delete ENGLISH from the list of preferred locales.

This commit documents the fact that ENGLISH is the default preferred
locale and makes it possible to set the list of preferred locales via a
new setPreferredLocales(List<Locale> locales) method.

Issue: SPR-9724
2012-10-27 18:13:13 +02:00
Sam Brannen 7d9c823a15 Delete unused imports 2012-10-27 17:32:51 +02:00
Sam Brannen 4aaf014cc6 Support comments in SQL scripts in JdbcTestUtils
Prior to this commit, utility methods in JdbcTestUtils interpreted SQL
comments as separate statements, resulting in an exception when such a
script is executed.

This commit addresses this issue by introducing a
readScript(lineNumberReader, String) method that accepts a comment
prefix. Comment lines are therefore no longer returned in the parsed
script. Furthermore, the existing readScript(lineNumberReader) method
now delegates to this new readScript() method, supplying "--" as the
default comment prefix.

Issue: SPR-9593
2012-10-22 00:52:01 -04:00
Sam Brannen 7c538bd588 Rename WebTEL to ServletTEL
Renamed WebTestExecutionListener to ServletTestExecutionListener.
2012-10-19 20:29:20 -04:00
Sam Brannen ff8a6e8fdb Remove code duplication in ModelAndViewAssert
ModelAndViewAssert now uses assertion methods in the newly
introduced AssertionErrors class.
2012-10-19 20:19:03 -04:00
Rossen Stoyanchev 0a10f95e18 Shorten package name for Spring MVC Test framework 2012-10-18 14:20:45 -04:00
Sam Brannen 300d41840b Fix JDK7 method order-dependent issues in SRCCT
SpringRunnerContextCacheTests suffers from JDK7-related non-determinism
in values returned from Class#getDeclaredMethods(), which in turn
affects JUnit and its execution of @Test methods.

This commit addresses this issue by introducing an
OrderedMethodsSpringJUnit4ClassRunner that sorts the test methods
alphabetically, which is actually required for
SpringRunnerContextCacheTests to work properly.

Issue: SPR-9789
2012-10-13 20:29:59 +02:00
Sam Brannen 21ebbb9c02 Support session & request scoped beans in the TCF
This commit introduces RequestAndSessionScopedBeansWacTests which
verifies support for request and session scoped beans in the Spring
TestContext Framework (TCF).

This support was actually introduced as an intentional side effect of
the work performed for SPR-5243 through the addition of the new 
WebTestExecutionListener.

Issue: SPR-4588
2012-10-13 19:50:31 +02:00
Sam Brannen 0bb24f2922 Update documentation TODOs
Issue: SPR-9864
2012-10-13 18:43:50 +02:00
Sam Brannen a73280ccc8 Support loading WebApplicationContexts in the TCF
Prior to this commit, the Spring TestContext Framework only supported
loading an ApplicationContext in integration tests from either XML or
Java Properties files (since Spring 2.5), and Spring 3.1 introduced
support for loading an ApplicationContext in integration tests from
annotated classes (e.g., @Configuration classes). All of the
ContextLoader implementations used to provide this support load a
GenericApplicationContext. However, a GenericApplicationContext is not
suitable for testing a web application since a web application relies on
an implementation of WebApplicationContext (WAC).

This commit makes it possible to integration test Spring-powered web
applications by adding the following functionality to the Spring
TestContext Framework.

 - Introduced AbstractGenericWebContextLoader and two concrete
   subclasses:
   - XmlWebContextLoader
   - AnnotationConfigWebContextLoader

 - Pulled up prepareContext(context, mergedConfig) from
   AbstractGenericContextLoader into AbstractContextLoader to allow it
   to be shared across web and non-web context loaders.

 - Introduced AnnotationConfigContextLoaderUtils and refactored
   AnnotationConfigContextLoader accordingly. These utils are also used
   by AnnotationConfigWebContextLoader.

 - Introduced a new @WebAppConfiguration annotation to denote that the
   ApplicationContext loaded for a test should be a WAC and to configure
   the base resource path for the root directory of a web application.

 - Introduced WebMergedContextConfiguration which extends
   MergedContextConfiguration with support for a baseResourcePath for
   the root directory of a web application.

 - ContextLoaderUtils.buildMergedContextConfiguration() now builds a
   WebMergedContextConfiguration instead of a standard
   MergedContextConfiguration if @WebAppConfiguration is present on the
   test class.

 - Introduced a configureWebResources() method in
   AbstractGenericWebContextLoader that is responsible for creating a
   MockServletContext with a proper ResourceLoader for the
   resourceBasePath configured in the WebMergedContextConfiguration. The
   resulting mock ServletContext is set in the WAC, and the WAC is
   stored as the Root WAC in the ServletContext.

 - Introduced a WebTestExecutionListener that sets up default thread
   local state via RequestContextHolder before each test method by using
   the MockServletContext already present in the WAC and by creating a
   MockHttpServletRequest, MockHttpServletResponse, and
   ServletWebRequest that is set in the RequestContextHolder. WTEL also
   ensures that the MockHttpServletResponse and ServletWebRequest can be
   injected into the test instance (e.g., via @Autowired) and cleans up
   thread locals after each test method.

 - WebTestExecutionListener is configured as a default
   TestExecutionListener before DependencyInjectionTestExecutionListener

 - Extracted AbstractDelegatingSmartContextLoader from
   DelegatingSmartContextLoader and introduced a new
   WebDelegatingSmartContextLoader.

 - ContextLoaderUtils now selects the default delegating ContextLoader
   class name based on the presence of @WebAppConfiguration on the test
   class.

 - Tests in the spring-test-mvc module no longer use a custom
   ContextLoader to load a WebApplicationContext. Instead, they now
   rely on new core functionality provided in this commit.

Issue: SPR-5243
2012-10-08 00:23:19 +02:00
Rossen Stoyanchev 5c13739afa Add mock implementations of Http[Input|Output]Message 2012-09-27 17:07:14 -04:00
Rossen Stoyanchev 4566db82f5 Polish MockFilterChain
A reset method now allows it to be invoked more than once each time
storing the request and response with which it was invoked.
2012-09-27 12:06:35 -04:00
Chris Beams c4aa14f343 Ignore SpringRunnerContextCacheTests
Avoid order-dependent test method failures on JDK7

Issue: SPR-9789
2012-09-11 23:54:35 +02:00
Chris Beams dfe05305e2 Upgrade to JUnit 4.11 snapshot in support of JDK7
Class#getDeclaredMembers returns arbitrary results under JDK7. This
results in non-deterministic execution of JUnit test methods, often
revealing unintended dependencies between methods that rely on a
specific order to succeed.

JUnit 4.11 contains support for predictable test ordering [1], but at
the time of this commit, JUnit 4.11 has not yet been released.
Therefore we are testing against a snapshot version [2], which has been
uploaded to repo.springsource.org [3] for easy access. Note that this
artifact may be removed when JUnit 4.11 goes GA.

 - Care has been taken to ensure that spring-test's compile-time
   dependency on JUnit remains at 4.10. This means that the spring-test
   pom.xml will continue to have an optional <dependency> on JUnit
   4.10, instead of the 4.11 snapshot.

 - For reasons not fully understood, the upgrade to the 4.11 snapshot
   of junit-dep caused NoSuchMethodErrors around certain Hamcrest
   types, particularly CoreMatchers and Matchers. import statements
   have been updated accordingly throughout affected test cases.

 - Runtime errors also occurred around uses of JUnit @Rule and
   ExpectedException. These have been reverted to use simpler
   mechanisms like @Test(expected) in the meantime.

 - Some test methods with order-based dependencies on one another have
   been renamed in order to fall in line with JUnit 4.11's new method
   ordering (as opposed to actually fixing the inter-test
   dependencies). In other areas, the fix was as simple as adding a
   tearDown method and cleaning up state.

 - For no apparent reason, the timeout in AspectJAutoProxyCreatorTests'
   testAspectsAndAdvisorNotAppliedToPrototypeIsFastEnough method begins
   to be exceeded. Prior to this commit the timeout value was 3000 ms;
   on the CI server under Linux/JDK6 and JDK7, the test begins taking
   anywhere from 3500-5500 ms with this commit. It is presumed that
   this is an incidental artifact of the upgrade to JUnit 4.11. In any
   case, there are no changes to src/main in this commit, so this
   should not actually represent a performance risk for Spring
   Framework users. The timeout has been increased to 6000 ms to
   accommodate this situation.

[1]: https://github.com/KentBeck/junit/pull/293
[2]: https://github.com/downloads/KentBeck/junit/junit-dep-4.11-SNAPSHOT-20120805-1225.jar
[3]: https://repo.springsource.org/simple/ext-release-local/junit/junit-dep/4.11.20120805.1225

Issue: SPR-9783
2012-09-11 15:04:56 +02:00
Phillip Webb a9a90cabad Protect against non-deterministic method order in JDK7
- Allow reset of GlobalAdvisorAdapterRegistry

   Provide a reset() method allowing the GlobalAdvisorAdapterRegistry
   instance to be replaced with a fresh instance. This method has
   primarily been added to allow unit tests to leave the registry
   in a known state.

 - Protect against the fact that calls to configuration class methods
   my occur in a random order.

Issue: SPR-9779
2012-09-11 15:04:55 +02:00
Rob Winch c92a06f003 Support Filters/Servlet invocation in MockFilterChain
This commit adds the ability to allow the MockFilterChain to invoke
a List of Filter's and/or a Servlet.

Issue: SPR-9745
2012-09-05 01:30:46 -04:00
Juergen Hoeller 50df4d08c2 adapted to deprecation backport in 3.1.3
Issue: SPR-9664
2012-08-31 16:52:28 +02:00
Sam Brannen 3794f995ba Avoid and/or suppress warnings in spring-test 2012-08-25 15:34:26 +02:00
Sam Brannen 1f93777bbd Support ApplicationContextInitializers in the TCF
Starting with Spring 3.1 applications can specify
contextInitializerClasses via context-param and init-param in web.xml;
however, there is currently no way to have such initializers invoked in
integration testing scenarios without writing a custom
SmartContextLoader. For comprehensive integration testing it should
therefore be possible to re-use ApplicationContextInitializers in the
Spring TestContext Framework as well.

This commit makes this possible at the @ContextConfiguration level by
allowing an array of ACI types to be specified, and the out-of-the-box
SmartContextLoader implementations invoke the declared initializers at
the appropriate time.

 - Added initializers and inheritInitializers attributes to
   @ContextConfiguration.

 - Introduced support for ApplicationContextInitializers in
   ContextConfigurationAttributes, MergedContextConfiguration, and
   ContextLoaderUtils.

 - MergedContextConfiguration stores context initializer classes as a
   Set and incorporates them into the implementations of hashCode() and
   equals() for proper context caching.

 - ApplicationContextInitializers are invoked in the new
   prepareContext(GenericApplicationContext, MergedContextConfiguration)
   method in AbstractGenericContextLoader, and ordering declared via the
   Ordered interface and @Order annotation is honored.

 - Updated DelegatingSmartContextLoader to support initializers.
   Specifically, a test class may optionally declare neither XML
   configuration files nor annotated classes and instead declare only
   application context initializers. In such cases, an attempt will
   still be made to detect defaults, but their absence will not result
   an an exception.

 - Documented support for application context initializers in Javadoc
   and in the testing chapter of the reference manual.

Issue: SPR-9011
2012-08-20 15:31:46 +02:00
Sam Brannen 3b9833c538 Update MockHttpSession across the test suite 2012-08-16 13:38:51 +02:00
Sam Brannen 8059625670 Implement invalidate() properly in MockHttpSession
The invalidate() method in MockHttpSession is currently implemented
incorrectly. According to the Servlet specification, the method should
throw an IllegalStateException if it is invoked on an already
invalidated session. However, invoking invalidate() on the same
MockHttpSession instance multiple times does not throw an exception.

This commits addresses this issue by checking the invalid field and
throwing an IllegalStateException if it has already been set to true.

Issue: SPR-9686
2012-08-16 13:14:35 +02:00
Sam Brannen df961a938e RTU.setField() shouldn't call toString() on target
ReflectionTestUtils.setField() implicitly calls toString() on the target
object when arguments for a call to Assert.notNull() are built. This can
have undesirable side effects, for example if the toString() invocation
results in a thrown exception or access to an external system (e.g., a
database).

This commit addresses this issue by inlining the Assert.notNull() code,
thereby avoiding accidental invocation of toString() on a non-null
target.

Issue: SPR-9571
2012-08-10 16:44:55 +02:00
Sam Brannen 5710cf5ed2 Reduce log level to DEBUG when @TELs isn't present
The default set of TestExecutionListeners is sufficient in most
integration testing scenarios; however, the TestContextManager
nonetheless logs an INFO message if the @TestExecutionListeners
annotation is not present on an integration test class.

In order to avoid flooding the logs with messages about the absence of
@TestExecutionListeners, this commit reduces the log level for such
messages from INFO to DEBUG.

Issue: SPR-8645
2012-08-10 15:16:27 +02:00
Sam Brannen 015086cb9c Introduce new methods in tx base test classes
Recently new utility methods were added to JdbcTestUtils, and a
JdbcTemplate was introduced in abstract transactional base classes in
the TestContext framework. This presents an easy opportunity to make
these new utility methods available as convenience methods in the base
test classes.

This commit introduces new countRowsInTableWhere() and dropTables()
convenience methods in the abstract transactional base classes in the
TestContext framework. These new methods internally delegate to methods
of the same names in JdbcTestUtils.

Issue: SPR-9665
2012-08-03 22:50:39 +02:00
Sam Brannen 8d9637ada6 Provide JdbcTemplate in tx base classes in the TCF
Since Spring 2.5, the abstract transactional base classes in the
TestContext framework have defined and delegated to a protected
SimpleJdbcTemplate instance variable; however, SimpleJdbcTemplate has
deprecated since Spring 3.1. Consequently, subclasses of
AbstractTransactionalJUnit4SpringContextTests and
AbstractTransactionalTestNGSpringContextTests that use this instance
variable suffer from seemingly unnecessary deprecation warnings.

This commit addresses this issue by introducing a protected JdbcTemplate
instance variable in abstract transactional base classes to replace the
use of the existing SimpleJdbcTemplate. Furthermore, the existing
simpleJdbcTemplate instance variable has been deprecated, and utility
methods in the affected base classes now delegate to JdbcTestUtils
instead of the now deprecated SimpleJdbcTestUtils.

Issue: SPR-8990
2012-08-03 21:59:05 +02:00
Ian Brandt bd0c4b4d99 Deprecate SimpleJdbcTestUtils in favor of JdbcTestUtils
Several static utility methods in SimpleJdbcTestUtils accept an instance
of SimpleJdbcTemplate as an argument; however, SimpleJdbcTemplate has
been deprecated since Spring 3.1 in favor of simply using JdbcTemplate
which now also supports Java 5 language constructs such as var-args.
Consequently, use of such methods from SimpleJdbcTestUtils results in
deprecation warnings without an equivalent API to migrate to.

This commit addresses this issue by migrating all existing methods in
SimpleJdbcTestUtils to JdbcTestUtils. The migrated methods now accept an
instance of JdbcTemplate as an argument, thereby avoiding the
deprecation warnings but maintaining semantic compatibility with the
functionality previous available in SimpleJdbcTestUtils.

In addition, this commit also introduces two new methods:

 - countRowsInTableWhere(): counts the rows in a given table, using
   a provided `WHERE` clause
 - dropTables(): drops the tables with the specified names

Issue: SPR-9235
2012-08-03 20:55:09 +02:00
Sam Brannen f49b22c78f Introduce MockEnvironment in the spring-test module
For legacy reasons, a MockEnvironment implementation already exists in multiple places within Spring's test suite; however, it is not available to the general public.

This commit promotes MockEnvironment to a first-class citizen in the spring-test module, alongside the existing MockPropertySource.

In addition, the following house cleaning has been performed.

 - deleted MockPropertySource from the spring-expression module
 - deleted MockEnvironment from the "spring" integration testing module
 - updated test copies of MockPropertySource and MockEnvironment
 - documented MockEnvironment and MockPropertySource in the testing
   chapter of the reference manual

Issue: SPR-9492
2012-07-28 20:10:21 +02:00
Sam Brannen 2b7a629068 Support TransactionManagementConfigurer in the TCF
Currently the Spring TestContext Framework looks up a
PlatformTransactionManager bean named "transactionManager". The exact
name of the bean can be overridden via @TransactionConfiguration or
@Transactional; however, the bean will always be looked up 'by name'.

The TransactionManagementConfigurer interface that was introduced in
Spring 3.1 provides a programmatic approach to specifying the
PlatformTransactionManager bean to be used for annotation-driven
transaction management, and that bean is not required to be named
"transactionManager". However, as of Spring 3.1.2, using the
TransactionManagementConfigurer on a @Configuration class has no effect
on how the TestContext framework looks up the transaction manager.
Consequently, if an explicit name or qualifier has not been specified,
the bean must be named "transactionManager" in order for a transactional
integration test to work.

This commit addresses this issue by refactoring the
TransactionalTestExecutionListener so that it looks up and delegates to
a single TransactionManagementConfigurer as part of the algorithm for
determining the transaction manager.

Issue: SPR-9604
2012-07-28 01:24:32 +02:00
Sam Brannen f21fe33e74 Support single, unqualified tx manager in the TCF
TransactionalTestExecutionListener currently requires that the
PlatformTransactionManager bean be named "transactionManager" by
default. Otherwise, the bean name can only be overridden via the
transactionManager attribute of @TransactionConfiguration or the value
attribute of @Transactional.

However, if there is only a single PlatformTransactionManager in the
test's ApplicationContext, then the requirement to specify the exact
name of that bean (or to name it exactly "transactionManager") is often
superfluous.

This commit addresses this issue by refactoring the
TransactionalTestExecutionListener so that it is comparable to the
algorithm for determining the transaction manager used in
TransactionAspectSupport for "production" code. Specifically, the TTEL
now uses the following algorithm to retrieve the transaction manager.

 - look up by type and qualifier from @Transactional
 - else, look up by type and explicit name from
   @TransactionConfiguration
 - else, look up single bean by type
 - else, look up by type and default name from @TransactionConfiguration

Issue: SPR-9645
2012-07-28 00:06:46 +02:00
Sam Brannen 37dc211f58 Support named dispatchers in MockServletContext
Currently the getNamedDispatcher(String) method of MockServletContext
always returns null. This poses a problem in certain testing scenarios
since one would always expect at least a default Servlet to be present.
This is specifically important for web application tests that involve
the DefaultServletHttpRequestHandler which attempts to forward to the
default Servlet after retrieving it by name. Furthermore, there is no
way to register a named RequestDispatcher with the MockServletContext.

This commit addresses these issues by introducing the following in
MockServletContext.

 - a new defaultServletName property for configuring the name of the
   default Servlet, which defaults to "default"
 - named RequestDispatchers can be registered and unregistered
 - a MockRequestDispatcher is registered for the "default" Servlet
   automatically in the constructor
 - when the defaultServletName property is set to a new value the
   the current default RequestDispatcher is unregistered and replaced
   with a MockRequestDispatcher for the new defaultServletName

Issue: SPR-9587
2012-07-26 03:06:07 +02:00
Sam Brannen 060b37ca8d Fix typo in MockFilterChain 2012-07-25 01:03:33 +02:00
Rob Winch 59d80ec19e Fix minor issue in MockHttpServletRequest
Previously MockHttpServletRequest#sendRedirect did not set the HTTP status
or the Location header. This does not conform to the HttpServletRequest
interface.

MockHttpServletRequest will now:

  - Set the HTTP status to 302 on sendRedirect
  - Set the Location header on sendRedirect
  - Ensure the Location header and getRedirectedUrl are kept in synch

Issue: SPR-9594
2012-07-16 12:23:28 -04:00
Sam Brannen 726655af50 Fix outdated Javadoc in the TestContext framework
Fixed outdated Javadoc regarding support for 'annotated classes' in
the TestContext Framework.
2012-06-19 12:52:24 +02:00
Sam Brannen 04a6827290 Reproduce claims raised in SPR-8849
This commit introduces a test suite (Spr8849Tests) that demonstrates
the claims made in SPR-8849.

Specifically, if <jdbc:embedded-database id="xyz" /> is used to create
an embedded HSQL database in an XML configuration file and that
configuration file is imported in different sets of configuration files
that are used to load ApplicationContexts for different integration
tests, the embedded database will be initialized multiple times using
any nested <jdbc:script /> elements. If such a script is used to create
a table, for example, subsequent attempts to initialize the database
named "xyz" will fail since an embedded database named "xyz" already
exists in the JVM.

As a work-around, this test suite uses a SpEL expression to generate a
random string for each embedded database instance:

  id="#{T(java.util.UUID).randomUUID().toString()}"

See the Javadoc in Spr8849Tests for further information.

Issue: SPR-8849
2012-06-10 00:31:05 +02:00
Chris Beams a4b00c732b Introduce BeanFactoryAnnotationUtils
Commit 096693c46f refactored and
deprecated TransactionAspectUtils, moving its #qualifiedBeanOfType
and related methods into BeanFactoryUtils. This created a package cycle
between beans.factory and beans.factory.annotation due to use of the
beans.factory.annotation.Qualifier annotation in these methods.

This commit breaks the package cycle by introducing
beans.factory.annotation.BeanFactoryAnnotationUtils and moving these
@Qualifier-related methods to it. It is intentionally similar in name
and style to the familiar BeanFactoryUtils class for purposes of
discoverability.

There are no backward-compatibilty concerns associated with this change
as the cycle was introduced, caught and now fixed before a release.

Issue: SPR-6847
2012-05-26 14:22:57 +03:00
Chris Beams 096693c46f Refactor and deprecate TransactionAspectUtils
TransactionAspectUtils contains a number of methods useful in
retrieving a bean by type+qualifier. These methods are functionally
general-purpose save for the hard coding of PlatformTransactionManager
class literals throughout.

This commit generifies these methods and moves them into
BeanFactoryUtils primarily in anticipation of their use by async method
execution interceptors and aspects when performing lookups for qualified
executor beans e.g. via @Async("qualifier").

The public API of TransactionAspectUtils remains backward compatible;
all methods within have been deprecated, and all calls to those methods
throughout the framework refactored to use the new BeanFactoryUtils
variants instead.
2012-05-20 15:15:13 +03:00
Sam Brannen e71cd06a46 Doc. usage of JSR-250 lifecycle annotations in TCF
The reference manual previously did not mention the applicability of
JSR-250 lifecycle annotations within the TestContext framework. The
lacking documentation here has lead to misunderstandings of the support
provided for @PostConstruct and @PreDestroy in test classes.

The testing chapter of the reference manual has therefore been updated
to explicitly define the limited support for these annotations.

Also introduced Jsr250LifecycleTests for empirical verification of the 
expected behavior.

Issue: SPR-4868
2012-05-19 04:03:40 +02:00
Sam Brannen dc6b2abe46 Verify scope support for 'lite' @Beans in the TCF
Introduced AtBeanLiteModeScopeTests integration tests to verify proper 
scoping of beans created in 'lite' mode.

Updated comments in TACCWithoutACTests to better reflect the runtime 
behavior for 'lite' @Bean methods.

Issue: SPR-9401
2012-05-18 21:54:17 +02:00
Sam Brannen 36e7cb2d31 Improve documentation of annotated class support in the TCF
Updated all Javadoc in the Spring TestContext Framework (TCF) to explain
and refer to 'annotated classes' instead of 'configuration classes'.

Specifically, @ContextConfiguration now explicitly defines what is meant
by 'annotated classes', and various other classes now refer to this
definition. Otherwise, the term 'configuration class' has simply been
replaced with 'annotated class'.

Also deleted cross references to deprecated JUnit 3.8 classes and
formatted Javadoc in general for greater readability.

Issue: SPR-9401
2012-05-17 20:17:48 +02:00
Sam Brannen 500a4dd995 Fix tx annotated tests so that they pass in the build
AbstractTransactionalAnnotatedConfigClassTests is now annotated with
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD) so 
that side-effects between tests are avoided.

Re-enabled TransactionalAnnotatedConfigClassWithAtConfigurationTests
and TransactionalAnnotatedConfigClassesWithoutAtConfigurationTests.

Also introduced a log4j FileAppender for tests that writes to
"build/spring-test.log".

Issue: SPR-9051
2012-05-16 03:08:15 +02:00
Sam Brannen 2017b24867 Disable tx annotated tests until working within the build
Issue: SPR-9051
2012-05-15 23:45:49 +02:00
Sam Brannen 1cec0f9c65 Investigate claims made in SPR-9051 regarding transactional tests
The claim: given an integration test class that is annotated with 
@ContextConfiguration and declares a configuration class that is missing

an @Configuration annotation, if a transactional test method (i.e., one 
annotated with @Transactional) changes the state of the database then
the 
changes will not be rolled back as would be expected with the default 
rollback semantics of the Spring TestContext Framework (TCF).

TransactionalAnnotatedConfigClassWithAtConfigurationTests is a concrete 
implementation of AbstractTransactionalAnnotatedConfigClassTests that
uses 
a true @Configuration class and thereby demonstrates the expected
behavior 
of such transactional tests with automatic rollback.

TransactionalAnnotatedConfigClassesWithoutAtConfigurationTests is a 
concrete implementation of
AbstractTransactionalAnnotatedConfigClassTests 
that does NOT use a true @Configuration class but rather a 'lite mode'
configuration class (see the Javadoc for @Bean for details).

Using such a 'lite mode' configuration class results in the following:

 - Its @Bean methods act as factory methods instead of singleton beans.
 - The dataSource() method is invoked multiple times instead of once.
 - The test instance and the TCF operate on different data sources.
 - The transaction managed (and rolled back) by the TCF is not the 
   transaction that the application code or test instance uses.

Ultimately, the use of a 'lite mode' configuration class gives the false
appearance that there is a bug in the TCF (in that the transaction is
not 
rolled back); however, the transaction managed by the TCF is in fact 
rolled back.

In conclusion, these tests demonstrate both the intended behavior of the

TCF and the fact that using 'lite mode' configuration classes can lead
to 
confusing results (both in tests and production code).

Issue: SPR-9051
2012-05-15 23:04:31 +02:00
Sam Brannen 78c6d70f0b Refute claims made in SPR-9051
It was claimed that when a {@code @ContextConfiguration} test class
references a config class missing an {@code @Configuration} annotation,
@Bean dependencies are wired successfully but the bean lifecycle is not
applied (no init methods are invoked, for example).

AnnotatedConfigClassesWithoutAtConfigurationTests refutes this claim by
demonstrating that @Bean methods in non-@Configuration classes are
properly handled as "annotated factory bean methods" and that lifecycle
callbacks in fact apply to such factory beans.

Issue: SPR-9051
2012-05-12 00:36:24 +02:00
Sam Brannen 0b17dd2242 Fix misleading JavaDoc in ProfileAnnotationConfigTestSuite 2012-05-11 23:35:43 +02:00
Sam Brannen 80af842662 Re-enable ignored tests in MockServletContextTests
Two tests in MockServletContextTests were disabled with @Ignore with the
comment "fails to work under ant after move from .testsuite -> .test";
however, this no longer appears to apply with the Gradle build. Thus
these tests have been re-enabled.
2012-05-10 17:00:28 +02:00
Stevo Slavic effb762558 Fix javadoc warnings
Before this change there were numerous javadoc warnings being reported
while building Spring framework API.

This commit resolves most of the javadoc warnings, reducing the total
number from 265 to 103.

Issue: SPR-9113
2012-04-30 11:31:02 +03:00
Stevo Slavic 991b8e9a06 Fix encoding issues in javadoc
Before this change javadoc in two classes had non-UTF-8 encoded
characters. This caused building Spring API to fail in Java 1.7.

Commit fixes this by replacing wrongly encoded characters with their
UTF-8 equivalents.

Issue: SPR-9097
2012-04-30 11:05:05 +03:00
Chris Beams ee36c80ca9 Sync with 3.1.x
* 3.1.x: (61 commits)
  Compensate for changes in JDK 7 Introspector
  Avoid 'type mismatch' errors in ExtendedBeanInfo
  Polish ExtendedBeanInfo and tests
  Infer AnnotationAttributes method return types
  Minor fix in MVC reference doc chapter
  Hibernate 4.1 etc
  TypeDescriptor equals implementation accepts annotations in any order
  "setBasenames" uses varargs now (for programmatic setup; SPR-9106)
  @ActiveProfiles mechanism works with @ImportResource as well (SPR-8992
  polishing
  clarified Resource's "getFilename" method to consistently return null
  substituteNamedParameters detects and unwraps SqlParameterValue object
  Replace spaces with tabs
  Consider security in ClassUtils#getMostSpecificMethod
  Adding null check for username being null.
  Improvements for registering custom SQL exception translators in app c
  SPR-7680 Adding QueryTimeoutException to the DataAccessException hiera
  Minor polish in WebMvcConfigurationSupport
  Detect overridden boolean getters in ExtendedBeanInfo
  Polish ExtendedBeanInfoTests
  ...
2012-02-13 15:17:30 +01:00
Chris Beams ddf8eaf38a Mark remaining @Ignored tests with 'TODO SPR-8116'
Each of these tests began failing during the Gradle build porting
process. None seem severe, many are likely due to classpath issues.

In the case of TestNG support, this needs to be added to the Gradle
build in order to execute these tests. See SPR-8116.txt
2012-01-31 14:37:12 +01:00
Chris Beams 6235a341a7 Remove bundlor support 2012-01-31 14:37:11 +01:00
Chris Beams 02a4473c62 Rename modules {org.springframework.*=>spring-*}
This renaming more intuitively expresses the relationship between
subprojects and the JAR artifacts they produce.

Tracking history across these renames is possible, but it requires
use of the --follow flag to `git log`, for example

    $ git log spring-aop/src/main/java/org/springframework/aop/Advisor.java

will show history up until the renaming event, where

    $ git log --follow spring-aop/src/main/java/org/springframework/aop/Advisor.java

will show history for all changes to the file, before and after the
renaming.

See http://chrisbeams.com/git-diff-across-renamed-directories
2012-01-31 14:37:10 +01:00