Revisit Assert to avoid single-arg assert methods (with refined messages)
Issue: SPR-15196
(cherry picked from commit 1b2dc36)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -61,7 +61,7 @@ public class MockAsyncContext implements AsyncContext {
|
||||
|
||||
|
||||
public void addDispatchHandler(Runnable handler) {
|
||||
Assert.notNull(handler);
|
||||
Assert.notNull(handler, "Dispatch handler must not be null");
|
||||
this.dispatchHandlers.add(handler);
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public class MockAsyncContext implements AsyncContext {
|
||||
|
||||
@Override
|
||||
public boolean hasOriginalRequestAndResponse() {
|
||||
return (this.request instanceof MockHttpServletRequest) && (this.response instanceof MockHttpServletResponse);
|
||||
return (this.request instanceof MockHttpServletRequest && this.response instanceof MockHttpServletResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -112,8 +112,8 @@ public class MockAsyncContext implements AsyncContext {
|
||||
try {
|
||||
listener.onComplete(new AsyncEvent(this, this.request, this.response));
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new IllegalStateException("AsyncListener failure", e);
|
||||
catch (IOException ex) {
|
||||
throw new IllegalStateException("AsyncListener failure", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -356,12 +356,12 @@ public class MockPageContext extends PageContext {
|
||||
}
|
||||
|
||||
public byte[] getContentAsByteArray() {
|
||||
Assert.isTrue(this.response instanceof MockHttpServletResponse);
|
||||
Assert.state(this.response instanceof MockHttpServletResponse, "MockHttpServletResponse required");
|
||||
return ((MockHttpServletResponse) this.response).getContentAsByteArray();
|
||||
}
|
||||
|
||||
public String getContentAsString() throws UnsupportedEncodingException {
|
||||
Assert.isTrue(this.response instanceof MockHttpServletResponse);
|
||||
Assert.state(this.response instanceof MockHttpServletResponse, "MockHttpServletResponse required");
|
||||
return ((MockHttpServletResponse) this.response).getContentAsString();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.util;
|
||||
|
||||
import java.net.URI;
|
||||
@@ -21,13 +22,14 @@ import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link DefaultUriTemplateHandler}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class DefaultUriTemplateHandlerTests {
|
||||
|
||||
private final DefaultUriTemplateHandler handler = new DefaultUriTemplateHandler();
|
||||
|
||||
Reference in New Issue
Block a user