Commit Graph

143 Commits

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