Commit Graph

107 Commits

Author SHA1 Message Date
Juergen Hoeller 7bbd38b9e0 Fixed javadoc warnings
Issue: SPR-10373
(cherry picked from commit 1ca943c)
2013-05-07 22:06:33 +02: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
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 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
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 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