Commit Graph

88 Commits

Author SHA1 Message Date
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
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