Fix broken test in MvcNamespaceTests

The testDefaultConfig() method in MvcNamespaceTests creates a new Date()
in its test fixture but then performs an assertion against a hard coded
data string of "2013-10-21". This test therefore only passed yesterday,
on October 21, 2013.

This commit addresses this by changing the hard coded date string to one
based on the current date.

Issue: SPR-10665, SPR-8826
This commit is contained in:
Sam Brannen 2013-10-22 22:38:32 +02:00
parent e95bd9e250
commit 6b0a62569b
1 changed files with 4 additions and 2 deletions

View File

@ -19,6 +19,8 @@ package org.springframework.web.servlet.config;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.Method;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
@ -161,8 +163,8 @@ public class MvcNamespaceTests {
testController.testBind(now, null, null);
MvcUrls mvcUrls = this.appContext.getBean(MvcUrls.class);
UriComponents uriComponents = mvcUrls.linkToMethodOn(testController);
assertEquals("http://localhost/?date=2013-10-21", uriComponents.toUriString());
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
assertEquals("http://localhost/?date=" + dateFormat.format(now), uriComponents.toUriString());
}
finally {
RequestContextHolder.resetRequestAttributes();