Add @Override annotations to test sources
Issue: SPR-10129
This commit is contained in:
@@ -51,12 +51,14 @@ public class DerivedTestBean extends TestBean implements Serializable, BeanNameA
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setBeanName(String beanName) {
|
||||
if (this.beanName == null || beanName == null) {
|
||||
this.beanName = beanName;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBeanName() {
|
||||
return beanName;
|
||||
}
|
||||
@@ -75,10 +77,12 @@ public class DerivedTestBean extends TestBean implements Serializable, BeanNameA
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
this.destroyed = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wasDestroyed() {
|
||||
return destroyed;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ public class NestedTestBean implements INestedTestBean {
|
||||
this.company = (company != null ? company : "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCompany() {
|
||||
return company;
|
||||
}
|
||||
|
||||
@@ -31,22 +31,27 @@ public class SerializablePerson implements Person, Serializable {
|
||||
private String name;
|
||||
private int age;
|
||||
|
||||
@Override
|
||||
public int getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAge(int age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object echo(Object o) throws Throwable {
|
||||
if (o instanceof Throwable) {
|
||||
throw (Throwable) o;
|
||||
|
||||
@@ -143,6 +143,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setBeanName(String beanName) {
|
||||
this.beanName = beanName;
|
||||
}
|
||||
@@ -151,6 +152,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
||||
return beanName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) {
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
@@ -167,10 +169,12 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
||||
return postProcessed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
@@ -186,10 +190,12 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAge(int age) {
|
||||
this.age = age;
|
||||
}
|
||||
@@ -202,6 +208,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
||||
this.jedi = jedi;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITestBean getSpouse() {
|
||||
return (spouses != null ? spouses[0] : null);
|
||||
}
|
||||
@@ -214,10 +221,12 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
||||
return (spouses != null ? (TestBean) spouses[0] : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSpouse(ITestBean spouse) {
|
||||
this.spouses = new ITestBean[] {spouse};
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITestBean[] getSpouses() {
|
||||
return spouses;
|
||||
}
|
||||
@@ -244,42 +253,52 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getStringArray() {
|
||||
return stringArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStringArray(String[] stringArray) {
|
||||
this.stringArray = stringArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer[] getSomeIntegerArray() {
|
||||
return someIntegerArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSomeIntegerArray(Integer[] someIntegerArray) {
|
||||
this.someIntegerArray = someIntegerArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer[][] getNestedIntegerArray() {
|
||||
return nestedIntegerArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNestedIntegerArray(Integer[][] nestedIntegerArray) {
|
||||
this.nestedIntegerArray = nestedIntegerArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSomeIntArray() {
|
||||
return someIntArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSomeIntArray(int[] someIntArray) {
|
||||
this.someIntArray = someIntArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[][] getNestedIntArray() {
|
||||
return nestedIntArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNestedIntArray(int[][] nestedIntArray) {
|
||||
this.nestedIntArray = nestedIntArray;
|
||||
}
|
||||
@@ -340,6 +359,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
||||
this.someProperties = someProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public INestedTestBean getDoctor() {
|
||||
return doctor;
|
||||
}
|
||||
@@ -348,6 +368,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
||||
this.doctor = doctor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public INestedTestBean getLawyer() {
|
||||
return lawyer;
|
||||
}
|
||||
@@ -380,6 +401,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
||||
this.someBoolean = someBoolean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IndexedTestBean getNestedIndexedBean() {
|
||||
return nestedIndexedBean;
|
||||
}
|
||||
@@ -405,23 +427,28 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void exceptional(Throwable t) throws Throwable {
|
||||
if (t != null) {
|
||||
throw t;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unreliableFileOperation() throws IOException {
|
||||
throw new IOException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object returnsThis() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void absquatulate() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int haveBirthday() {
|
||||
return age++;
|
||||
}
|
||||
@@ -451,6 +478,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
||||
return this.age;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Object other) {
|
||||
if (this.name != null && other instanceof TestBean) {
|
||||
return this.name.compareTo(((TestBean) other).getName());
|
||||
|
||||
@@ -74,6 +74,7 @@ public class DummyFactory
|
||||
* Return if the bean managed by this factory is a singleton.
|
||||
* @see FactoryBean#isSingleton()
|
||||
*/
|
||||
@Override
|
||||
public boolean isSingleton() {
|
||||
return this.singleton;
|
||||
}
|
||||
@@ -85,6 +86,7 @@ public class DummyFactory
|
||||
this.singleton = singleton;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanName(String beanName) {
|
||||
this.beanName = beanName;
|
||||
}
|
||||
@@ -93,6 +95,7 @@ public class DummyFactory
|
||||
return beanName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) {
|
||||
this.beanFactory = (AutowireCapableBeanFactory) beanFactory;
|
||||
this.beanFactory.applyBeanPostProcessorsBeforeInitialization(this.testBean, this.beanName);
|
||||
@@ -119,6 +122,7 @@ public class DummyFactory
|
||||
return otherTestBean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
if (initialized) {
|
||||
throw new RuntimeException("Cannot call afterPropertiesSet twice on the one bean");
|
||||
@@ -144,6 +148,7 @@ public class DummyFactory
|
||||
* and prototype mode.
|
||||
* @see FactoryBean#getObject()
|
||||
*/
|
||||
@Override
|
||||
public Object getObject() throws BeansException {
|
||||
if (isSingleton()) {
|
||||
return this.testBean;
|
||||
@@ -158,11 +163,13 @@ public class DummyFactory
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getObjectType() {
|
||||
return TestBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
if (this.testBean != null) {
|
||||
this.testBean.setName(null);
|
||||
|
||||
@@ -23,6 +23,7 @@ public class MockRunnable implements Runnable {
|
||||
|
||||
private boolean executed = false;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
this.executed = true;
|
||||
}
|
||||
|
||||
@@ -41,10 +41,12 @@ public class MockHttpInputMessage implements HttpInputMessage {
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpHeaders getHeaders() {
|
||||
return headers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getBody() throws IOException {
|
||||
return body;
|
||||
}
|
||||
|
||||
@@ -30,10 +30,12 @@ public class MockHttpOutputMessage implements HttpOutputMessage {
|
||||
|
||||
private final ByteArrayOutputStream body = new ByteArrayOutputStream();
|
||||
|
||||
@Override
|
||||
public HttpHeaders getHeaders() {
|
||||
return headers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutputStream getBody() throws IOException {
|
||||
return body;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ public class BufferedSimpleHttpRequestFactoryTests extends AbstractHttpRequestFa
|
||||
return new SimpleClientHttpRequestFactory();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void httpMethods() throws Exception {
|
||||
try {
|
||||
|
||||
@@ -26,6 +26,7 @@ public class HttpComponentsClientHttpRequestFactoryTests extends AbstractHttpReq
|
||||
return new HttpComponentsClientHttpRequestFactory();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void httpMethods() throws Exception {
|
||||
assertHttpMethod("patch", HttpMethod.PATCH);
|
||||
|
||||
@@ -79,6 +79,7 @@ public class InterceptingClientHttpRequestFactoryTests {
|
||||
public void noExecution() throws Exception {
|
||||
List<ClientHttpRequestInterceptor> interceptors = new ArrayList<ClientHttpRequestInterceptor>();
|
||||
interceptors.add(new ClientHttpRequestInterceptor() {
|
||||
@Override
|
||||
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
|
||||
throws IOException {
|
||||
return responseMock;
|
||||
@@ -101,6 +102,7 @@ public class InterceptingClientHttpRequestFactoryTests {
|
||||
final String headerName = "Foo";
|
||||
final String headerValue = "Bar";
|
||||
ClientHttpRequestInterceptor interceptor = new ClientHttpRequestInterceptor() {
|
||||
@Override
|
||||
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
|
||||
throws IOException {
|
||||
|
||||
@@ -134,6 +136,7 @@ public class InterceptingClientHttpRequestFactoryTests {
|
||||
public void changeURI() throws Exception {
|
||||
final URI changedUri = new URI("http://example.com/2");
|
||||
ClientHttpRequestInterceptor interceptor = new ClientHttpRequestInterceptor() {
|
||||
@Override
|
||||
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
|
||||
throws IOException {
|
||||
|
||||
@@ -166,6 +169,7 @@ public class InterceptingClientHttpRequestFactoryTests {
|
||||
public void changeMethod() throws Exception {
|
||||
final HttpMethod changedMethod = HttpMethod.POST;
|
||||
ClientHttpRequestInterceptor interceptor = new ClientHttpRequestInterceptor() {
|
||||
@Override
|
||||
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
|
||||
throws IOException {
|
||||
|
||||
@@ -198,6 +202,7 @@ public class InterceptingClientHttpRequestFactoryTests {
|
||||
public void changeBody() throws Exception {
|
||||
final byte[] changedBody = "Foo".getBytes();
|
||||
ClientHttpRequestInterceptor interceptor = new ClientHttpRequestInterceptor() {
|
||||
@Override
|
||||
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
|
||||
throws IOException {
|
||||
|
||||
@@ -217,6 +222,7 @@ public class InterceptingClientHttpRequestFactoryTests {
|
||||
|
||||
private boolean invoked = false;
|
||||
|
||||
@Override
|
||||
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
|
||||
throws IOException {
|
||||
invoked = true;
|
||||
@@ -226,6 +232,7 @@ public class InterceptingClientHttpRequestFactoryTests {
|
||||
|
||||
private class RequestFactoryMock implements ClientHttpRequestFactory {
|
||||
|
||||
@Override
|
||||
public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IOException {
|
||||
requestMock.setURI(uri);
|
||||
requestMock.setMethod(httpMethod);
|
||||
@@ -249,6 +256,7 @@ public class InterceptingClientHttpRequestFactoryTests {
|
||||
private RequestMock() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public URI getURI() {
|
||||
return uri;
|
||||
}
|
||||
@@ -257,6 +265,7 @@ public class InterceptingClientHttpRequestFactoryTests {
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpMethod getMethod() {
|
||||
return method;
|
||||
}
|
||||
@@ -265,14 +274,17 @@ public class InterceptingClientHttpRequestFactoryTests {
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpHeaders getHeaders() {
|
||||
return headers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutputStream getBody() throws IOException {
|
||||
return body;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientHttpResponse execute() throws IOException {
|
||||
executed = true;
|
||||
return responseMock;
|
||||
@@ -287,26 +299,32 @@ public class InterceptingClientHttpRequestFactoryTests {
|
||||
|
||||
private HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
@Override
|
||||
public HttpStatus getStatusCode() throws IOException {
|
||||
return statusCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRawStatusCode() throws IOException {
|
||||
return statusCode.value();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStatusText() throws IOException {
|
||||
return statusText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpHeaders getHeaders() {
|
||||
return headers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getBody() throws IOException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ public class StreamingSimpleHttpRequestFactoryTests extends AbstractHttpRequestF
|
||||
final String headerName = "MyHeader";
|
||||
final String headerValue = "MyValue";
|
||||
ClientHttpRequestInterceptor interceptor = new ClientHttpRequestInterceptor() {
|
||||
@Override
|
||||
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
|
||||
throws IOException {
|
||||
request.getHeaders().add(headerName, headerValue);
|
||||
|
||||
@@ -167,20 +167,24 @@ public class FormHttpMessageConverterTests {
|
||||
this.outputMessage = outputMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCharacterEncoding() {
|
||||
MediaType contentType = outputMessage.getHeaders().getContentType();
|
||||
return contentType != null && contentType.getCharSet() != null ? contentType.getCharSet().name() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentType() {
|
||||
MediaType contentType = outputMessage.getHeaders().getContentType();
|
||||
return contentType != null ? contentType.toString() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getContentLength() {
|
||||
return outputMessage.getBodyAsBytes().length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream() throws IOException {
|
||||
return new ByteArrayInputStream(outputMessage.getBodyAsBytes());
|
||||
}
|
||||
|
||||
@@ -54,10 +54,12 @@ public class DelegatingServletInputStream extends ServletInputStream {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
return this.sourceStream.read();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
super.close();
|
||||
this.sourceStream.close();
|
||||
|
||||
@@ -54,15 +54,18 @@ public class DelegatingServletOutputStream extends ServletOutputStream {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
this.targetStream.write(b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() throws IOException {
|
||||
super.flush();
|
||||
this.targetStream.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
super.close();
|
||||
this.targetStream.close();
|
||||
|
||||
@@ -56,14 +56,17 @@ public class MockAsyncContext implements AsyncContext {
|
||||
this.response = (HttpServletResponse) response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletRequest getRequest() {
|
||||
return this.request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletResponse getResponse() {
|
||||
return this.response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOriginalRequestAndResponse() {
|
||||
return (this.request instanceof MockHttpServletRequest) && (this.response instanceof MockHttpServletResponse);
|
||||
}
|
||||
@@ -72,18 +75,22 @@ public class MockAsyncContext implements AsyncContext {
|
||||
return this.dispatchedPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispatch() {
|
||||
dispatch(this.request.getRequestURI());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispatch(String path) {
|
||||
dispatch(null, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispatch(ServletContext context, String path) {
|
||||
this.dispatchedPath = path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void complete() {
|
||||
MockHttpServletRequest mockRequest = WebUtils.getNativeRequest(request, MockHttpServletRequest.class);
|
||||
if (mockRequest != null) {
|
||||
@@ -99,6 +106,7 @@ public class MockAsyncContext implements AsyncContext {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Runnable runnable) {
|
||||
runnable.run();
|
||||
}
|
||||
@@ -107,22 +115,27 @@ public class MockAsyncContext implements AsyncContext {
|
||||
return this.listeners;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(AsyncListener listener) {
|
||||
this.listeners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(AsyncListener listener, ServletRequest request, ServletResponse response) {
|
||||
this.listeners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends AsyncListener> T createListener(Class<T> clazz) throws ServletException {
|
||||
return BeanUtils.instantiateClass(clazz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTimeout() {
|
||||
return this.timeout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTimeout(long timeout) {
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
@@ -77,14 +77,17 @@ public class MockBodyContent extends BodyContent {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Reader getReader() {
|
||||
return new StringReader(this.content);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString() {
|
||||
return this.content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeOut(Writer writer) throws IOException {
|
||||
writer.write(this.content);
|
||||
}
|
||||
@@ -94,102 +97,127 @@ public class MockBodyContent extends BodyContent {
|
||||
// Delegating implementations of JspWriter's abstract methods
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public void clear() throws IOException {
|
||||
getEnclosingWriter().clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearBuffer() throws IOException {
|
||||
getEnclosingWriter().clearBuffer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
getEnclosingWriter().close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRemaining() {
|
||||
return getEnclosingWriter().getRemaining();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void newLine() throws IOException {
|
||||
getEnclosingWriter().println();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(char value[], int offset, int length) throws IOException {
|
||||
getEnclosingWriter().write(value, offset, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(boolean value) throws IOException {
|
||||
getEnclosingWriter().print(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(char value) throws IOException {
|
||||
getEnclosingWriter().print(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(char[] value) throws IOException {
|
||||
getEnclosingWriter().print(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(double value) throws IOException {
|
||||
getEnclosingWriter().print(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(float value) throws IOException {
|
||||
getEnclosingWriter().print(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(int value) throws IOException {
|
||||
getEnclosingWriter().print(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(long value) throws IOException {
|
||||
getEnclosingWriter().print(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(Object value) throws IOException {
|
||||
getEnclosingWriter().print(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(String value) throws IOException {
|
||||
getEnclosingWriter().print(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println() throws IOException {
|
||||
getEnclosingWriter().println();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(boolean value) throws IOException {
|
||||
getEnclosingWriter().println(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(char value) throws IOException {
|
||||
getEnclosingWriter().println(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(char[] value) throws IOException {
|
||||
getEnclosingWriter().println(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(double value) throws IOException {
|
||||
getEnclosingWriter().println(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(float value) throws IOException {
|
||||
getEnclosingWriter().println(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(int value) throws IOException {
|
||||
getEnclosingWriter().println(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(long value) throws IOException {
|
||||
getEnclosingWriter().println(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(Object value) throws IOException {
|
||||
getEnclosingWriter().println(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(String value) throws IOException {
|
||||
getEnclosingWriter().println(value);
|
||||
}
|
||||
|
||||
@@ -53,17 +53,20 @@ public class MockExpressionEvaluator extends ExpressionEvaluator {
|
||||
this.pageContext = pageContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Expression parseExpression(
|
||||
final String expression, final Class expectedType, final FunctionMapper functionMapper)
|
||||
throws ELException {
|
||||
|
||||
return new Expression() {
|
||||
@Override
|
||||
public Object evaluate(VariableResolver variableResolver) throws ELException {
|
||||
return doEvaluate(expression, expectedType, functionMapper);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object evaluate(
|
||||
String expression, Class expectedType, VariableResolver variableResolver, FunctionMapper functionMapper)
|
||||
throws ELException {
|
||||
|
||||
@@ -117,6 +117,7 @@ public class MockFilterChain implements FilterChain {
|
||||
* Invoke registered {@link Filter}s and/or {@link Servlet} also saving the
|
||||
* request and response.
|
||||
*/
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
|
||||
Assert.notNull(request, "Request must not be null");
|
||||
Assert.notNull(response, "Response must not be null");
|
||||
@@ -160,15 +161,18 @@ public class MockFilterChain implements FilterChain {
|
||||
this.delegateServlet = servlet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
|
||||
throws IOException, ServletException {
|
||||
|
||||
this.delegateServlet.service(request, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
}
|
||||
|
||||
|
||||
@@ -79,10 +79,12 @@ public class MockFilterConfig implements FilterConfig {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getFilterName() {
|
||||
return filterName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletContext getServletContext() {
|
||||
return servletContext;
|
||||
}
|
||||
@@ -92,11 +94,13 @@ public class MockFilterConfig implements FilterConfig {
|
||||
this.initParameters.put(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInitParameter(String name) {
|
||||
Assert.notNull(name, "Parameter name must not be null");
|
||||
return this.initParameters.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getInitParameterNames() {
|
||||
return Collections.enumeration(this.initParameters.keySet());
|
||||
}
|
||||
|
||||
@@ -264,6 +264,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
* Return the ServletContext that this request is associated with. (Not
|
||||
* available in the standard HttpServletRequest interface for some reason.)
|
||||
*/
|
||||
@Override
|
||||
public ServletContext getServletContext() {
|
||||
return this.servletContext;
|
||||
}
|
||||
@@ -305,20 +306,24 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
// ServletRequest interface
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public Object getAttribute(String name) {
|
||||
checkActive();
|
||||
return this.attributes.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getAttributeNames() {
|
||||
checkActive();
|
||||
return Collections.enumeration(this.attributes.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCharacterEncoding() {
|
||||
return this.characterEncoding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCharacterEncoding(String characterEncoding) {
|
||||
this.characterEncoding = characterEncoding;
|
||||
updateContentTypeHeader();
|
||||
@@ -338,6 +343,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getContentLength() {
|
||||
return (this.content != null ? this.content.length : -1);
|
||||
}
|
||||
@@ -354,10 +360,12 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return this.contentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletInputStream getInputStream() {
|
||||
if (this.content != null) {
|
||||
return new DelegatingServletInputStream(new ByteArrayInputStream(this.content));
|
||||
@@ -480,21 +488,25 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.parameters.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParameter(String name) {
|
||||
Assert.notNull(name, "Parameter name must not be null");
|
||||
String[] arr = this.parameters.get(name);
|
||||
return (arr != null && arr.length > 0 ? arr[0] : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getParameterNames() {
|
||||
return Collections.enumeration(this.parameters.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getParameterValues(String name) {
|
||||
Assert.notNull(name, "Parameter name must not be null");
|
||||
return this.parameters.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String[]> getParameterMap() {
|
||||
return Collections.unmodifiableMap(this.parameters);
|
||||
}
|
||||
@@ -503,6 +515,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.protocol = protocol;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProtocol() {
|
||||
return this.protocol;
|
||||
}
|
||||
@@ -511,6 +524,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.scheme = scheme;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getScheme() {
|
||||
return this.scheme;
|
||||
}
|
||||
@@ -519,6 +533,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.serverName = serverName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServerName() {
|
||||
return this.serverName;
|
||||
}
|
||||
@@ -527,10 +542,12 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.serverPort = serverPort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getServerPort() {
|
||||
return this.serverPort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BufferedReader getReader() throws UnsupportedEncodingException {
|
||||
if (this.content != null) {
|
||||
InputStream sourceStream = new ByteArrayInputStream(this.content);
|
||||
@@ -547,6 +564,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.remoteAddr = remoteAddr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRemoteAddr() {
|
||||
return this.remoteAddr;
|
||||
}
|
||||
@@ -555,10 +573,12 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.remoteHost = remoteHost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRemoteHost() {
|
||||
return this.remoteHost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String name, Object value) {
|
||||
checkActive();
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
@@ -570,6 +590,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttribute(String name) {
|
||||
checkActive();
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
@@ -604,10 +625,12 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.locales.addAll(locales);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
return this.locales.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<Locale> getLocales() {
|
||||
return Collections.enumeration(this.locales);
|
||||
}
|
||||
@@ -616,14 +639,17 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.secure = secure;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSecure() {
|
||||
return this.secure;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RequestDispatcher getRequestDispatcher(String path) {
|
||||
return new MockRequestDispatcher(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRealPath(String path) {
|
||||
return this.servletContext.getRealPath(path);
|
||||
}
|
||||
@@ -632,6 +658,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.remotePort = remotePort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRemotePort() {
|
||||
return this.remotePort;
|
||||
}
|
||||
@@ -640,6 +667,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.localName = localName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocalName() {
|
||||
return this.localName;
|
||||
}
|
||||
@@ -648,6 +676,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.localAddr = localAddr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocalAddr() {
|
||||
return this.localAddr;
|
||||
}
|
||||
@@ -656,6 +685,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.localPort = localPort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLocalPort() {
|
||||
return this.localPort;
|
||||
}
|
||||
@@ -669,6 +699,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.authType = authType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthType() {
|
||||
return this.authType;
|
||||
}
|
||||
@@ -677,6 +708,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.cookies = cookies;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cookie[] getCookies() {
|
||||
return this.cookies;
|
||||
}
|
||||
@@ -725,6 +757,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDateHeader(String name) {
|
||||
HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name);
|
||||
Object value = (header != null ? header.getValue() : null);
|
||||
@@ -743,20 +776,24 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHeader(String name) {
|
||||
HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name);
|
||||
return (header != null ? header.getValue().toString() : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getHeaders(String name) {
|
||||
HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name);
|
||||
return Collections.enumeration(header != null ? header.getStringValues() : new LinkedList<String>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getHeaderNames() {
|
||||
return Collections.enumeration(this.headers.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntHeader(String name) {
|
||||
HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name);
|
||||
Object value = (header != null ? header.getValue() : null);
|
||||
@@ -778,6 +815,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return this.method;
|
||||
}
|
||||
@@ -786,10 +824,12 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.pathInfo = pathInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPathInfo() {
|
||||
return this.pathInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPathTranslated() {
|
||||
return (this.pathInfo != null ? getRealPath(this.pathInfo) : null);
|
||||
}
|
||||
@@ -798,6 +838,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.contextPath = contextPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContextPath() {
|
||||
return this.contextPath;
|
||||
}
|
||||
@@ -806,6 +847,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.queryString = queryString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQueryString() {
|
||||
return this.queryString;
|
||||
}
|
||||
@@ -814,6 +856,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.remoteUser = remoteUser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRemoteUser() {
|
||||
return this.remoteUser;
|
||||
}
|
||||
@@ -822,6 +865,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.userRoles.add(role);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUserInRole(String role) {
|
||||
return (this.userRoles.contains(role) || (this.servletContext instanceof MockServletContext && ((MockServletContext) this.servletContext).getDeclaredRoles().contains(
|
||||
role)));
|
||||
@@ -831,6 +875,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.userPrincipal = userPrincipal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Principal getUserPrincipal() {
|
||||
return this.userPrincipal;
|
||||
}
|
||||
@@ -839,6 +884,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.requestedSessionId = requestedSessionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRequestedSessionId() {
|
||||
return this.requestedSessionId;
|
||||
}
|
||||
@@ -847,10 +893,12 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.requestURI = requestURI;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRequestURI() {
|
||||
return this.requestURI;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StringBuffer getRequestURL() {
|
||||
StringBuffer url = new StringBuffer(this.scheme);
|
||||
url.append("://").append(this.serverName).append(':').append(this.serverPort);
|
||||
@@ -862,6 +910,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.servletPath = servletPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServletPath() {
|
||||
return this.servletPath;
|
||||
}
|
||||
@@ -874,6 +923,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpSession getSession(boolean create) {
|
||||
checkActive();
|
||||
// Reset session if invalidated.
|
||||
@@ -887,6 +937,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
return this.session;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpSession getSession() {
|
||||
return getSession(true);
|
||||
}
|
||||
@@ -895,6 +946,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.requestedSessionIdValid = requestedSessionIdValid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRequestedSessionIdValid() {
|
||||
return this.requestedSessionIdValid;
|
||||
}
|
||||
@@ -903,6 +955,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.requestedSessionIdFromCookie = requestedSessionIdFromCookie;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRequestedSessionIdFromCookie() {
|
||||
return this.requestedSessionIdFromCookie;
|
||||
}
|
||||
@@ -911,10 +964,12 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.requestedSessionIdFromURL = requestedSessionIdFromURL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRequestedSessionIdFromURL() {
|
||||
return this.requestedSessionIdFromURL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRequestedSessionIdFromUrl() {
|
||||
return isRequestedSessionIdFromURL();
|
||||
}
|
||||
@@ -924,6 +979,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
// Methods introduced in Servlet 3.0
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public AsyncContext getAsyncContext() {
|
||||
return this.asyncContext;
|
||||
}
|
||||
@@ -932,6 +988,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.asyncContext = asyncContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DispatcherType getDispatcherType() {
|
||||
return this.dispatcherType;
|
||||
}
|
||||
@@ -944,14 +1001,17 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.asyncSupported = asyncSupported;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAsyncSupported() {
|
||||
return this.asyncSupported;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncContext startAsync() {
|
||||
return startAsync(this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncContext startAsync(ServletRequest request, ServletResponse response) {
|
||||
if (!this.asyncSupported) {
|
||||
throw new IllegalStateException("Async not supported");
|
||||
@@ -965,10 +1025,12 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.asyncStarted = asyncStarted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAsyncStarted() {
|
||||
return this.asyncStarted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean authenticate(HttpServletResponse arg0) throws IOException, ServletException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
@@ -977,18 +1039,22 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
parts.put(part.getName(), part);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Part getPart(String key) throws IOException, IllegalStateException, ServletException {
|
||||
return parts.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Part> getParts() throws IOException, IllegalStateException, ServletException {
|
||||
return parts.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void login(String arg0, String arg1) throws ServletException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logout() throws ServletException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@@ -138,6 +138,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
return this.writerAccessAllowed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCharacterEncoding(String characterEncoding) {
|
||||
this.characterEncoding = characterEncoding;
|
||||
this.charset = true;
|
||||
@@ -154,10 +155,12 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCharacterEncoding() {
|
||||
return this.characterEncoding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletOutputStream getOutputStream() {
|
||||
if (!this.outputStreamAccessAllowed) {
|
||||
throw new IllegalStateException("OutputStream access not allowed");
|
||||
@@ -165,6 +168,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
return this.outputStream;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrintWriter getWriter() throws UnsupportedEncodingException {
|
||||
if (!this.writerAccessAllowed) {
|
||||
throw new IllegalStateException("Writer access not allowed");
|
||||
@@ -188,6 +192,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
this.content.toString(this.characterEncoding) : this.content.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContentLength(int contentLength) {
|
||||
this.contentLength = contentLength;
|
||||
doAddHeaderValue(CONTENT_LENGTH_HEADER, contentLength, true);
|
||||
@@ -197,6 +202,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
return this.contentLength;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContentType(String contentType) {
|
||||
this.contentType = contentType;
|
||||
if (contentType != null) {
|
||||
@@ -210,22 +216,27 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return this.contentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBufferSize(int bufferSize) {
|
||||
this.bufferSize = bufferSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBufferSize() {
|
||||
return this.bufferSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flushBuffer() {
|
||||
setCommitted(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetBuffer() {
|
||||
if (isCommitted()) {
|
||||
throw new IllegalStateException("Cannot reset buffer - response is already committed");
|
||||
@@ -244,10 +255,12 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
this.committed = committed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommitted() {
|
||||
return this.committed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
resetBuffer();
|
||||
this.characterEncoding = null;
|
||||
@@ -260,10 +273,12 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
this.errorMessage = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocale(Locale locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
return this.locale;
|
||||
}
|
||||
@@ -273,6 +288,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
// HttpServletResponse interface
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public void addCookie(Cookie cookie) {
|
||||
Assert.notNull(cookie, "Cookie must not be null");
|
||||
this.cookies.add(cookie);
|
||||
@@ -292,6 +308,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsHeader(String name) {
|
||||
return (HeaderValueHolder.getByName(this.headers, name) != null);
|
||||
}
|
||||
@@ -301,6 +318,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
* <p>As of Servlet 3.0, this method is also defined HttpServletResponse.
|
||||
* @return the {@code Set} of header name {@code Strings}, or an empty {@code Set} if none
|
||||
*/
|
||||
@Override
|
||||
public Set<String> getHeaderNames() {
|
||||
return this.headers.keySet();
|
||||
}
|
||||
@@ -314,6 +332,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
* @param name the name of the header
|
||||
* @return the associated header value, or {@code null} if none
|
||||
*/
|
||||
@Override
|
||||
public String getHeader(String name) {
|
||||
HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name);
|
||||
return (header != null ? header.getStringValue() : null);
|
||||
@@ -327,6 +346,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
* @param name the name of the header
|
||||
* @return the associated header values, or an empty List if none
|
||||
*/
|
||||
@Override
|
||||
public List<String> getHeaders(String name) {
|
||||
HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name);
|
||||
if (header != null) {
|
||||
@@ -367,6 +387,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
* The default implementation returns the given URL String as-is.
|
||||
* <p>Can be overridden in subclasses, appending a session id or the like.
|
||||
*/
|
||||
@Override
|
||||
public String encodeURL(String url) {
|
||||
return url;
|
||||
}
|
||||
@@ -379,18 +400,22 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
* override the common {@link #encodeURL} method instead, applying
|
||||
* to redirect URLs as well as to general URLs.
|
||||
*/
|
||||
@Override
|
||||
public String encodeRedirectURL(String url) {
|
||||
return encodeURL(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String encodeUrl(String url) {
|
||||
return encodeURL(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String encodeRedirectUrl(String url) {
|
||||
return encodeRedirectURL(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendError(int status, String errorMessage) throws IOException {
|
||||
if (isCommitted()) {
|
||||
throw new IllegalStateException("Cannot set error status - response is already committed");
|
||||
@@ -400,6 +425,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
setCommitted(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendError(int status) throws IOException {
|
||||
if (isCommitted()) {
|
||||
throw new IllegalStateException("Cannot set error status - response is already committed");
|
||||
@@ -408,6 +434,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
setCommitted(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRedirect(String url) throws IOException {
|
||||
if (isCommitted()) {
|
||||
throw new IllegalStateException("Cannot send redirect - response is already committed");
|
||||
@@ -422,26 +449,32 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
return getHeader(LOCATION_HEADER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDateHeader(String name, long value) {
|
||||
setHeaderValue(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDateHeader(String name, long value) {
|
||||
addHeaderValue(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeader(String name, String value) {
|
||||
setHeaderValue(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addHeader(String name, String value) {
|
||||
addHeaderValue(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIntHeader(String name, int value) {
|
||||
setHeaderValue(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addIntHeader(String name, int value) {
|
||||
addHeaderValue(name, value);
|
||||
}
|
||||
@@ -489,15 +522,18 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStatus(int status, String errorMessage) {
|
||||
this.status = status;
|
||||
this.errorMessage = errorMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
@@ -555,12 +591,14 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
super(out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
super.write(b);
|
||||
super.flush();
|
||||
setCommittedIfBufferSizeExceeded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() throws IOException {
|
||||
super.flush();
|
||||
setCommitted(true);
|
||||
@@ -578,24 +616,28 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
super(out, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(char buf[], int off, int len) {
|
||||
super.write(buf, off, len);
|
||||
super.flush();
|
||||
setCommittedIfBufferSizeExceeded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(String s, int off, int len) {
|
||||
super.write(s, off, len);
|
||||
super.flush();
|
||||
setCommittedIfBufferSizeExceeded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int c) {
|
||||
super.write(c);
|
||||
super.flush();
|
||||
setCommittedIfBufferSizeExceeded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
super.flush();
|
||||
setCommitted(true);
|
||||
|
||||
@@ -98,10 +98,12 @@ public class MockHttpSession implements HttpSession {
|
||||
this.id = (id != null ? id : Integer.toString(nextId++));
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCreationTime() {
|
||||
return this.creationTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
@@ -111,43 +113,53 @@ public class MockHttpSession implements HttpSession {
|
||||
this.isNew = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastAccessedTime() {
|
||||
return this.lastAccessedTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletContext getServletContext() {
|
||||
return this.servletContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxInactiveInterval(int interval) {
|
||||
this.maxInactiveInterval = interval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxInactiveInterval() {
|
||||
return this.maxInactiveInterval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpSessionContext getSessionContext() {
|
||||
throw new UnsupportedOperationException("getSessionContext");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getAttribute(String name) {
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
return this.attributes.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(String name) {
|
||||
return getAttribute(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getAttributeNames() {
|
||||
return Collections.enumeration(this.attributes.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getValueNames() {
|
||||
return this.attributes.keySet().toArray(new String[this.attributes.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String name, Object value) {
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
if (value != null) {
|
||||
@@ -161,10 +173,12 @@ public class MockHttpSession implements HttpSession {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putValue(String name, Object value) {
|
||||
setAttribute(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttribute(String name) {
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
Object value = this.attributes.remove(name);
|
||||
@@ -173,6 +187,7 @@ public class MockHttpSession implements HttpSession {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeValue(String name) {
|
||||
removeAttribute(name);
|
||||
}
|
||||
@@ -197,6 +212,7 @@ public class MockHttpSession implements HttpSession {
|
||||
*
|
||||
* @throws IllegalStateException if this method is called on an already invalidated session
|
||||
*/
|
||||
@Override
|
||||
public void invalidate() {
|
||||
if (this.invalid) {
|
||||
throw new IllegalStateException("The session has already been invalidated");
|
||||
@@ -215,6 +231,7 @@ public class MockHttpSession implements HttpSession {
|
||||
this.isNew = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew() {
|
||||
return this.isNew;
|
||||
}
|
||||
|
||||
@@ -82,6 +82,7 @@ public class MockJspWriter extends JspWriter {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void clear() throws IOException {
|
||||
if (this.response.isCommitted()) {
|
||||
throw new IOException("Response already committed");
|
||||
@@ -89,101 +90,126 @@ public class MockJspWriter extends JspWriter {
|
||||
this.response.resetBuffer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearBuffer() throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() throws IOException {
|
||||
this.response.flushBuffer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRemaining() {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void newLine() throws IOException {
|
||||
getTargetWriter().println();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(char value[], int offset, int length) throws IOException {
|
||||
getTargetWriter().write(value, offset, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(boolean value) throws IOException {
|
||||
getTargetWriter().print(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(char value) throws IOException {
|
||||
getTargetWriter().print(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(char[] value) throws IOException {
|
||||
getTargetWriter().print(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(double value) throws IOException {
|
||||
getTargetWriter().print(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(float value) throws IOException {
|
||||
getTargetWriter().print(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(int value) throws IOException {
|
||||
getTargetWriter().print(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(long value) throws IOException {
|
||||
getTargetWriter().print(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(Object value) throws IOException {
|
||||
getTargetWriter().print(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(String value) throws IOException {
|
||||
getTargetWriter().print(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println() throws IOException {
|
||||
getTargetWriter().println();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(boolean value) throws IOException {
|
||||
getTargetWriter().println(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(char value) throws IOException {
|
||||
getTargetWriter().println(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(char[] value) throws IOException {
|
||||
getTargetWriter().println(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(double value) throws IOException {
|
||||
getTargetWriter().println(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(float value) throws IOException {
|
||||
getTargetWriter().println(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(int value) throws IOException {
|
||||
getTargetWriter().println(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(long value) throws IOException {
|
||||
getTargetWriter().println(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(Object value) throws IOException {
|
||||
getTargetWriter().println(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(String value) throws IOException {
|
||||
getTargetWriter().println(value);
|
||||
}
|
||||
|
||||
@@ -96,34 +96,42 @@ public class MockMultipartFile implements MultipartFile {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOriginalFilename() {
|
||||
return this.originalFilename;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return this.contentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return (this.content.length == 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSize() {
|
||||
return this.content.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBytes() throws IOException {
|
||||
return this.content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream() throws IOException {
|
||||
return new ByteArrayInputStream(this.content);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transferTo(File dest) throws IOException, IllegalStateException {
|
||||
FileCopyUtils.copy(this.content, dest);
|
||||
}
|
||||
|
||||
@@ -66,14 +66,17 @@ public class MockMultipartHttpServletRequest extends MockHttpServletRequest impl
|
||||
this.multipartFiles.add(file.getName(), file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<String> getFileNames() {
|
||||
return this.multipartFiles.keySet().iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultipartFile getFile(String name) {
|
||||
return this.multipartFiles.getFirst(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MultipartFile> getFiles(String name) {
|
||||
List<MultipartFile> multipartFiles = this.multipartFiles.get(name);
|
||||
if (multipartFiles != null) {
|
||||
@@ -84,14 +87,17 @@ public class MockMultipartHttpServletRequest extends MockHttpServletRequest impl
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, MultipartFile> getFileMap() {
|
||||
return this.multipartFiles.toSingleValueMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiValueMap<String, MultipartFile> getMultiFileMap() {
|
||||
return new LinkedMultiValueMap<String, MultipartFile>(this.multipartFiles);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMultipartContentType(String paramOrFileName) {
|
||||
MultipartFile file = getFile(paramOrFileName);
|
||||
if (file != null) {
|
||||
@@ -102,10 +108,12 @@ public class MockMultipartHttpServletRequest extends MockHttpServletRequest impl
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpMethod getRequestMethod() {
|
||||
return HttpMethod.valueOf(getMethod());
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpHeaders getRequestHeaders() {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
Enumeration<String> headerNames = getHeaderNames();
|
||||
@@ -116,6 +124,7 @@ public class MockMultipartHttpServletRequest extends MockHttpServletRequest impl
|
||||
return headers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpHeaders getMultipartHeaders(String paramOrFileName) {
|
||||
String contentType = getMultipartContentType(paramOrFileName);
|
||||
if (contentType != null) {
|
||||
|
||||
@@ -125,6 +125,7 @@ public class MockPageContext extends PageContext {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void initialize(
|
||||
Servlet servlet, ServletRequest request, ServletResponse response,
|
||||
String errorPageURL, boolean needsSession, int bufferSize, boolean autoFlush) {
|
||||
@@ -132,9 +133,11 @@ public class MockPageContext extends PageContext {
|
||||
throw new UnsupportedOperationException("Use appropriate constructor");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void release() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String name, Object value) {
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
if (value != null) {
|
||||
@@ -145,6 +148,7 @@ public class MockPageContext extends PageContext {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String name, Object value, int scope) {
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
switch (scope) {
|
||||
@@ -165,11 +169,13 @@ public class MockPageContext extends PageContext {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getAttribute(String name) {
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
return this.attributes.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getAttribute(String name, int scope) {
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
switch (scope) {
|
||||
@@ -187,6 +193,7 @@ public class MockPageContext extends PageContext {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object findAttribute(String name) {
|
||||
Object value = getAttribute(name);
|
||||
if (value == null) {
|
||||
@@ -201,6 +208,7 @@ public class MockPageContext extends PageContext {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttribute(String name) {
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
this.removeAttribute(name, PageContext.PAGE_SCOPE);
|
||||
@@ -209,6 +217,7 @@ public class MockPageContext extends PageContext {
|
||||
this.removeAttribute(name, PageContext.APPLICATION_SCOPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttribute(String name, int scope) {
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
switch (scope) {
|
||||
@@ -229,6 +238,7 @@ public class MockPageContext extends PageContext {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAttributesScope(String name) {
|
||||
if (getAttribute(name) != null) {
|
||||
return PAGE_SCOPE;
|
||||
@@ -251,6 +261,7 @@ public class MockPageContext extends PageContext {
|
||||
return Collections.enumeration(this.attributes.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Enumeration<String> getAttributeNamesInScope(int scope) {
|
||||
switch (scope) {
|
||||
@@ -268,6 +279,7 @@ public class MockPageContext extends PageContext {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JspWriter getOut() {
|
||||
if (this.out == null) {
|
||||
this.out = new MockJspWriter(this.response);
|
||||
@@ -275,54 +287,67 @@ public class MockPageContext extends PageContext {
|
||||
return this.out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionEvaluator getExpressionEvaluator() {
|
||||
return new MockExpressionEvaluator(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ELContext getELContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VariableResolver getVariableResolver() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpSession getSession() {
|
||||
return this.request.getSession();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPage() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletRequest getRequest() {
|
||||
return this.request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletResponse getResponse() {
|
||||
return this.response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Exception getException() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletConfig getServletConfig() {
|
||||
return this.servletConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletContext getServletContext() {
|
||||
return this.servletContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forward(String path) throws ServletException, IOException {
|
||||
this.request.getRequestDispatcher(path).forward(this.request, this.response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void include(String path) throws ServletException, IOException {
|
||||
this.request.getRequestDispatcher(path).include(this.request, this.response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void include(String path, boolean flush) throws ServletException, IOException {
|
||||
this.request.getRequestDispatcher(path).include(this.request, this.response);
|
||||
if (flush) {
|
||||
@@ -340,10 +365,12 @@ public class MockPageContext extends PageContext {
|
||||
return ((MockHttpServletResponse) this.response).getContentAsString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePageException(Exception ex) throws ServletException, IOException {
|
||||
throw new ServletException("Page exception", ex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePageException(Throwable ex) throws ServletException, IOException {
|
||||
throw new ServletException("Page exception", ex);
|
||||
}
|
||||
|
||||
@@ -90,22 +90,27 @@ public class MockPart implements Part {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return this.contentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSize() {
|
||||
return this.content.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream() throws IOException {
|
||||
return new ByteArrayInputStream(this.content);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHeader(String name) {
|
||||
if (CONTENT_TYPE.equalsIgnoreCase(name)) {
|
||||
return this.contentType;
|
||||
@@ -115,6 +120,7 @@ public class MockPart implements Part {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getHeaders(String name) {
|
||||
if (CONTENT_TYPE.equalsIgnoreCase(name)) {
|
||||
return Collections.singleton(this.contentType);
|
||||
@@ -124,14 +130,17 @@ public class MockPart implements Part {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getHeaderNames() {
|
||||
return Collections.singleton(CONTENT_TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(String fileName) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete() throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ public class MockRequestDispatcher implements RequestDispatcher {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void forward(ServletRequest request, ServletResponse response) {
|
||||
Assert.notNull(request, "Request must not be null");
|
||||
Assert.notNull(response, "Response must not be null");
|
||||
@@ -67,6 +68,7 @@ public class MockRequestDispatcher implements RequestDispatcher {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void include(ServletRequest request, ServletResponse response) {
|
||||
Assert.notNull(request, "Request must not be null");
|
||||
Assert.notNull(response, "Response must not be null");
|
||||
|
||||
@@ -78,10 +78,12 @@ public class MockServletConfig implements ServletConfig {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getServletName() {
|
||||
return this.servletName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletContext getServletContext() {
|
||||
return this.servletContext;
|
||||
}
|
||||
@@ -91,11 +93,13 @@ public class MockServletConfig implements ServletConfig {
|
||||
this.initParameters.put(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInitParameter(String name) {
|
||||
Assert.notNull(name, "Parameter name must not be null");
|
||||
return this.initParameters.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getInitParameterNames() {
|
||||
return Collections.enumeration(this.initParameters.keySet());
|
||||
}
|
||||
|
||||
@@ -205,6 +205,7 @@ public class MockServletContext implements ServletContext {
|
||||
}
|
||||
|
||||
/* This is a Servlet API 2.5 method. */
|
||||
@Override
|
||||
public String getContextPath() {
|
||||
return this.contextPath;
|
||||
}
|
||||
@@ -213,6 +214,7 @@ public class MockServletContext implements ServletContext {
|
||||
this.contexts.put(contextPath, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletContext getContext(String contextPath) {
|
||||
if (this.contextPath.equals(contextPath)) {
|
||||
return this;
|
||||
@@ -224,6 +226,7 @@ public class MockServletContext implements ServletContext {
|
||||
this.majorVersion = majorVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMajorVersion() {
|
||||
return this.majorVersion;
|
||||
}
|
||||
@@ -232,6 +235,7 @@ public class MockServletContext implements ServletContext {
|
||||
this.minorVersion = minorVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinorVersion() {
|
||||
return this.minorVersion;
|
||||
}
|
||||
@@ -240,6 +244,7 @@ public class MockServletContext implements ServletContext {
|
||||
this.effectiveMajorVersion = effectiveMajorVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEffectiveMajorVersion() {
|
||||
return this.effectiveMajorVersion;
|
||||
}
|
||||
@@ -248,14 +253,17 @@ public class MockServletContext implements ServletContext {
|
||||
this.effectiveMinorVersion = effectiveMinorVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEffectiveMinorVersion() {
|
||||
return this.effectiveMinorVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMimeType(String filePath) {
|
||||
return MimeTypeResolver.getMimeType(filePath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getResourcePaths(String path) {
|
||||
String actualPath = (path.endsWith("/") ? path : path + "/");
|
||||
Resource resource = this.resourceLoader.getResource(getResourceLocation(actualPath));
|
||||
@@ -281,6 +289,7 @@ public class MockServletContext implements ServletContext {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getResource(String path) throws MalformedURLException {
|
||||
Resource resource = this.resourceLoader.getResource(getResourceLocation(path));
|
||||
if (!resource.exists()) {
|
||||
@@ -298,6 +307,7 @@ public class MockServletContext implements ServletContext {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getResourceAsStream(String path) {
|
||||
Resource resource = this.resourceLoader.getResource(getResourceLocation(path));
|
||||
if (!resource.exists()) {
|
||||
@@ -312,6 +322,7 @@ public class MockServletContext implements ServletContext {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RequestDispatcher getRequestDispatcher(String path) {
|
||||
if (!path.startsWith("/")) {
|
||||
throw new IllegalArgumentException("RequestDispatcher path at ServletContext level must start with '/'");
|
||||
@@ -319,6 +330,7 @@ public class MockServletContext implements ServletContext {
|
||||
return new MockRequestDispatcher(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RequestDispatcher getNamedDispatcher(String path) {
|
||||
return this.namedRequestDispatchers.get(path);
|
||||
}
|
||||
@@ -376,30 +388,37 @@ public class MockServletContext implements ServletContext {
|
||||
registerNamedDispatcher(this.defaultServletName, new MockRequestDispatcher(this.defaultServletName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Servlet getServlet(String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<Servlet> getServlets() {
|
||||
return Collections.enumeration(new HashSet<Servlet>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getServletNames() {
|
||||
return Collections.enumeration(new HashSet<String>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(String message) {
|
||||
logger.info(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(Exception ex, String message) {
|
||||
logger.info(message, ex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(String message, Throwable ex) {
|
||||
logger.info(message, ex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRealPath(String path) {
|
||||
Resource resource = this.resourceLoader.getResource(getResourceLocation(path));
|
||||
try {
|
||||
@@ -411,19 +430,23 @@ public class MockServletContext implements ServletContext {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServerInfo() {
|
||||
return "MockServletContext";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInitParameter(String name) {
|
||||
Assert.notNull(name, "Parameter name must not be null");
|
||||
return this.initParameters.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getInitParameterNames() {
|
||||
return Collections.enumeration(this.initParameters.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setInitParameter(String name, String value) {
|
||||
Assert.notNull(name, "Parameter name must not be null");
|
||||
if (this.initParameters.containsKey(name)) {
|
||||
@@ -438,15 +461,18 @@ public class MockServletContext implements ServletContext {
|
||||
this.initParameters.put(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getAttribute(String name) {
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
return this.attributes.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getAttributeNames() {
|
||||
return Collections.enumeration(this.attributes.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String name, Object value) {
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
if (value != null) {
|
||||
@@ -457,6 +483,7 @@ public class MockServletContext implements ServletContext {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttribute(String name) {
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
this.attributes.remove(name);
|
||||
@@ -466,14 +493,17 @@ public class MockServletContext implements ServletContext {
|
||||
this.servletContextName = servletContextName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServletContextName() {
|
||||
return this.servletContextName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassLoader getClassLoader() {
|
||||
return ClassUtils.getDefaultClassLoader();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void declareRoles(String... roleNames) {
|
||||
Assert.notNull(roleNames, "Role names array must not be null");
|
||||
for (String roleName : roleNames) {
|
||||
@@ -503,90 +533,111 @@ public class MockServletContext implements ServletContext {
|
||||
// Methods introduced in Servlet 3.0
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public FilterRegistration.Dynamic addFilter(String filterName, String className) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FilterRegistration.Dynamic addFilter(String filterName, Filter filter) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FilterRegistration.Dynamic addFilter(String filterName, Class<? extends Filter> filterClass) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(Class<? extends EventListener> listenerClass) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(String className) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends EventListener> void addListener(T t) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletRegistration.Dynamic addServlet(String servletName, String className) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletRegistration.Dynamic addServlet(String servletName, Servlet servlet) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletRegistration.Dynamic addServlet(String servletName,
|
||||
Class<? extends Servlet> servletClass) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Filter> T createFilter(Class<T> c)
|
||||
throws ServletException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends EventListener> T createListener(Class<T> c)
|
||||
throws ServletException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Servlet> T createServlet(Class<T> c)
|
||||
throws ServletException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<SessionTrackingMode> getDefaultSessionTrackingModes() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<SessionTrackingMode> getEffectiveSessionTrackingModes() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FilterRegistration getFilterRegistration(String filterName) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, ? extends FilterRegistration> getFilterRegistrations() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JspConfigDescriptor getJspConfigDescriptor() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletRegistration getServletRegistration(String servletName) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, ? extends ServletRegistration> getServletRegistrations() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionCookieConfig getSessionCookieConfig() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSessionTrackingModes(Set<SessionTrackingMode> sessionTrackingModes)
|
||||
throws IllegalStateException, IllegalArgumentException {
|
||||
throw new UnsupportedOperationException();
|
||||
|
||||
@@ -73,6 +73,7 @@ public class PassThroughFilterChain implements FilterChain {
|
||||
/**
|
||||
* Pass the call on to the Filter/Servlet.
|
||||
*/
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response) throws ServletException, IOException {
|
||||
if (this.filter != null) {
|
||||
this.filter.doFilter(request, response, this.nextFilterChain);
|
||||
|
||||
@@ -219,14 +219,17 @@ public class CauchoRemotingTests extends TestCase {
|
||||
private String password;
|
||||
private boolean overloadEnabled;
|
||||
|
||||
@Override
|
||||
public void setUser(String user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOverloadEnabled(boolean overloadEnabled) {
|
||||
this.overloadEnabled = overloadEnabled;
|
||||
}
|
||||
@@ -239,14 +242,17 @@ public class CauchoRemotingTests extends TestCase {
|
||||
private String password;
|
||||
private boolean overloadEnabled;
|
||||
|
||||
@Override
|
||||
public void setUser(String user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOverloadEnabled(boolean overloadEnabled) {
|
||||
this.overloadEnabled = overloadEnabled;
|
||||
}
|
||||
|
||||
@@ -73,6 +73,7 @@ public class HttpInvokerTests extends TestCase {
|
||||
pfb.setServiceUrl("http://myurl");
|
||||
|
||||
pfb.setHttpInvokerRequestExecutor(new AbstractHttpInvokerRequestExecutor() {
|
||||
@Override
|
||||
protected RemoteInvocationResult doExecuteRequest(
|
||||
HttpInvokerClientConfiguration config, ByteArrayOutputStream baos) throws Exception {
|
||||
assertEquals("http://myurl", config.getServiceUrl());
|
||||
@@ -138,6 +139,7 @@ public class HttpInvokerTests extends TestCase {
|
||||
pfb.setServiceUrl("http://myurl");
|
||||
|
||||
pfb.setHttpInvokerRequestExecutor(new HttpInvokerRequestExecutor() {
|
||||
@Override
|
||||
public RemoteInvocationResult executeRequest(
|
||||
HttpInvokerClientConfiguration config, RemoteInvocation invocation) throws IOException {
|
||||
throw new IOException("argh");
|
||||
@@ -160,6 +162,7 @@ public class HttpInvokerTests extends TestCase {
|
||||
TestBean target = new TestBean("myname", 99);
|
||||
|
||||
final HttpInvokerServiceExporter exporter = new HttpInvokerServiceExporter() {
|
||||
@Override
|
||||
protected InputStream decorateInputStream(HttpServletRequest request, InputStream is) throws IOException {
|
||||
if ("gzip".equals(request.getHeader("Compression"))) {
|
||||
return new GZIPInputStream(is);
|
||||
@@ -168,6 +171,7 @@ public class HttpInvokerTests extends TestCase {
|
||||
return is;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected OutputStream decorateOutputStream(
|
||||
HttpServletRequest request, HttpServletResponse response, OutputStream os) throws IOException {
|
||||
if ("gzip".equals(request.getHeader("Compression"))) {
|
||||
@@ -187,6 +191,7 @@ public class HttpInvokerTests extends TestCase {
|
||||
pfb.setServiceUrl("http://myurl");
|
||||
|
||||
pfb.setHttpInvokerRequestExecutor(new AbstractHttpInvokerRequestExecutor() {
|
||||
@Override
|
||||
protected RemoteInvocationResult doExecuteRequest(
|
||||
HttpInvokerClientConfiguration config, ByteArrayOutputStream baos)
|
||||
throws IOException, ClassNotFoundException {
|
||||
@@ -204,9 +209,11 @@ public class HttpInvokerTests extends TestCase {
|
||||
return readRemoteInvocationResult(
|
||||
new ByteArrayInputStream(response.getContentAsByteArray()), config.getCodebaseUrl());
|
||||
}
|
||||
@Override
|
||||
protected OutputStream decorateOutputStream(OutputStream os) throws IOException {
|
||||
return new GZIPOutputStream(os);
|
||||
}
|
||||
@Override
|
||||
protected InputStream decorateInputStream(InputStream is) throws IOException {
|
||||
return new GZIPInputStream(is);
|
||||
}
|
||||
@@ -239,6 +246,7 @@ public class HttpInvokerTests extends TestCase {
|
||||
TestBean target = new TestBean("myname", 99);
|
||||
|
||||
final HttpInvokerServiceExporter exporter = new HttpInvokerServiceExporter() {
|
||||
@Override
|
||||
protected RemoteInvocation doReadRemoteInvocation(ObjectInputStream ois)
|
||||
throws IOException, ClassNotFoundException {
|
||||
Object obj = ois.readObject();
|
||||
@@ -248,6 +256,7 @@ public class HttpInvokerTests extends TestCase {
|
||||
}
|
||||
return ((TestRemoteInvocationWrapper) obj).remoteInvocation;
|
||||
}
|
||||
@Override
|
||||
protected void doWriteRemoteInvocationResult(RemoteInvocationResult result, ObjectOutputStream oos)
|
||||
throws IOException {
|
||||
oos.writeObject(new TestRemoteInvocationResultWrapper(result));
|
||||
@@ -262,6 +271,7 @@ public class HttpInvokerTests extends TestCase {
|
||||
pfb.setServiceUrl("http://myurl");
|
||||
|
||||
pfb.setHttpInvokerRequestExecutor(new AbstractHttpInvokerRequestExecutor() {
|
||||
@Override
|
||||
protected RemoteInvocationResult doExecuteRequest(
|
||||
HttpInvokerClientConfiguration config, ByteArrayOutputStream baos) throws Exception {
|
||||
assertEquals("http://myurl", config.getServiceUrl());
|
||||
@@ -272,9 +282,11 @@ public class HttpInvokerTests extends TestCase {
|
||||
return readRemoteInvocationResult(
|
||||
new ByteArrayInputStream(response.getContentAsByteArray()), config.getCodebaseUrl());
|
||||
}
|
||||
@Override
|
||||
protected void doWriteRemoteInvocation(RemoteInvocation invocation, ObjectOutputStream oos) throws IOException {
|
||||
oos.writeObject(new TestRemoteInvocationWrapper(invocation));
|
||||
}
|
||||
@Override
|
||||
protected RemoteInvocationResult doReadRemoteInvocationResult(ObjectInputStream ois)
|
||||
throws IOException, ClassNotFoundException {
|
||||
Object obj = ois.readObject();
|
||||
@@ -316,6 +328,7 @@ public class HttpInvokerTests extends TestCase {
|
||||
exporter.setServiceInterface(ITestBean.class);
|
||||
exporter.setService(target);
|
||||
exporter.setRemoteInvocationExecutor(new DefaultRemoteInvocationExecutor() {
|
||||
@Override
|
||||
public Object invoke(RemoteInvocation invocation, Object targetObject)
|
||||
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
|
||||
assertNotNull(invocation.getAttributes());
|
||||
@@ -331,6 +344,7 @@ public class HttpInvokerTests extends TestCase {
|
||||
pfb.setServiceInterface(ITestBean.class);
|
||||
pfb.setServiceUrl("http://myurl");
|
||||
pfb.setRemoteInvocationFactory(new RemoteInvocationFactory() {
|
||||
@Override
|
||||
public RemoteInvocation createRemoteInvocation(MethodInvocation methodInvocation) {
|
||||
RemoteInvocation invocation = new RemoteInvocation(methodInvocation);
|
||||
invocation.addAttribute("myKey", "myValue");
|
||||
@@ -350,6 +364,7 @@ public class HttpInvokerTests extends TestCase {
|
||||
});
|
||||
|
||||
pfb.setHttpInvokerRequestExecutor(new AbstractHttpInvokerRequestExecutor() {
|
||||
@Override
|
||||
protected RemoteInvocationResult doExecuteRequest(
|
||||
HttpInvokerClientConfiguration config, ByteArrayOutputStream baos) throws Exception {
|
||||
assertEquals("http://myurl", config.getServiceUrl());
|
||||
@@ -375,6 +390,7 @@ public class HttpInvokerTests extends TestCase {
|
||||
exporter.setServiceInterface(ITestBean.class);
|
||||
exporter.setService(target);
|
||||
exporter.setRemoteInvocationExecutor(new DefaultRemoteInvocationExecutor() {
|
||||
@Override
|
||||
public Object invoke(RemoteInvocation invocation, Object targetObject)
|
||||
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
|
||||
assertTrue(invocation instanceof TestRemoteInvocation);
|
||||
@@ -389,6 +405,7 @@ public class HttpInvokerTests extends TestCase {
|
||||
pfb.setServiceInterface(ITestBean.class);
|
||||
pfb.setServiceUrl("http://myurl");
|
||||
pfb.setRemoteInvocationFactory(new RemoteInvocationFactory() {
|
||||
@Override
|
||||
public RemoteInvocation createRemoteInvocation(MethodInvocation methodInvocation) {
|
||||
RemoteInvocation invocation = new TestRemoteInvocation(methodInvocation);
|
||||
assertNull(invocation.getAttributes());
|
||||
@@ -398,6 +415,7 @@ public class HttpInvokerTests extends TestCase {
|
||||
});
|
||||
|
||||
pfb.setHttpInvokerRequestExecutor(new AbstractHttpInvokerRequestExecutor() {
|
||||
@Override
|
||||
protected RemoteInvocationResult doExecuteRequest(
|
||||
HttpInvokerClientConfiguration config, ByteArrayOutputStream baos) throws Exception {
|
||||
assertEquals("http://myurl", config.getServiceUrl());
|
||||
@@ -423,6 +441,7 @@ public class HttpInvokerTests extends TestCase {
|
||||
pfb.setServiceUrl(serviceUrl);
|
||||
|
||||
pfb.setHttpInvokerRequestExecutor(new HttpInvokerRequestExecutor() {
|
||||
@Override
|
||||
public RemoteInvocationResult executeRequest(
|
||||
HttpInvokerClientConfiguration config, RemoteInvocation invocation) throws IOException {
|
||||
throw new IOException("argh");
|
||||
|
||||
@@ -495,6 +495,7 @@ public class JaxRpcSupportTests extends TestCase {
|
||||
service1Control.setReturnValue(new RemoteBean());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Service createService(QName qName) throws ServiceException {
|
||||
if (!"myNamespace".equals(qName.getNamespaceURI()) || !"myService1".equals(qName.getLocalPart())) {
|
||||
throw new ServiceException("not supported");
|
||||
@@ -503,6 +504,7 @@ public class JaxRpcSupportTests extends TestCase {
|
||||
return service1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Service createService(URL url, QName qName) throws ServiceException {
|
||||
try {
|
||||
if (!(new URL("http://myUrl1")).equals(url) || !"".equals(qName.getNamespaceURI()) ||
|
||||
@@ -516,6 +518,7 @@ public class JaxRpcSupportTests extends TestCase {
|
||||
return service2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Service loadService(URL url, QName qName, Properties props) throws ServiceException {
|
||||
try {
|
||||
if (!(new URL("http://myUrl1")).equals(url) || !"".equals(qName.getNamespaceURI()) ||
|
||||
@@ -532,6 +535,7 @@ public class JaxRpcSupportTests extends TestCase {
|
||||
return service1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Service loadService(Class ifc) throws ServiceException {
|
||||
if (!IRemoteBean.class.equals(ifc)) {
|
||||
throw new ServiceException("not supported");
|
||||
@@ -540,6 +544,7 @@ public class JaxRpcSupportTests extends TestCase {
|
||||
return service2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Service loadService(URL url, Class ifc, Properties props) throws ServiceException {
|
||||
try {
|
||||
if (!(new URL("http://myUrl1")).equals(url) || !IRemoteBean.class.equals(ifc)) {
|
||||
@@ -563,6 +568,7 @@ public class JaxRpcSupportTests extends TestCase {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initMocks() throws Exception {
|
||||
super.initMocks();
|
||||
service1.getPort(new QName("myNamespace", "myPort"), IRemoteBean.class);
|
||||
@@ -580,6 +586,7 @@ public class JaxRpcSupportTests extends TestCase {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initMocks() throws Exception {
|
||||
initStandardCall(1);
|
||||
}
|
||||
@@ -591,9 +598,11 @@ public class JaxRpcSupportTests extends TestCase {
|
||||
service1Control.setReturnValue(call1, count);
|
||||
call1.invoke(new Object[] {"myName"});
|
||||
call1Control.setMatcher(new ArgumentsMatcher() {
|
||||
@Override
|
||||
public boolean matches(Object[] objects, Object[] objects1) {
|
||||
return Arrays.equals((Object[]) objects[0], (Object[]) objects1[0]);
|
||||
}
|
||||
@Override
|
||||
public String toString(Object[] objects) {
|
||||
return ObjectUtils.nullSafeToString(objects[0]);
|
||||
}
|
||||
@@ -616,6 +625,7 @@ public class JaxRpcSupportTests extends TestCase {
|
||||
public ExceptionCallMockServiceFactory() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initMocks() throws Exception {
|
||||
initExceptionCall();
|
||||
initStandardCall(2);
|
||||
@@ -628,9 +638,11 @@ public class JaxRpcSupportTests extends TestCase {
|
||||
service1Control.setReturnValue(call2);
|
||||
call2.invoke(new Object[] {"exception"});
|
||||
call2Control.setMatcher(new ArgumentsMatcher() {
|
||||
@Override
|
||||
public boolean matches(Object[] objects, Object[] objects1) {
|
||||
return Arrays.equals((Object[]) objects[0], (Object[]) objects1[0]);
|
||||
}
|
||||
@Override
|
||||
public String toString(Object[] objects) {
|
||||
return ObjectUtils.nullSafeToString(objects[0]);
|
||||
}
|
||||
@@ -646,6 +658,7 @@ public class JaxRpcSupportTests extends TestCase {
|
||||
public CallWithPropertiesMockServiceFactory() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void extendStandardCall() {
|
||||
call1.setProperty(Call.USERNAME_PROPERTY, "user");
|
||||
call1Control.setVoidCallable();
|
||||
@@ -682,6 +695,7 @@ public class JaxRpcSupportTests extends TestCase {
|
||||
properties = new HashMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String nam) throws RemoteException {
|
||||
if ("exception".equals(nam)) {
|
||||
throw new RemoteException();
|
||||
@@ -689,14 +703,17 @@ public class JaxRpcSupportTests extends TestCase {
|
||||
name = nam;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void _setProperty(String key, Object o) {
|
||||
properties.put(key, o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object _getProperty(String key) {
|
||||
return properties.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator _getPropertyNames() {
|
||||
return properties.keySet().iterator();
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ public class OrderServiceImpl implements OrderService {
|
||||
@Resource
|
||||
private WebServiceContext webServiceContext;
|
||||
|
||||
@Override
|
||||
public String getOrder(int id) throws OrderNotFoundException {
|
||||
Assert.notNull(this.webServiceContext, "WebServiceContext has not been injected");
|
||||
if (id == 0) {
|
||||
|
||||
@@ -44,6 +44,7 @@ public class ServletRequestDataBinderTests {
|
||||
|
||||
ServletRequestDataBinder binder = new ServletRequestDataBinder(tb, "person");
|
||||
binder.registerCustomEditor(ITestBean.class, new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue(new TestBean());
|
||||
}
|
||||
@@ -168,6 +169,7 @@ public class ServletRequestDataBinderTests {
|
||||
|
||||
ServletRequestDataBinder binder = new ServletRequestDataBinder(tb, "person");
|
||||
binder.registerCustomEditor(ITestBean.class, new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue(new TestBean());
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ public class WebRequestDataBinderTests {
|
||||
|
||||
WebRequestDataBinder binder = new WebRequestDataBinder(tb, "person");
|
||||
binder.registerCustomEditor(ITestBean.class, new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue(new TestBean());
|
||||
}
|
||||
|
||||
@@ -87,6 +87,7 @@ public class RequestContextListenerTests extends TestCase {
|
||||
|
||||
// Execute requestDestroyed callback in different thread.
|
||||
Thread thread = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
listener.requestDestroyed(new ServletRequestEvent(context, request));
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ public class RequestScopeTests extends TestCase {
|
||||
|
||||
private DefaultListableBeanFactory beanFactory;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
this.beanFactory = new DefaultListableBeanFactory();
|
||||
this.beanFactory.registerScope("request", new RequestScope());
|
||||
|
||||
@@ -40,6 +40,7 @@ public class SessionScopeTests extends TestCase {
|
||||
|
||||
private DefaultListableBeanFactory beanFactory;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
this.beanFactory = new DefaultListableBeanFactory();
|
||||
this.beanFactory.registerScope("session", new SessionScope());
|
||||
@@ -162,14 +163,17 @@ public class SessionScopeTests extends TestCase {
|
||||
|
||||
private static class CustomDestructionAwareBeanPostProcessor implements DestructionAwareBeanPostProcessor {
|
||||
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessBeforeDestruction(Object bean, String beanName) throws BeansException {
|
||||
}
|
||||
}
|
||||
@@ -179,14 +183,17 @@ public class SessionScopeTests extends TestCase {
|
||||
private static class CustomSerializableDestructionAwareBeanPostProcessor
|
||||
implements DestructionAwareBeanPostProcessor, Serializable {
|
||||
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessBeforeDestruction(Object bean, String beanName) throws BeansException {
|
||||
if (bean instanceof BeanNameAware) {
|
||||
((BeanNameAware) bean).setBeanName(null);
|
||||
|
||||
@@ -86,6 +86,7 @@ public class DeferredResultTests {
|
||||
|
||||
DeferredResult<String> result = new DeferredResult<String>();
|
||||
result.onCompletion(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
sb.append("completion event");
|
||||
}
|
||||
@@ -108,6 +109,7 @@ public class DeferredResultTests {
|
||||
DeferredResult<String> result = new DeferredResult<String>(null, "timeout result");
|
||||
result.setResultHandler(handler);
|
||||
result.onTimeout(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
sb.append("timeout event");
|
||||
}
|
||||
|
||||
@@ -432,6 +432,7 @@ public class WebAsyncManagerTests {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
if (this.value instanceof Exception) {
|
||||
throw ((Exception) this.value);
|
||||
|
||||
@@ -104,6 +104,7 @@ public class WebAsyncManagerTimeoutTests {
|
||||
StubCallable callable = new StubCallable();
|
||||
WebAsyncTask<Object> webAsyncTask = new WebAsyncTask<Object>(callable);
|
||||
webAsyncTask.onTimeout(new Callable<Object>() {
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
return 7;
|
||||
}
|
||||
@@ -207,6 +208,7 @@ public class WebAsyncManagerTimeoutTests {
|
||||
|
||||
final DeferredResult<Integer> deferredResult = new DeferredResult<Integer>();
|
||||
deferredResult.onTimeout(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
deferredResult.setResult(23);
|
||||
}
|
||||
@@ -228,6 +230,7 @@ public class WebAsyncManagerTimeoutTests {
|
||||
DeferredResult<Integer> deferredResult = new DeferredResult<Integer>();
|
||||
|
||||
DeferredResultProcessingInterceptor interceptor = new DeferredResultProcessingInterceptorAdapter() {
|
||||
@Override
|
||||
public <T> boolean handleTimeout(NativeWebRequest request, DeferredResult<T> result) throws Exception {
|
||||
result.setErrorResult(23);
|
||||
return true;
|
||||
@@ -252,6 +255,7 @@ public class WebAsyncManagerTimeoutTests {
|
||||
final Exception exception = new Exception();
|
||||
|
||||
DeferredResultProcessingInterceptor interceptor = new DeferredResultProcessingInterceptorAdapter() {
|
||||
@Override
|
||||
public <T> boolean handleTimeout(NativeWebRequest request, DeferredResult<T> result) throws Exception {
|
||||
throw exception;
|
||||
}
|
||||
@@ -270,6 +274,7 @@ public class WebAsyncManagerTimeoutTests {
|
||||
|
||||
|
||||
private final class StubCallable implements Callable<Object> {
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
return 21;
|
||||
}
|
||||
|
||||
@@ -71,14 +71,17 @@ public class CompositeFilterTests {
|
||||
|
||||
public FilterConfig filterConfig;
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
this.filterConfig = filterConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
|
||||
request.setAttribute("called", Boolean.TRUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
this.filterConfig = null;
|
||||
}
|
||||
|
||||
@@ -272,14 +272,17 @@ public class DelegatingFilterProxyTests {
|
||||
|
||||
public FilterConfig filterConfig;
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
this.filterConfig = filterConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
|
||||
request.setAttribute("called", Boolean.TRUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
this.filterConfig = null;
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ public class HiddenHttpMethodFilterTest {
|
||||
|
||||
FilterChain filterChain = new FilterChain() {
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest filterRequest, ServletResponse filterResponse)
|
||||
throws IOException, ServletException {
|
||||
assertEquals("Invalid method", "DELETE", ((HttpServletRequest) filterRequest).getMethod());
|
||||
@@ -63,6 +64,7 @@ public class HiddenHttpMethodFilterTest {
|
||||
|
||||
FilterChain filterChain = new FilterChain() {
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest filterRequest, ServletResponse filterResponse)
|
||||
throws IOException, ServletException {
|
||||
assertEquals("Invalid method", "POST", ((HttpServletRequest) filterRequest).getMethod());
|
||||
|
||||
@@ -54,6 +54,7 @@ public class RequestContextFilterTests extends TestCase {
|
||||
// Expect one invocation by the filter being tested
|
||||
class DummyFilterChain implements FilterChain {
|
||||
public int invocations = 0;
|
||||
@Override
|
||||
public void doFilter(ServletRequest req, ServletResponse resp) throws IOException, ServletException {
|
||||
++invocations;
|
||||
if (invocations == 1) {
|
||||
|
||||
@@ -97,6 +97,7 @@ public class RequestLoggingFilterTests {
|
||||
request.setContent(requestBody);
|
||||
FilterChain filterChain = new FilterChain() {
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest filterRequest, ServletResponse filterResponse)
|
||||
throws IOException, ServletException {
|
||||
((HttpServletResponse) filterResponse).setStatus(HttpServletResponse.SC_OK);
|
||||
@@ -122,6 +123,7 @@ public class RequestLoggingFilterTests {
|
||||
request.setContent(requestBody.getBytes("UTF-8"));
|
||||
FilterChain filterChain = new FilterChain() {
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest filterRequest, ServletResponse filterResponse)
|
||||
throws IOException, ServletException {
|
||||
((HttpServletResponse) filterResponse).setStatus(HttpServletResponse.SC_OK);
|
||||
@@ -148,6 +150,7 @@ public class RequestLoggingFilterTests {
|
||||
request.setContent(requestBody);
|
||||
FilterChain filterChain = new FilterChain() {
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest filterRequest, ServletResponse filterResponse)
|
||||
throws IOException, ServletException {
|
||||
((HttpServletResponse) filterResponse).setStatus(HttpServletResponse.SC_OK);
|
||||
@@ -182,6 +185,7 @@ public class RequestLoggingFilterTests {
|
||||
|
||||
private static class NoopFilterChain implements FilterChain {
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ public class ShallowEtagHeaderFilterTests {
|
||||
final byte[] responseBody = "Hello World".getBytes("UTF-8");
|
||||
FilterChain filterChain = new FilterChain() {
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest filterRequest, ServletResponse filterResponse)
|
||||
throws IOException, ServletException {
|
||||
assertEquals("Invalid request passed", request, filterRequest);
|
||||
@@ -83,6 +84,7 @@ public class ShallowEtagHeaderFilterTests {
|
||||
|
||||
FilterChain filterChain = new FilterChain() {
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest filterRequest, ServletResponse filterResponse)
|
||||
throws IOException, ServletException {
|
||||
assertEquals("Invalid request passed", request, filterRequest);
|
||||
@@ -109,6 +111,7 @@ public class ShallowEtagHeaderFilterTests {
|
||||
|
||||
FilterChain filterChain = new FilterChain() {
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest filterRequest, ServletResponse filterResponse)
|
||||
throws IOException, ServletException {
|
||||
assertEquals("Invalid request passed", request, filterRequest);
|
||||
|
||||
@@ -36,12 +36,14 @@ public class DelegatingPhaseListenerTests extends TestCase {
|
||||
private StaticListableBeanFactory beanFactory;
|
||||
private DelegatingPhaseListenerMulticaster delPhaseListener;
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("serial")
|
||||
protected void setUp() {
|
||||
facesContext = new MockFacesContext();
|
||||
beanFactory = new StaticListableBeanFactory();
|
||||
|
||||
delPhaseListener = new DelegatingPhaseListenerMulticaster() {
|
||||
@Override
|
||||
protected ListableBeanFactory getBeanFactory(FacesContext facesContext) {
|
||||
return beanFactory;
|
||||
}
|
||||
@@ -87,14 +89,17 @@ public class DelegatingPhaseListenerTests extends TestCase {
|
||||
boolean beforeCalled = false;
|
||||
boolean afterCalled = false;
|
||||
|
||||
@Override
|
||||
public PhaseId getPhaseId() {
|
||||
return PhaseId.ANY_PHASE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforePhase(PhaseEvent arg0) {
|
||||
beforeCalled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPhase(PhaseEvent arg0) {
|
||||
afterCalled = true;
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ public class DelegatingVariableResolverTests extends TestCase {
|
||||
// We need to override the getWebApplicationContext method here:
|
||||
// FacesContext and ExternalContext are hard to mock.
|
||||
DelegatingVariableResolver resolver = new DelegatingVariableResolver(new OriginalVariableResolver()) {
|
||||
@Override
|
||||
protected WebApplicationContext getWebApplicationContext(FacesContext facesContext) {
|
||||
return wac;
|
||||
}
|
||||
@@ -61,6 +62,7 @@ public class DelegatingVariableResolverTests extends TestCase {
|
||||
// We need to override the getWebApplicationContext method here:
|
||||
// FacesContext and ExternalContext are hard to mock.
|
||||
SpringBeanVariableResolver resolver = new SpringBeanVariableResolver(new OriginalVariableResolver()) {
|
||||
@Override
|
||||
protected WebApplicationContext getWebApplicationContext(FacesContext facesContext) {
|
||||
return wac;
|
||||
}
|
||||
@@ -72,6 +74,7 @@ public class DelegatingVariableResolverTests extends TestCase {
|
||||
|
||||
private static class OriginalVariableResolver extends VariableResolver {
|
||||
|
||||
@Override
|
||||
public Object resolveVariable(FacesContext facesContext, String name) throws EvaluationException {
|
||||
if ("var1".equals(name)) {
|
||||
return "val1";
|
||||
|
||||
@@ -44,6 +44,7 @@ public class MockFacesContext extends FacesContext {
|
||||
private UIViewRoot viewRoot;
|
||||
|
||||
|
||||
@Override
|
||||
public Application getApplication() {
|
||||
return application;
|
||||
}
|
||||
@@ -52,10 +53,12 @@ public class MockFacesContext extends FacesContext {
|
||||
this.application = application;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator getClientIdsWithMessages() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExternalContext getExternalContext() {
|
||||
return externalContext;
|
||||
}
|
||||
@@ -64,61 +67,77 @@ public class MockFacesContext extends FacesContext {
|
||||
this.externalContext = externalContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Severity getMaximumSeverity() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator getMessages() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator getMessages(String arg0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderKit getRenderKit() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getRenderResponse() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getResponseComplete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseStream getResponseStream() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResponseStream(ResponseStream arg0) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseWriter getResponseWriter() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResponseWriter(ResponseWriter arg0) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public UIViewRoot getViewRoot() {
|
||||
return viewRoot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setViewRoot(UIViewRoot viewRoot) {
|
||||
this.viewRoot = viewRoot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMessage(String arg0, FacesMessage arg1) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void release() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderResponse() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void responseComplete() {
|
||||
}
|
||||
|
||||
|
||||
@@ -27,19 +27,24 @@ import javax.faces.lifecycle.Lifecycle;
|
||||
*/
|
||||
public class MockLifecycle extends Lifecycle {
|
||||
|
||||
@Override
|
||||
public void addPhaseListener(PhaseListener phaseListener) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(FacesContext facesContext) throws FacesException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PhaseListener[] getPhaseListeners() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePhaseListener(PhaseListener phaseListener) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(FacesContext facesContext) throws FacesException {
|
||||
}
|
||||
|
||||
|
||||
@@ -265,14 +265,17 @@ public class ModelAttributeMethodProcessorTests {
|
||||
return validateInvoked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bind(WebRequest request) {
|
||||
bindInvoked = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate() {
|
||||
validateInvoked = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(Object... validationHints) {
|
||||
validateInvoked = true;
|
||||
}
|
||||
|
||||
@@ -226,10 +226,12 @@ public class InvocableHandlerMethodTests {
|
||||
|
||||
private static class ExceptionRaisingArgumentResolver implements HandlerMethodArgumentResolver {
|
||||
|
||||
@Override
|
||||
public boolean supportsParameter(MethodParameter parameter) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
|
||||
NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
|
||||
throw new HttpMessageNotReadableException("oops, can't read");
|
||||
|
||||
@@ -46,10 +46,12 @@ public class StubArgumentResolver implements HandlerMethodArgumentResolver {
|
||||
return resolvedParameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsParameter(MethodParameter parameter) {
|
||||
return parameter.getParameterType().equals(this.parameterType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
|
||||
NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
|
||||
this.resolvedParameters.add(parameter);
|
||||
|
||||
@@ -38,10 +38,12 @@ public class StubReturnValueHandler implements HandlerMethodReturnValueHandler {
|
||||
return this.returnValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsReturnType(MethodParameter returnType) {
|
||||
return returnType.getParameterType().equals(this.returnType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleReturnValue(Object returnValue, MethodParameter returnType, ModelAndViewContainer mavContainer,
|
||||
NativeWebRequest webRequest) throws Exception {
|
||||
this.returnValue = returnValue;
|
||||
|
||||
@@ -282,6 +282,7 @@ public class CommonsMultipartResolverTests {
|
||||
|
||||
final List<MultipartFile> files = new ArrayList<MultipartFile>();
|
||||
final FilterChain filterChain = new FilterChain() {
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse) {
|
||||
MultipartHttpServletRequest request = (MultipartHttpServletRequest) servletRequest;
|
||||
files.addAll(request.getFileMap().values());
|
||||
@@ -319,6 +320,7 @@ public class CommonsMultipartResolverTests {
|
||||
|
||||
final List<MultipartFile> files = new ArrayList<MultipartFile>();
|
||||
FilterChain filterChain = new FilterChain() {
|
||||
@Override
|
||||
public void doFilter(ServletRequest originalRequest, ServletResponse response) {
|
||||
if (originalRequest instanceof MultipartHttpServletRequest) {
|
||||
MultipartHttpServletRequest request = (MultipartHttpServletRequest) originalRequest;
|
||||
@@ -415,38 +417,47 @@ public class CommonsMultipartResolverTests {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream() throws IOException {
|
||||
return new ByteArrayInputStream(value.getBytes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return contentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInMemory() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSize() {
|
||||
return value.length();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] get() {
|
||||
return value.getBytes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(String encoding) throws UnsupportedEncodingException {
|
||||
return new String(get(), encoding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(File file) throws Exception {
|
||||
this.writtenFile = file;
|
||||
}
|
||||
@@ -455,6 +466,7 @@ public class CommonsMultipartResolverTests {
|
||||
return writtenFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete() {
|
||||
this.deleted = true;
|
||||
}
|
||||
@@ -463,22 +475,27 @@ public class CommonsMultipartResolverTests {
|
||||
return deleted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFieldName() {
|
||||
return fieldName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFieldName(String s) {
|
||||
this.fieldName = s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFormField() {
|
||||
return (this.name == null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFormField(boolean b) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutputStream getOutputStream() throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@@ -270,6 +270,7 @@ public class ExpressionEvaluationUtilsTests {
|
||||
|
||||
private ExpressionEvaluator eval = new CountingMockExpressionEvaluator(this);
|
||||
|
||||
@Override
|
||||
public ExpressionEvaluator getExpressionEvaluator() {
|
||||
return eval;
|
||||
}
|
||||
@@ -286,11 +287,13 @@ public class ExpressionEvaluationUtilsTests {
|
||||
super(pageContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Expression parseExpression(String expression, Class expectedType, FunctionMapper functionMapper) throws ELException {
|
||||
this.parseExpressionCount++;
|
||||
return super.parseExpression(expression, expectedType, functionMapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object evaluate(String expression, Class expectedType, VariableResolver variableResolver, FunctionMapper functionMapper) throws ELException {
|
||||
this.evaluateCount++;
|
||||
return super.evaluate(expression, expectedType, variableResolver, functionMapper);
|
||||
|
||||
@@ -34,6 +34,7 @@ public class MockLog4jAppender extends AppenderSkeleton {
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.log4j.AppenderSkeleton#append(org.apache.log4j.spi.LoggingEvent)
|
||||
*/
|
||||
@Override
|
||||
protected void append(LoggingEvent evt) {
|
||||
//System.out.println("Adding " + evt.getMessage());
|
||||
loggingStrings.add(evt.getMessage());
|
||||
@@ -42,6 +43,7 @@ public class MockLog4jAppender extends AppenderSkeleton {
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.log4j.Appender#close()
|
||||
*/
|
||||
@Override
|
||||
public void close() {
|
||||
closeCalled = true;
|
||||
}
|
||||
@@ -49,6 +51,7 @@ public class MockLog4jAppender extends AppenderSkeleton {
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.log4j.Appender#requiresLayout()
|
||||
*/
|
||||
@Override
|
||||
public boolean requiresLayout() {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user