diff --git a/org.springframework.web.servlet/src/test/java/org/springframework/mock/web/MockHttpServletResponse.java b/org.springframework.web.servlet/src/test/java/org/springframework/mock/web/MockHttpServletResponse.java index 4bd0c51e761ae9db8a21b6d3f853df104385802d..46eb174615dcc42aa34225d8354c562568812918 100644 --- a/org.springframework.web.servlet/src/test/java/org/springframework/mock/web/MockHttpServletResponse.java +++ b/org.springframework.web.servlet/src/test/java/org/springframework/mock/web/MockHttpServletResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -98,7 +98,7 @@ public class MockHttpServletResponse implements HttpServletResponse { private String forwardedUrl; - private String includedUrl; + private final List includedUrls = new ArrayList(); //--------------------------------------------------------------------- @@ -443,11 +443,28 @@ public class MockHttpServletResponse implements HttpServletResponse { } public void setIncludedUrl(String includedUrl) { - this.includedUrl = includedUrl; + this.includedUrls.clear(); + if (includedUrl != null) { + this.includedUrls.add(includedUrl); + } } public String getIncludedUrl() { - return this.includedUrl; + int count = this.includedUrls.size(); + if (count > 1) { + throw new IllegalStateException( + "More than 1 URL included - check getIncludedUrls instead: " + this.includedUrls); + } + return (count == 1 ? this.includedUrls.get(0) : null); + } + + public void addIncludedUrl(String includedUrl) { + Assert.notNull(includedUrl, "Included URL must not be null"); + this.includedUrls.add(includedUrl); + } + + public List getIncludedUrls() { + return this.includedUrls; } diff --git a/org.springframework.web.servlet/src/test/java/org/springframework/mock/web/MockRequestDispatcher.java b/org.springframework.web.servlet/src/test/java/org/springframework/mock/web/MockRequestDispatcher.java index 2983c15501e46cbeaaf58b051c48eef64199500d..396f0e7fd54f485dea34ec7ba2ce1d4956b5f86c 100644 --- a/org.springframework.web.servlet/src/test/java/org/springframework/mock/web/MockRequestDispatcher.java +++ b/org.springframework.web.servlet/src/test/java/org/springframework/mock/web/MockRequestDispatcher.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -68,7 +68,7 @@ public class MockRequestDispatcher implements RequestDispatcher { public void include(ServletRequest request, ServletResponse response) { Assert.notNull(request, "Request must not be null"); Assert.notNull(response, "Response must not be null"); - getMockHttpServletResponse(response).setIncludedUrl(this.url); + getMockHttpServletResponse(response).addIncludedUrl(this.url); if (logger.isDebugEnabled()) { logger.debug("MockRequestDispatcher: including URL [" + this.url + "]"); } diff --git a/org.springframework.web/src/test/java/org/springframework/mock/web/MockHttpServletResponse.java b/org.springframework.web/src/test/java/org/springframework/mock/web/MockHttpServletResponse.java index 4bd0c51e761ae9db8a21b6d3f853df104385802d..46eb174615dcc42aa34225d8354c562568812918 100644 --- a/org.springframework.web/src/test/java/org/springframework/mock/web/MockHttpServletResponse.java +++ b/org.springframework.web/src/test/java/org/springframework/mock/web/MockHttpServletResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -98,7 +98,7 @@ public class MockHttpServletResponse implements HttpServletResponse { private String forwardedUrl; - private String includedUrl; + private final List includedUrls = new ArrayList(); //--------------------------------------------------------------------- @@ -443,11 +443,28 @@ public class MockHttpServletResponse implements HttpServletResponse { } public void setIncludedUrl(String includedUrl) { - this.includedUrl = includedUrl; + this.includedUrls.clear(); + if (includedUrl != null) { + this.includedUrls.add(includedUrl); + } } public String getIncludedUrl() { - return this.includedUrl; + int count = this.includedUrls.size(); + if (count > 1) { + throw new IllegalStateException( + "More than 1 URL included - check getIncludedUrls instead: " + this.includedUrls); + } + return (count == 1 ? this.includedUrls.get(0) : null); + } + + public void addIncludedUrl(String includedUrl) { + Assert.notNull(includedUrl, "Included URL must not be null"); + this.includedUrls.add(includedUrl); + } + + public List getIncludedUrls() { + return this.includedUrls; } diff --git a/org.springframework.web/src/test/java/org/springframework/mock/web/MockRequestDispatcher.java b/org.springframework.web/src/test/java/org/springframework/mock/web/MockRequestDispatcher.java index 2983c15501e46cbeaaf58b051c48eef64199500d..396f0e7fd54f485dea34ec7ba2ce1d4956b5f86c 100644 --- a/org.springframework.web/src/test/java/org/springframework/mock/web/MockRequestDispatcher.java +++ b/org.springframework.web/src/test/java/org/springframework/mock/web/MockRequestDispatcher.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -68,7 +68,7 @@ public class MockRequestDispatcher implements RequestDispatcher { public void include(ServletRequest request, ServletResponse response) { Assert.notNull(request, "Request must not be null"); Assert.notNull(response, "Response must not be null"); - getMockHttpServletResponse(response).setIncludedUrl(this.url); + getMockHttpServletResponse(response).addIncludedUrl(this.url); if (logger.isDebugEnabled()) { logger.debug("MockRequestDispatcher: including URL [" + this.url + "]"); }