Fix test bug related to legacy JUnit AssertionFailedError

AssertionFailedError was thrown by JUnit 3.8. Since RedirectViewTests
has been upgraded to JUnit 4, now standard java.lang.AssertionErrors are
thrown. Thus, attempting to catch an AssertionFailedError is futile.

Of course, since these tests have not been failing, it is likely a moot
point, but changing the try-catch blocks to catch a possible
AssertionError can't be a bad thing.
master
Sam Brannen 11 years ago
parent 08842f3fdf
commit f717b55035
  1. 11
      spring-webmvc/src/test/java/org/springframework/web/servlet/view/RedirectViewTests.java

@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@ -24,9 +24,8 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import junit.framework.AssertionFailedError;
import org.junit.Test;
import org.springframework.http.HttpStatus;
import org.springframework.mock.web.test.MockHttpServletRequest;
import org.springframework.mock.web.test.MockHttpServletResponse;
@ -264,7 +263,7 @@ public class RedirectViewTests {
String expectedUrlForEncoding = "http://url.somewhere.com?" + key + "=" + val + "&" + key2 + "=" + val2;
doTest(model, url, false, expectedUrlForEncoding);
}
catch (AssertionFailedError err) {
catch (AssertionError err) {
// OK, so it's the other order... probably on Sun JDK 1.6 or IBM JDK 1.5
String expectedUrlForEncoding = "http://url.somewhere.com?" + key2 + "=" + val2 + "&" + key + "=" + val;
doTest(model, url, false, expectedUrlForEncoding);
@ -282,7 +281,7 @@ public class RedirectViewTests {
String expectedUrlForEncoding = "http://url.somewhere.com?" + key + "=" + val[0] + "&" + key + "=" + val[1];
doTest(model, url, false, expectedUrlForEncoding);
}
catch (AssertionFailedError err) {
catch (AssertionError err) {
// OK, so it's the other order... probably on Sun JDK 1.6 or IBM JDK 1.5
String expectedUrlForEncoding = "http://url.somewhere.com?" + key + "=" + val[1] + "&" + key + "=" + val[0];
doTest(model, url, false, expectedUrlForEncoding);
@ -302,7 +301,7 @@ public class RedirectViewTests {
String expectedUrlForEncoding = "http://url.somewhere.com?" + key + "=" + val.get(0) + "&" + key + "=" + val.get(1);
doTest(model, url, false, expectedUrlForEncoding);
}
catch (AssertionFailedError err) {
catch (AssertionError err) {
// OK, so it's the other order... probably on Sun JDK 1.6 or IBM JDK 1.5
String expectedUrlForEncoding = "http://url.somewhere.com?" + key + "=" + val.get(1) + "&" + key + "=" + val.get(0);
doTest(model, url, false, expectedUrlForEncoding);

Loading…
Cancel
Save