Issue 1:
Sam Brannen opened SPR-7827 and commented

Overview

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.

As mentioned in various forums, a JIRA comment, and discussions I've had with Spring users, it would be beneficial to provide similar meta-annotation support for test-related annotations.

Given a custom @TransactionalTest stereotype annotation (see code listing below), multiple test classes in the application's test suite could rely on centralized configuration of the context and transaction configuration and thus avoid unnecessary duplication. See UserRepositoryIntegrationTests for an example.

Notes on JUnit

Naturally, Spring cannot provide meta-annotation support for JUnit's @RunWith annotation, since @RunWith is processed by JUnit internals. Developers would therefore still be required to specify SpringJUnit4ClassRunner as the runner for each individual test class.

Deliverables

Provide meta-annotation support for the following annotations within the context of the TestContext framework.

@ContextConfiguration

@WebAppConfiguration

@ContextHierarchy

@ActiveProfiles

@DirtiesContext

@TestExecutionListeners

@IfProfileValue

@ProfileValueSourceConfiguration

@Transactional

@BeforeTransaction

@AfterTransaction

@TransactionConfiguration

@Rollback

@Repeat

@Timed

Code Examples

@Transactional
@ContextConfiguration({"/app-config.xml", "/test-data-access-config.xml"})
public @interface TransactionalTest {}

@TransactionalTest
@RunWith(SpringJUnit4ClassRunner.class)
public class UserRepositoryIntegrationTests { /* ... */ }

Further Resources

JUnit: All JUnit annotations should be able to be applied as meta-annotations

JUnit: @RunWith(MetaAnnotations.class)

Affects: 3.0.5

Issue Links:

#15735 Document meta-annotation support in the TestContext framework ("is depended on by")

#16081 ContextLoader is supplied composed annotation class instead of test class for default resource detection

#15734 Support composed annotations declared on interfaces

#15666 Support meta-annotation attribute overrides in the TestContext framework

Referenced from: commits 5e7021f, 2bd5a53, 412f74f

8 votes, 11 watchers

Issue 2:
Matthew Sgarlata opened SPR-2233 and commented

Let me preface this by saying I know my use case is an edge case. However, the logging produced at WARN level by DispatcherServlet.noHandlerFound is incorrect for this case and is very confusing. Let me just start by saying what the fix is, and then come back to how the problem can be duplicated.

The current code for the method is:

protected void noHandlerFound(HttpServletRequest request, HttpServletResponse response) throws IOException {
if (pageNotFoundLogger.isWarnEnabled()) {
pageNotFoundLogger.warn("No mapping for [" + request.getRequestURI() +
"] in DispatcherServlet with name '" + getServletName() + "'");
}
response.sendError(HttpServletResponse.SC_NOT_FOUND);
}

In the case of a include done with <c:import>, request.getRequestURI() returns the wrong path. UrlPathHelper.getLookupPathForRequest needs to be used to get the correct path.

Here is my log output from a valid request. In this case, in a JSP called closeDialogRefreshPane.jsp I correctly did a <c:import> to one of my controllers called '/dashboardsNav'

DEBUG [http-80-Processor24] (DispatcherServlet:doService) - DispatcherServlet with name 'spring' received request for [/scoreboard/common/closeDialogRefreshPane.jsp]

DEBUG [http-80-Processor24] (DispatcherServlet:doService) - Taking snapshot of request attributes before include

DEBUG [http-80-Processor24] (DispatcherServlet:doDispatch) - Bound request context to thread: org.apache.catalina.core.ApplicationHttpRequest@1f489d9

DEBUG [http-80-Processor24] (DispatcherServlet:getHandler) - Testing handler map [org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping@16a346a] in DispatcherServlet with name 'spring'

DEBUG [http-80-Processor24] (BeanNameUrlHandlerMapping:getHandlerInternal) - Looking up handler for [/dashboardsNav]

DEBUG [http-80-Processor24] (DispatcherServlet:getHandlerAdapter) - Testing handler adapter [org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter@1bd871]

DEBUG [http-80-Processor24] (DispatcherServlet:getHandlerAdapter) - Testing handler adapter [org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter@1ba0609]

DEBUG [http-80-Processor24] (DispatcherServlet:render) - Rendering view [org.springframework.web.servlet.view.InternalResourceView: name 'dashboardsNavView'; URL [/dashboards/dashboardsNav.jsp]] in DispatcherServlet with name 'spring'

Here is my log output from an invalid request. I accidentally tried to do a <c:import> from closeDialogRefreshPane.jsp to the view '/calendarsNavView' instead of to my controller called '/calendarsNav':

DEBUG [http-80-Processor24] (DispatcherServlet:doService) - DispatcherServlet with name 'spring' received request for [/scoreboard/common/closeDialogRefreshPane.jsp]

DEBUG [http-80-Processor24] (DispatcherServlet:doService) - Taking snapshot of request attributes before include

DEBUG [http-80-Processor24] (DispatcherServlet:doDispatch) - Bound request context to thread: org.apache.catalina.core.ApplicationHttpRequest@1a34544

DEBUG [http-80-Processor24] (DispatcherServlet:getHandler) - Testing handler map [org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping@16a346a] in DispatcherServlet with name 'spring'

DEBUG [http-80-Processor24] (BeanNameUrlHandlerMapping:getHandlerInternal) - Looking up handler for [/calendarsNavView]

WARN [http-80-Processor24] (PageNotFound:noHandlerFound) - No mapping for [/scoreboard/common/closeDialogRefreshPane.jsp] in DispatcherServlet with name 'spring'

As you can see, the the PageNotFound logger says /common/closeDialogRefreshPane could not be found, when in fact it was already found and dispatched to, at which point an invalid <c:import> call is what's actually screwing things up.

Affects: 2.0 RC1