Commit Graph

317 Commits

Author SHA1 Message Date
Rossen Stoyanchev 34924810fe Remove field no longer used after previous commit
Issue: SPR-11516
2014-03-05 14:50:16 -05:00
Rossen Stoyanchev 74de35df1e Refactor async result handling in Spring MVC Test
This change removes the use of a CountDownLatch to wait for the
asynchronously computed controller method return value. Instead we
check in a loop every 200 milliseconds if the result has been set.
If the result is not set within the specified amount of time to wait
an IllegalStateException is raised.

Additional changes:
 - Use AtomicReference to hold the async result
 - Remove @Ignore annotations on AsyncTests methods
 - Remove checks for the presence of Servlet 3

Issue: SPR-11516
2014-03-05 12:55:39 -05:00
Rossen Stoyanchev 705efc5bdf Fix timing issue with obtaining async result
Issue: SPR-11516
2014-03-04 21:38:42 -05:00
Rossen Stoyanchev c553d681f1 Add Servlet 3.1 methods to mock request
Issue: SPR-11492
2014-02-28 12:28:17 -05:00
Sam Brannen 979c483384 Do not inspect meta-annotations on Java annotations
This commit introduces a new isInJavaLangAnnotationPackage(Annotation)
method in AnnotationUtils. This method is now used in AnnotationUtils,
AnnotatedElementUtils, and MetaAnnotationUtils to ensure that search
algorithms do no search for meta-annotations on annotations in the
"java.lang.annotation" package.

The following are some empirical results from this change:

- The number of times that the findAnnotation(Class,Class,Set) method in
  AnnotationUtils is recursively invoked while executing
  AnnotationUtilsTests drops from 51 to 29.

- The number of times that the process(AnnotatedElement) method in
  AnnotationUtils.AnnotationCollector is recursively invoked while
  executing AnnotationUtilsTests.getRepeatableFromMethod() drops
  from 16 to 2.

- The number of times that the doProcess() method in
  AnnotatedElementUtils is recursively invoked while executing the
  "getAnnotationAttributes() On MetaCycleAnnotatedClass with missing
  target meta-annotation" test in AnnotatedElementUtilsTests drops
  from 23 to 5.

- The number of times that the findAnnotationDescriptor(Class,Set,Class)
  method in MetaAnnotationUtils is recursively invoked while executing
  the "findAnnotationDescriptor() on MetaCycleAnnotatedClass with
  missing target meta-annotation" test in MetaAnnotationUtilsTests drops
  from 16 to 8.

Issue: SPR-11483
2014-02-25 21:57:35 +01:00
Sam Brannen 78b69f5d77 Always supply test class to ContextLoaders in TCF
Prior to this commit, the following methods in ContextLoaderUtils
treated a composed @ContextConfiguration annotation (i.e., a custom
annotation that is meta-annotated with @ContextConfiguration) as the
"declaring class" instead of the actual test class.

- resolveContextConfigurationAttributes()
- resolveContextHierarchyAttributes()

As a consequence, if @ContextConfiguration is used as a
meta-annotation, the meta-annotated class is stored as the
"declaringClass" in ContextConfigurationAttributes. Thus, when a
ContextLoader (or SmartContextLoader) attempts to detect default
resource locations or configuration classes, it does so for the
composed annotation class instead of for the declaring test class.

This commit ensures that ContextLoaders are supplied the declaring test
class instead of the composed annotation class in such use cases.

Issue: SPR-11455
2014-02-25 15:27:31 +01:00
Sam Brannen f8950960f2 Support arbitrary meta-annotation levels in the TCF
Prior to this commit, the findAnnotationDescriptor() and
findAnnotationDescriptorForTypes() methods in MetaAnnotationUtils only
supported a single level of meta-annotations. In particular, this kept
the following annotations from being used as meta-annotations on
meta-annotations:

- @ContextConfiguration
- @ContextHierarchy
- @ActiveProfiles
- @TestExecutionListeners

This commit alters the search algorithms used in MetaAnnotationUtils so
that arbitrary levels of meta-annotations are now supported for the
aforementioned test-related annotations.

Issue: SPR-11470
2014-02-23 01:05:15 +01:00
Sam Brannen 2c8f25a14c Delete call to System.err in AbstractContextLoaderUtilsTests 2014-02-23 00:28:00 +01:00
Sam Brannen aa3e250ab6 @Ignore PrintingResultHandlerTests 2014-02-23 00:24:24 +01:00
Sam Brannen 3c511f00cc Simplify MetaAnnotationUtilsTests 2014-02-22 18:48:55 +01:00
Sam Brannen d9a2b3c2ba Deleted unused code in ContextLoaderUtilsActiveProfilesTests 2014-02-22 18:09:59 +01:00
Sam Brannen dc6eaad2e9 Update copyright date in ContextLoaderUtils 2014-02-22 18:06:37 +01:00
Sam Brannen 5f7d1758f8 Always pass test class to ActiveProfilesResolver
Prior to this commit, if @ActiveProfiles were used as a meta-annotation
on a composed annotation, then the composed annotation's class would be
passed to the ActiveProfilesResolver.resolve() method instead of the
test class, which breaks the contract for ActiveProfilesResolver.

This commit addresses this issue by ensuring that the actual test class
is always passed to ActiveProfilesResolver.resolve().

Issue: SPR-11467
2014-02-22 17:15:11 +01:00
Sam Brannen 34e90ba7f7 Simplify ContextLoaderUtilsActiveProfilesTests 2014-02-22 16:55:13 +01:00
Sam Brannen fe6a9826c5 Fix typo in AbstractDelegatingSmartContextLoader 2014-02-18 18:42:44 +01:00
Rossen Stoyanchev b1abe26b33 Add ResultMatchers for status code ranges
Issue: SPR-11424
2014-02-13 11:45:12 -05:00
Juergen Hoeller cead06a3d9 Polishing 2014-02-12 00:12:52 +01:00
Anton Bobov 1cf38a98a4 Fixed example in JavaDoc.
mimeType is not a valid method on ContentResultMatche.

I have signed and agree to the terms of the SpringSource Individual
Contributor License Agreement.
2014-02-10 14:23:10 +06:00
Sam Brannen c335e99e3f Remove trailing whitespace from source code 2014-02-08 17:30:39 +01:00
Sam Brannen 1f778530b5 Polish test classes
- Consistent importing of org.junit.Assert.*;
- Proper declaration of expected exceptions via @Test(expected).
- Renamed SpEL ExpressionTestCase to AbstractExpressionTests.
- Formatting and test method naming conventions.
2014-02-08 17:24:11 +01:00
Sam Brannen 08842f3fdf Delete legacy JUnit 3.8 test from spring-test 2014-02-08 15:50:04 +01:00
Sam Brannen 2d5c5fc18e Delete legacy JUnit 3.8 test from spring-test 2014-02-08 15:49:07 +01:00
Sam Brannen 522d136bbd Delete TODO that is now tracked in JIRA
Issue: SPR-11393
2014-02-06 14:12:03 +01:00
Sam Brannen b8ed2f4967 Ensure all tests are executed in the Gradle build
Prior to this commit several test classes named "*Test" were not
recognized as tests by the Gradle build. This is due to the configured
inclusion of '**/*Tests.*' which follows Spring's naming convention for
test classes.

This commit addresses this issue by:

 - Renaming real test classes consistently to "*Tests".
 - Renaming internal test classes to "*TestCase".
 - Renaming @WebTest to @WebTestStereotype.
 - Disabling broken tests in AnnoDrivenStaticEntityMockingControlTest.
 - Modifying the Gradle build configuration so that classes ending in
   either "*Tests" or "*Test" are considered test classes.

Issue: SPR-11384
2014-02-03 23:16:47 +01:00
Sam Brannen a521ef5cee Verify ServletCtxAware beans are processed in WAC tests
SPR-11145 claims that ServletContextAware beans declared in an
ApplicationContext loaded for an integration test by the TestContext
framework (TCF) do not have their setServletContext() methods invoked
if the tests are executed manually using JUnit 4.11.

This commit verifies that such ServletContextAware beans are processed
properly regardless of how the test was launched. Specifically:

 - A ServletContextAwareBean has been introduced.

 - BasicAnnotationConfigWacTests has been retrofitted with a
   ServletContextAwareBean in its context.

 - ServletContextAwareBeanWacTests has been introduced to execute
   BasicAnnotationConfigWacTests manually via JUnitCore.

Issue: SPR-11145
2014-02-01 02:08:21 +01:00
hupfis 0013a43237 Fixed code example in JavaDoc
equalTo is not a valid method on JsonPathResultMatchers

I have signed and agree to the terms of the SpringSource Individual Contributor License Agreement.
2014-01-24 09:26:09 +01:00
Sam Brannen fb12e234fc Handle NoClassDefFoundError consistently for TELs
Prior to this commit, a NoClassDefFoundError caught in
TestContextManager's retrieveTestExecutionListeners() method would be
handled differently for implicit default listeners (i.e., listeners not
declared via @TestExecutionListeners) and listeners explicitly declared
via @TestExecutionListeners. Specifically, a NoClassDefFoundError would
cause a test to fail for an explicitly declared TestExecutionListener
but not for an implicitly declared one.

This commit addresses this issue by:

 - Always swallowing a NoClassDefFoundError for both implicitly and
   explicitly declared TestExecutionListeners.
 - Changing the log level from DEBUG to INFO to make such situations
   more visible to the average end user.

Issue: SPR-11347
2014-01-22 23:28:36 +01:00
Sam Brannen 8105011368 Delete unnecessary redeclaration of test methods
This commit deletes methods in RollbackForRequiredEjbTxDaoTestNGTests
that were unnecessarily redeclared. The redeclaration is required for
JUnit's @FixMethodOrder support but not for TestNG's built-in support
for dependent methods.

Issue: SPR-6132
2014-01-22 17:44:13 +01:00
Sam Brannen c0eafa9ea1 Introduce EJB-based transactional tests in the TCF
This commit introduces transactional integration tests executing
against both JUnit and TestNG in the TestContext framework (TCF) using
@TransactionAttribute in EJBs instead of Spring’s @Transactional
annotation.

These tests disprove the claims raised in SPR-6132 by demonstrating that
transaction support in the TCF works as expected when a transactional
EJB method that is configured with TransactionAttribute.REQUIRES_NEW is
invoked. Specifically:

 - The transaction managed by the TCF is suspended while such an EJB
   method is invoked.
 - Any work performed within the new transaction for the EJB method is
   committed after the method invocation completes.
 - The transaction managed by the TCF is resumed and subsequently
   either rolled back or committed as necessary based on the
   configuration of @Rollback and @TransactionConfiguration.

The configuration for the JUnit-based tests is straightforward and self
explanatory; however, the configuration for the TestNG tests is less
intuitive.

In order for the TCF to function properly, the developer must ensure
that test methods within a given TestNG test (whether defined locally,
in a superclass, or somewhere else in the suite) are executed in the
proper order. In a stand-alone test class this is straightforward;
however, in a test class hierarchy (or test suite) with dependent
methods, it is necessary to configure TestNG so that all methods within
an individual test are executed in isolation from test methods in other
tests. This can be achieved by configuring a test class to run in its
own uniquely identified suite (e.g., by annotating each concrete
TestNG-based test class with @Test(suiteName = "< Some Unique Suite
Name >")).

For example, without specifying a unique suite name for the TestNG
tests introduced in this commit, test methods will be executed in the
following (incorrect) order:

 - CommitForRequiredEjbTxDaoTestNGTests.test1InitialState()
 - CommitForRequiresNewEjbTxDaoTestNGTests.test1InitialState()
 - RollbackForRequiresNewEjbTxDaoTestNGTests.test1InitialState()
 - RollbackForRequiredEjbTxDaoTestNGTests.test1InitialState()
 - CommitForRequiredEjbTxDaoTestNGTests.test2IncrementCount1()

The reason for this ordering is that test2IncrementCount1() depends on
test1InitialState(); however, the intention of the developer is that
the tests for an individual test class are independent of those in
other test classes. So by specifying unique suite names for each test
class, the following (correct) ordering is achieved:

 - RollbackForRequiresNewEjbTxDaoTestNGTests.test1InitialState()
 - RollbackForRequiresNewEjbTxDaoTestNGTests.test2IncrementCount1()
 - RollbackForRequiresNewEjbTxDaoTestNGTests.test3IncrementCount2()
 - CommitForRequiredEjbTxDaoTestNGTests.test1InitialState()
 - CommitForRequiredEjbTxDaoTestNGTests.test2IncrementCount1()
 - CommitForRequiredEjbTxDaoTestNGTests.test3IncrementCount2()
 - RollbackForRequiredEjbTxDaoTestNGTests.test1InitialState()
 - RollbackForRequiredEjbTxDaoTestNGTests.test2IncrementCount1()
 - RollbackForRequiredEjbTxDaoTestNGTests.test3IncrementCount2()
 - CommitForRequiresNewEjbTxDaoTestNGTests.test1InitialState()
 - CommitForRequiresNewEjbTxDaoTestNGTests.test2IncrementCount1()
 - CommitForRequiresNewEjbTxDaoTestNGTests.test3IncrementCount2()

See the JIRA issue for more detailed log output.

Furthermore, @DirtiesContext(classMode = ClassMode.AFTER_CLASS) has
been used in both the JUnit and TestNG tests introduced in this commit
in order to ensure that the in-memory database is reinitialized between
each test class.

Issue: SPR-6132
2014-01-22 12:56:07 +01:00
Sam Brannen 3370f8b1b1 Include ServletTEL in abstract base test classes
The ServletTestExecutionListener is now prepended to the set of default
listeners in AbstractJUnit4SpringContextTests and
AbstractTestNGSpringContextTests.

Issue: SPR-11340
2014-01-21 15:01:29 +01:00
Sam Brannen 6e30851328 Improve logging in TransactionalTEL
This commit makes the logging in TransactionalTestExecutionListener
consistent for both starting and ending transactions. Specifically,
the current TestContext is now included in the informational log
statement when starting a new transaction.

Issue: SPR-11323
2014-01-17 14:54:36 +01:00
Juergen Hoeller a5f9b29292 Polishing 2014-01-15 22:53:46 +01:00
Sam Brannen feb9d261ac Remove unused import in MockHttpServletRequestBuilderTests 2014-01-15 15:46:52 +01:00
Rossen Stoyanchev 8b35c3ff74 Recognize Content-Type as special header in MHSRB
When adding headers generically, MockHttpServletRequestBuilder now
recognizes Content-Type and updates the contentType field accordingly.

Issue: SPR-11308
2014-01-14 12:11:12 -05:00
Juergen Hoeller 26271fc30c Polishing 2014-01-13 23:45:54 +01:00
Juergen Hoeller 547646de6d Polishing 2014-01-13 22:25:34 +01:00
Juergen Hoeller f7fc2cbc3b Replaced reflection code with straight Servlet 3.0 setAsyncStarted call 2014-01-13 22:20:46 +01:00
Greg Turnquist 6b0d88721c Add method for HTTP PATCH in MockMvcRequestBuilders
Issue: SPR-11299

This is short to avoid having to use MockMvcRequestBuilders.request()
and instead have a simple patch(url, params...)
2014-01-13 14:17:16 -05:00
Sam Brannen a30cf3058e Remove unused imports in tests 2014-01-06 12:16:24 +01:00
Sam Brannen 27ab9332c1 Suppress deprecation warning for MHSR.setStatus()
Suppressing deprecation warnings for
MockHttpServletResponse.setStatus(int, String).
2014-01-06 12:15:52 +01:00
Brian Clozel 1c83e8653a Switch to Jackson 2 in unit tests
Prior to this commit, some unit tests were using
Spring's Jackson 1.x implementations. Now Jackson
2.x implementations are the default ones used in
unit tests.

Even if Jackson 1.x support is deprecated, Jackson 1.x
unit tests are kept.

Issue: SPR-11121
2014-01-03 09:50:43 +01:00
Rossen Stoyanchev 2e4f38f6af Introduce AbstractMockMvcBuilder class
This change splits out an abstract base class from DefaultMockMvcBuilder
with StandaloneMockMvcBuilder switching to extend the new abstract class
(rather than DefaultMockMvcBuilder).

Issue: SPR-11238
2013-12-23 21:40:27 -05:00
Sam Brannen a223e247c2 Document meta-annotation support in the TCF
- Completed Javadoc for MetaAnnotationUtils.
- Added Javadoc notes to multiple annotations in the TCF, pointing out
  which annotations can be used as meta-annotations.

Issue: SPR-11109
2013-12-11 14:43:10 +01:00
Sam Brannen da7ae4a63b Polish meta-annotation terminology in MetaAnnoUtils 2013-12-11 02:14:50 +01:00
Sam Brannen 800018a817 Do not repopulate RequestContextHolder in ServTEL
This commit fixes a bug introduced in the last commit.

ServletTestExecutionListener (STEL) now tracks whether it has already
populated the RequestContextHolder.

Issue: SPR-11144
2013-12-11 01:00:04 +01:00
Sam Brannen 099b10d23b Honor presence of @WebAppConfiguration in ServTEL
The previous commit for issue SPR-11144 revealed a bug in
ServletTestExecutionListener (STEL). Specifically, STEL acted on the
fact that the ApplicationContext for a given TestContext was an
instance of WebApplicationContext. This behavior could potentially
break test code from previous releases of the Spring Framework that
relied on a custom setup of the RequestAttributes in the
RequestContextHolder with a custom WebApplicationContext ContextLoader.

This commit addresses this issue by ensuring that STEL only comes into
play if the test class is annotated with @WebAppConfiguration (for
prepareTestInstance() and beforeTestMethod()) or if the TestContext
attribute named RESET_REQUEST_CONTEXT_HOLDER_ATTRIBUTE is set to
Boolean.TRUE (for afterTestMethod()).

Issue: SPR-11144
2013-12-10 23:49:58 +01:00
Sam Brannen a3b022aa48 Ensure ServTEL doesn't reset ReqAttrs by accident
Prior to this commit, the ServletTestExecutionListener did not
overwrite RequestAttributes in the RequestContextHolder if the
ApplicationContext associated with the given TestContext was not a
WebApplicationContext; however, the ServletTestExecutionListener would
clear the RequestAttributes after every test method execution,
regardless of whether the context was a WebApplicationContext or not.
This behavior breaks backwards compatibility with integration tests
that managed the RequestAttributes in RequestContextHolder themselves.

This commit addresses this issue by introducing a TestContext attribute
named RESET_REQUEST_CONTEXT_HOLDER_ATTRIBUTE in
ServletTestExecutionListener. This attribute is used internally within
ServletTestExecutionListener to ensure that the RequestContextHolder is
only cleared (i.e., reset) if the ServletTestExecutionListener actually
populated the RequestContextHolder.

Issue: SPR-11144
2013-12-09 15:35:54 +01:00
Sam Brannen 3e0b0f100c Delete unused import in MockAsyncContext 2013-12-05 21:48:49 +01:00
Phillip Webb 526555de85 Tweak times in TimedSpringRunnerTests 2013-12-02 22:47:01 -08:00
Juergen Hoeller f5a310ad57 Polishing (backported from 3.2.x) 2013-12-03 01:37:01 +01:00
Juergen Hoeller 2a52decbbc Polishing (including removal of javadoc imports that show as package cycles in IntelliJ) 2013-12-02 23:57:00 +01:00
Phillip Webb 043a41e382 Consistent whitespace after imports
Update code to have a consistent number of new-line characters after
import statements.
2013-11-26 15:14:43 -08:00
Phillip Webb 15698860e1 General polish of new 4.0 classes
Apply consistent styling to new classes introduced in Spring 4.0.

- Javadoc line wrapping, whitespace and formatting
- General code whitespace
- Consistent Assert.notNull messages
2013-11-26 15:11:18 -08:00
Phillip Webb a31ac882c5 Fix various javadoc warnings 2013-11-26 13:25:37 -08:00
Sam Brannen 64f593db8f Support meta-annotation attr overrides in the TCF
Prior to this commit, the Spring TestContext Framework (TCF) supported
the use of test-related annotations as meta-annotations for composing
custom test stereotype annotations; however, attributes in custom
stereotypes could not be used to override meta-annotation attributes.

This commit addresses this by allowing attributes from the following
annotations (when used as meta-annotations) to be overridden in custom
stereotypes.

- @ContextConfiguration
- @ActiveProfiles
- @DirtiesContext
- @TransactionConfiguration
- @Timed
- @TestExecutionListeners

This support depends on functionality provided by
AnnotatedElementUtils. See the 'Notes' below for further details and
ramifications.

Notes:

- AnnotatedElementUtils does not support overrides for the 'value'
  attribute of an annotation. It is therefore not possible or not
  feasible to support meta-annotation attribute overrides for some
  test-related annotations.
- @ContextHierarchy, @WebAppConfiguration, @Rollback, @Repeat, and
  @ProfileValueSourceConfiguration define single 'value' attributes
  which cannot be overridden via Spring's meta-annotation attribute
  support.
- Although @IfProfileValue has 'values' and 'name' attributes, the
  typical usage scenario involves the 'value' attribute which is not
  supported for meta-annotation attribute overrides. Furthermore,
  'name' and 'values' are so generic that it is deemed unfeasible to
  provide meta-annotation attribute override support for these.
- @BeforeTransaction and @AfterTransaction do not define any attributes
  that can be overridden.
- Support for meta-annotation attribute overrides for @Transactional is
  provided indirectly via SpringTransactionAnnotationParser.

Implementation Details:

- MetaAnnotationUtils.AnnotationDescriptor now provides access to the
  AnnotationAttributes for the described annotation.
- MetaAnnotationUtils.AnnotationDescriptor now provides access to the
  root declaring class as well as the declaring class.
- ContextLoaderUtils now retrieves AnnotationAttributes from
  AnnotationDescriptor to look up annotation attributes for
  @ContextConfiguration and @ActiveProfiles.
- ContextConfigurationAttributes now provides a constructor to have its
  attributes sourced from an instance of AnnotationAttributes.
- ContextLoaderUtils.resolveContextHierarchyAttributes() now throws an
  IllegalStateException if no class in the class hierarchy declares
  @ContextHierarchy.
- TransactionalTestExecutionListener now uses AnnotatedElementUtils to
  look up annotation attributes for @TransactionConfiguration.
- Implemented missing unit tests for @Rollback resolution in
  TransactionalTestExecutionListener.
- SpringJUnit4ClassRunner now uses AnnotatedElementUtils to look up
  annotation attributes for @Timed.
- TestContextManager now retrieves AnnotationAttributes from
  AnnotationDescriptor to look up annotation attributes for
  @TestExecutionListeners.
- DirtiesContextTestExecutionListener now uses AnnotatedElementUtils to
  look up annotation attributes for @DirtiesContext.

Issue: SPR-11038
2013-11-26 15:56:37 -05:00
Rossen Stoyanchev 119e793994 Fix concurrency issue in TestDispatcherServlet
This change fixes a timing issue in tests using Spring MVC Tests where
assertions on an async result may not wait long enough.

The fix involves the use of a new callback in  MockAsyncContext that
allows tests to detect when an async dispatch has been invoked.

Issue: SPR-10838
2013-11-25 21:51:08 -05:00
Sam Brannen a5d87fffd9 Polish Javadoc for @IfProfileValue 2013-11-25 21:22:54 -05:00
Sam Brannen 412f74f679 Provide meta-annotation support for @Rollback
@Rollback now supports ANNOTATION_TYPE as a target, allowing it to be
used as meta-annotation.

Note: this change was accidentally omitted from the original commit for
SPR-7827.

Issue: SPR-7827
2013-11-25 20:17:14 -05:00
Phillip Webb 59002f2456 Fix remaining compiler warnings
Fix remaining Java compiler warnings, mainly around missing
generics or deprecated code.

Also add the `-Werror` compiler option to ensure that any future
warnings will fail the build.

Issue: SPR-11064
2013-11-25 12:52:42 -08:00
Sam Brannen 665251fa2f Suppress deprecation warning in StatusResultMatchers 2013-11-22 12:55:12 +01:00
Sam Brannen 127bc07cda Delete unused package import 2013-11-22 12:49:25 +01:00
Phillip Webb d9c4470461 Upgrade to HSQLDB 2.3.1
Replace `hsqldb:hsqldb:1.8.0.10` with `org.hsqldb:hsqldb:2.3.1` and
fix breaking tests.

Issue: SPR-10947
2013-11-21 15:48:17 -08:00
Juergen Hoeller 6a9e116d78 Polishing 2013-11-20 14:50:59 +01:00
Juergen Hoeller 54571bf038 Introduced getBeanNamesForAnnotation method on ListableBeanFactory
Issue: SPR-11069
2013-11-15 16:04:11 +01:00
Rossen Stoyanchev 2e57cf8bfc Fold spring-test-mvc sources into spring-test
With spring-test compiling against Servlet 3.0 it is no longer required
to compile Spring MVC Test sources separately (from spring-test).
2013-11-05 11:44:13 -05:00
Sam Brannen 2e6c998168 Update Javadoc for mocks regarding Servlet 3.0
Commit deba32cad9 upgraded the Servlet API mocks to Servlet 3.0;
however, not all of the Javadoc was updated accordingly.

This commit updates the remaining Javadoc with regard to Servlet 3.0 as
the baseline for mocks in the spring-test module.

In addition, this commit syncs up the mocks used for internal testing in
the spring-web module with the most current versions from spring-test.

Issue: SPR-11049
2013-10-31 11:51:15 +01:00
Sam Brannen 180f41c4c5 Renamed @WebTests to @WebTest
@WebTests has been renamed to @WebTest so that the Gradle build does not
attempt to run it as a JUnit test.
2013-10-28 02:04:24 +01:00
Sam Brannen f9cadfe6f9 Relocate test class to src/test/java folder 2013-10-28 01:56:21 +01:00
Sam Brannen 5e7021f3f7 Provide meta-annotation support in the TCF
Spring 3.0 already allows component stereotypes to be used in a
meta-annotation fashion, for example by creating a custom
@TransactionalService stereotype annotation which combines
@Transactional and @Service in a single, reusable, application-specific
annotation. However, the Spring TestContext Framework (TCF) currently
does not provide any support for test-related annotations to be used as
meta-annotations.

This commit overhauls the TCF with regard to how annotations are
retrieved and adds explicit support for the following annotations to be
used as meta-annotations in conjunction with the TCF.

- @ContextConfiguration
- @ContextHierarchy
- @ActiveProfiles
- @DirtiesContext
- @IfProfileValue
- @ProfileValueSourceConfiguration
- @BeforeTransaction
- @AfterTransaction
- @TransactionConfiguration
- @Rollback
- @TestExecutionListeners
- @Repeat
- @Timed
- @WebAppConfiguration

Note that meta-annotation support for @Transactional was already
available prior to this commit.

The following is a summary of the major changes included in this commit.

- Now using AnnotationUtils.getAnnotation() instead of
  Class.getAnnotation() where appropriate in the TestContext Framework.
- Now using AnnotationUtils.findAnnotation() instead of
  Class.isAnnotationPresent() where appropriate in the TestContext
  Framework.
- Introduced findAnnotationPrefersInteracesOverLocalMetaAnnotations() in
  AnnotationUtilsTests in order to verify the status quo.
- AnnotationUtils.findAnnotationDeclaringClass() and
  AnnotationUtils.findAnnotationDeclaringClassForTypes() now support
  meta annotations.
- Introduced MetaAnnotationUtils and AnnotationDescriptor in the
  spring-test module.
- Introduced UntypedAnnotationDescriptor in MetaAnnotationUtils.
- Introduced findAnnotationDescriptorForTypes() in MetaAnnotationUtils.
- ContextLoaderUtils now uses MetaAnnotationUtils for looking up
  @ActiveProfiles as a potential meta-annotation.
- TestContextManager now uses MetaAnnotationUtils for looking up
  @TestExecutionListeners as a potential meta-annotation.
- DirtiesContextTestExecutionListener now uses AnnotationUtils for
  looking up @DirtiesContext as a potential meta-annotation.
- Introduced DirtiesContextTestExecutionListenerTests.
- ProfileValueUtils now uses AnnotationUtils for looking up
  @IfProfileValue and @ProfileValueSourceConfiguration as potential
  meta-annotations.
- @BeforeTransaction and @AfterTransaction now support ANNOTATION_TYPE
  as a target, allowing them to be used as meta-annotations.
- TransactionalTestExecutionListener now uses AnnotationUtils for
  looking up @BeforeTransaction, @AfterTransaction, @Rollback, and
  @TransactionConfiguration as potential meta-annotations.
- Introduced TransactionalTestExecutionListenerTests.
- @Repeat and @Timed now support ANNOTATION_TYPE as a target, allowing
  them to be used as meta-annotations.
- SpringJUnit4ClassRunner now uses AnnotationUtils for looking up
  @Repeat and @Timed as potential meta-annotations.
- Moved all remaining logic for building the MergedContextConfiguration
  from the DefaultTestContext constructor to
  ContextLoaderUtils.buildMergedContextConfiguration().
- Verified meta-annotation support for @WebAppConfiguration and
  @ContextConfiguration.

Issue: SPR-7827
2013-10-28 01:33:17 +01:00
Sam Brannen 88fe2e9b00 Convert TestContext to interface & default impl
Since the Spring TestContext Framework was introduced in Spring
Framework 2.5, the TestContext class has always been a public class
with package private constructors. The visibility of TestContext's
constructor and methods was intentionally limited in order to hide the
implementation details of the context cache, etc. However, this fact
has made it difficult (if not impossible) to unit test custom
TestExecutionListener implementations.

This commit addresses this issue by converting TestContext into a
public interface with a package private DefaultTestContext
implementation. This enables unit testing of any components that depend
on a TestContext (e.g., TestExecutionListeners) while at the same time
preserving the encapsulation of the inner workings of the TestContext
implementation with regard to context loading and caching.

Issue: SPR-7692
2013-10-26 21:20:12 +02:00
Sam Brannen 7658d856ca Assert context uniqueness against merged config
Prior to this commit, the uniqueness check for @ContextConfiguration
attributes within a @ContextHierarchy was performed at a single test
class level instead of against the merged configuration for all test
class levels in the test class hierarchy.

This commit addresses this issue by moving the uniqueness check
algorithm from resolveContextHierarchyAttributes() to
buildContextHierarchyMap() within ContextLoaderUtils.

Issue: SPR-10997
2013-10-21 19:33:04 +02:00
Brian Clozel e4479c8669 Fix MockHttpServletResponse HTTP status update
Prior to this commit, one could call the setStatus method on
this Mock object and update the response's status,
even though the sendError method had already been called.

According to the HttpServletResponse Javadoc, sendError() methods
commit the response; so the response can't be written after that.

This commit fixes MockHttpServletResponse's behavior; setStatus
methods do not update the status once the response has been
committed.

Issue: SPR-10414
2013-10-07 14:43:06 -04:00
Juergen Hoeller beaf6992b2 Fixed BadSqlGrammarException usage in transaction test suite
Issue: SPR-10902
(cherry picked from commit ef66708)
2013-09-25 14:11:10 +02:00
Sam Brannen ee5d6c8f83 Exclude null requestURI in MHSR.getRequestURL()
This commit undoes the changes made in ec5d81e78e and ensures that the
getRequestURL() method in MockHttpServletRequest does not include the
String "null" for a null requestURI by first checking if the requestURI
contains text before including it in the composed URL.

Issue: SPR-10643
2013-09-11 23:08:05 +02:00
Rossen Stoyanchev 0d5901ffb6 Polish Cookie abstraction in http packge of spring-web
A getCookies method is now available on ServerHttpRequest with one
ServletServerCookie implementation that wraps a Servlet cookie.

The SockJS service makes use of this to check for an existing session
cookie in the request.
2013-08-02 12:30:43 -04:00
Sam Brannen 8ad36ef812 Delete remaining JUnit 3.8 tests in spring-test
This commit deletes the remaining JUnit 3.8 tests in the spring-test
module that were still subclassing deprecated class hierarchies.

Issue: SPR-10499
2013-06-16 20:03:21 +02:00
Sam Brannen d25611dd40 Move MockMultHtServReqTests to correct package
This commit relocates MockMultipartHttpServletRequestTests to the
appropriate package.
2013-06-16 19:55:35 +02:00
Sam Brannen c06157acd3 @Ignore empty test methods in RootWacEarTests hierarchy 2013-06-16 19:47:18 +02:00
Sam Brannen 432f899b29 Reduce complexity in ContextLoaderUtilsTests
This commit refactors ContextLoaderUtilsTests into
AbstractContextLoaderUtilsTests and several specialized subclasses in
order to reduce to the growing complexity of ContextLoaderUtilsTests.
2013-06-16 17:54:55 +02:00
Sam Brannen d126620216 Remove superfluous not-null check in ContextLoaderUtils 2013-06-16 00:38:56 +02:00
Sam Brannen 044f51283b Introduce ActiveProfilesResolver in the TCF
Prior to this commit, the active bean definition profiles to use when
loading an ApplicationContext for tests could only be configured
declaratively (i.e., via hard-coded values supplied to the 'value' or
'profiles' attribute of @ActiveProfiles).

This commit makes it possible to programmatically configure active bean
definition profiles in tests via a new ActiveProfileResolver interface.
Custom resolvers can be registered via a new 'resolver' attribute
introduced in @ActiveProfiles.

Overview of changes:

 - Introduced a new ActiveProfilesResolver API.
 - Added a 'resolver' attribute to @ActiveProfiles.
 - Updated ContextLoaderUtils.resolveActiveProfiles() to support
   ActiveProfilesResolvers.
 - Documented these new features in the reference manual.
 - Added new content to the reference manual regarding the
   'inheritProfiles' attribute of @ActiveProfiles
 - Removed the use of <lineannotation> Docbook markup in the testing
   chapter of the reference manual for Java code examples in order to
   allow comments to have proper syntax highlighting in the generated
   HTML and PDF.

Issue: SPR-10338
2013-06-16 00:01:34 +02:00
Sam Brannen 51d828816d Throw ISEs in MockHttpSession for invalid session
The Javadoc for several methods in HttpSession specifies that an
IllegalStateException must be thrown if the method is called on an
invalidated session; however, Spring's MockHttpSession did not implement
this behavior consistently prior to this commit.

This commit therefore ensures that the following methods in
MockHttpSession properly throw an IllegalStateException as defined in
the Servlet specification.

 - long getCreationTime()
 - long getLastAccessedTime()
 - Object getAttribute(String)
 - Object getValue(String)
 - Enumeration<String> getAttributeNames()
 - String[] getValueNames()
 - void setAttribute(String, Object)
 - void putValue(String , Object)
 - void removeAttribute(String)
 - void removeValue(String)
 - void invalidate()
 - boolean isNew()

Issue: SPR-7659
2013-06-09 16:38:04 +02:00
Sam Brannen ec5d81e78e Ensure method & requestURI are non-null in MHSR
Prior to this commit it was possible for the method and requestURI
fields in MockHttpServletRequest to be set to null.

This commit ensures that the method and requestURI fields are internally
stored as empty strings if the user sets them to a null value.

Issue: SPR-10643
2013-06-09 12:42:00 +02:00
Sam Brannen 86591e5e5a Support implicit ports in MHSR.getRequestURL()
Prior to this commit, MockHttpServletRequest.getRequestURL() always
included the server port number in the reconstructed request URL, even
for implicit ports (i.e., 80 and 443) and negative ports.

MockHttpServletRequest.getRequestURL() now omits the port number when
reconstructing a URL that has an implicit or negative port.

Issue: SPR-9726
2013-06-09 11:55:24 +02:00
Sam Brannen b3a693e356 Add test to assess claim in SPR-10330
This commit verifies that JdbcTestUtils.readScript() properly handles
SQL comments prefixed by tab characters.

Issue: SPR-10330
2013-06-08 21:45:29 +02:00
Sam Brannen bc9e4ab106 Polish method names in JdbcTestUtilsTests 2013-06-08 21:05:16 +02:00
Sam Brannen 34e8ee94c4 Add deleteFromTableWhere() to base classes in TCF
This commit introduces a deleteFromTableWhere() convenience method in
AbstractTransactionalJUnit4SpringContextTests and
AbstractTransactionalTestNGSpringContextTests that delegates to the
recently introduced method of the same name in JdbcTestUtils.

Issue: SPR-10639
2013-06-08 21:03:45 +02:00
Rob Winch 9468548116 Add @Override to remaining source files
Issue: SPR-10130
2013-05-13 17:04:56 -05:00
Sam Brannen 6fa493908b Hoellereasymock --> Hoeller 2013-05-10 22:13:23 +02:00
Phillip Webb 8b904102ff Update ...DirtiesContextTests to get beans early
Change ContextHierarchyDirtiesContextTests to obtain beans whilst the
ApplicationContext is still open, rather than trying to obtain them
after the context has been closed.
2013-05-09 14:57:16 -07:00
Juergen Hoeller 2a44228b98 Consistent use of <pre class="code">
Issue: SPR-8108
2013-05-07 21:31:26 +02:00
Juergen Hoeller 1ca943c681 Fixed javadoc warnings
Issue: SPR-10373
2013-05-07 21:26:01 +02:00
Rossen Stoyanchev 59e6298c82 Merge remote-tracking branch 'upstream/master' 2013-05-06 16:44:35 -04:00
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