From 6924f00f8c3739f42907a4feba595b3029f92150 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 9 Aug 2016 12:12:42 +0200 Subject: [PATCH] Polishing --- .../MockMvcClientHttpRequestFactory.java | 11 +++--- .../test/web/client/RequestMatcher.java | 5 +-- .../RequestMatcherClientHttpRequest.java | 12 ++---- .../client/match/ContentRequestMatchers.java | 8 ++-- .../client/match/JsonPathRequestMatchers.java | 13 +++---- .../client/match/MockRestRequestMatchers.java | 29 ++++---------- .../client/match/XpathRequestMatchers.java | 6 +-- .../response/DefaultResponseCreator.java | 39 ++++++++++--------- .../response/MockRestResponseCreators.java | 6 +-- .../mock/http/MockHttpInputMessage.java | 8 ++-- .../http/client/MockClientHttpRequest.java | 27 ++++++------- .../http/client/MockClientHttpResponse.java | 8 ++-- 12 files changed, 77 insertions(+), 95 deletions(-) diff --git a/spring-test-mvc/src/main/java/org/springframework/test/web/client/MockMvcClientHttpRequestFactory.java b/spring-test-mvc/src/main/java/org/springframework/test/web/client/MockMvcClientHttpRequestFactory.java index 914f949d0c..0361095c2e 100644 --- a/spring-test-mvc/src/main/java/org/springframework/test/web/client/MockMvcClientHttpRequestFactory.java +++ b/spring-test-mvc/src/main/java/org/springframework/test/web/client/MockMvcClientHttpRequestFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.test.web.client; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.request; @@ -33,6 +34,7 @@ import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder; +import org.springframework.util.Assert; /** * A {@link ClientHttpRequestFactory} for requests executed via {@link MockMvc}. @@ -46,29 +48,26 @@ public class MockMvcClientHttpRequestFactory implements ClientHttpRequestFactory public MockMvcClientHttpRequestFactory(MockMvc mockMvc) { + Assert.notNull(mockMvc, "MockMvc must not be null"); this.mockMvc = mockMvc; } + public ClientHttpRequest createRequest(final URI uri, final HttpMethod httpMethod) throws IOException { return new MockClientHttpRequest(httpMethod, uri) { - @Override public ClientHttpResponse executeInternal() throws IOException { try { MockHttpServletRequestBuilder requestBuilder = request(httpMethod, uri.toString()); requestBuilder.content(getBodyAsBytes()); requestBuilder.headers(getHeaders()); - MvcResult mvcResult = MockMvcClientHttpRequestFactory.this.mockMvc.perform(requestBuilder).andReturn(); - MockHttpServletResponse servletResponse = mvcResult.getResponse(); HttpStatus status = HttpStatus.valueOf(servletResponse.getStatus()); byte[] body = servletResponse.getContentAsByteArray(); HttpHeaders headers = getResponseHeaders(servletResponse); - MockClientHttpResponse clientResponse = new MockClientHttpResponse(body, status); clientResponse.getHeaders().putAll(headers); - return clientResponse; } catch (Exception ex) { diff --git a/spring-test-mvc/src/main/java/org/springframework/test/web/client/RequestMatcher.java b/spring-test-mvc/src/main/java/org/springframework/test/web/client/RequestMatcher.java index e59d48b5f2..a698627714 100644 --- a/spring-test-mvc/src/main/java/org/springframework/test/web/client/RequestMatcher.java +++ b/spring-test-mvc/src/main/java/org/springframework/test/web/client/RequestMatcher.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,8 +28,7 @@ import org.springframework.http.client.ClientHttpRequest; public interface RequestMatcher { /** - * Match the given request against some expectations. - * + * Match the given request against specific expectations. * @param request the request to make assertions on * @throws IOException in case of I/O errors * @throws AssertionError if expectations are not met diff --git a/spring-test-mvc/src/main/java/org/springframework/test/web/client/RequestMatcherClientHttpRequest.java b/spring-test-mvc/src/main/java/org/springframework/test/web/client/RequestMatcherClientHttpRequest.java index a0553cfd8d..9e2217a216 100644 --- a/spring-test-mvc/src/main/java/org/springframework/test/web/client/RequestMatcherClientHttpRequest.java +++ b/spring-test-mvc/src/main/java/org/springframework/test/web/client/RequestMatcherClientHttpRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,6 +45,7 @@ class RequestMatcherClientHttpRequest extends MockClientHttpRequest implements R this.requestMatchers.add(requestMatcher); } + public ResponseActions andExpect(RequestMatcher requestMatcher) { Assert.notNull(requestMatcher, "RequestMatcher is required"); this.requestMatchers.add(requestMatcher); @@ -57,22 +58,17 @@ class RequestMatcherClientHttpRequest extends MockClientHttpRequest implements R } public ClientHttpResponse executeInternal() throws IOException { - if (this.requestMatchers.isEmpty()) { throw new AssertionError("No request expectations to execute"); } - if (this.responseCreator == null) { - throw new AssertionError("No ResponseCreator was set up. Add it after request expectations, " - + "e.g. MockRestServiceServer.expect(requestTo(\"/foo\")).andRespond(withSuccess())"); + throw new AssertionError("No ResponseCreator was set up. Add it after request expectations, " + + "e.g. MockRestServiceServer.expect(requestTo(\"/foo\")).andRespond(withSuccess())"); } - for (RequestMatcher requestMatcher : this.requestMatchers) { requestMatcher.match(this); } - setResponse(this.responseCreator.createResponse(this)); - return super.executeInternal(); } diff --git a/spring-test-mvc/src/main/java/org/springframework/test/web/client/match/ContentRequestMatchers.java b/spring-test-mvc/src/main/java/org/springframework/test/web/client/match/ContentRequestMatchers.java index 1bcb49a5b9..c1f856cb0b 100644 --- a/spring-test-mvc/src/main/java/org/springframework/test/web/client/match/ContentRequestMatchers.java +++ b/spring-test-mvc/src/main/java/org/springframework/test/web/client/match/ContentRequestMatchers.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,6 +52,7 @@ public class ContentRequestMatchers { this.xmlHelper = new XmlExpectationsHelper(); } + /** * Assert the request content type as a String. */ @@ -135,10 +136,8 @@ public class ContentRequestMatchers { * Parse the request body and the given String as XML and assert that the * two are "similar" - i.e. they contain the same elements and attributes * regardless of order. - * *

Use of this matcher assumes the * XMLUnit library is available. - * * @param expectedXmlContent the expected XML content */ public RequestMatcher xml(final String expectedXmlContent) { @@ -175,6 +174,7 @@ public class ContentRequestMatchers { }; } + /** * Abstract base class for XML {@link RequestMatcher}'s. */ @@ -191,6 +191,6 @@ public class ContentRequestMatchers { } protected abstract void matchInternal(MockClientHttpRequest request) throws Exception; - } + } diff --git a/spring-test-mvc/src/main/java/org/springframework/test/web/client/match/JsonPathRequestMatchers.java b/spring-test-mvc/src/main/java/org/springframework/test/web/client/match/JsonPathRequestMatchers.java index d4da756185..0582929ce5 100644 --- a/spring-test-mvc/src/main/java/org/springframework/test/web/client/match/JsonPathRequestMatchers.java +++ b/spring-test-mvc/src/main/java/org/springframework/test/web/client/match/JsonPathRequestMatchers.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,8 +25,8 @@ import org.springframework.test.util.JsonPathExpectationsHelper; import org.springframework.test.web.client.RequestMatcher; /** - * Factory methods for request content {@code RequestMatcher}'s using a JSONPath expression. + * Factory methods for request content {@code RequestMatcher}'s using a + * JSONPath expression. * An instance of this class is typically accessed via * {@code RequestMatchers.jsonPath(..)}. * @@ -42,7 +42,6 @@ public class JsonPathRequestMatchers { * Class constructor, not for direct instantiation. Use * {@link MockRestRequestMatchers#jsonPath(String, Matcher)} or * {@link MockRestRequestMatchers#jsonPath(String, Object...)}. - * * @param expression the JSONPath expression * @param args arguments to parameterize the JSONPath expression with using * the formatting specifiers defined in @@ -123,12 +122,12 @@ public class JsonPathRequestMatchers { MockClientHttpRequest mockRequest = (MockClientHttpRequest) request; matchInternal(mockRequest); } - catch (ParseException e) { - throw new AssertionError("Failed to parse JSON request content: " + e.getMessage()); + catch (ParseException ex) { + throw new AssertionError("Failed to parse JSON request content: " + ex.getMessage()); } } protected abstract void matchInternal(MockClientHttpRequest request) throws IOException, ParseException; - } + } diff --git a/spring-test-mvc/src/main/java/org/springframework/test/web/client/match/MockRestRequestMatchers.java b/spring-test-mvc/src/main/java/org/springframework/test/web/client/match/MockRestRequestMatchers.java index ce3c7fb80d..292052b929 100644 --- a/spring-test-mvc/src/main/java/org/springframework/test/web/client/match/MockRestRequestMatchers.java +++ b/spring-test-mvc/src/main/java/org/springframework/test/web/client/match/MockRestRequestMatchers.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,13 +47,6 @@ import org.springframework.util.Assert; */ public abstract class MockRestRequestMatchers { - - /** - * Private class constructor. - */ - private MockRestRequestMatchers() { - } - /** * Match to any request. */ @@ -66,7 +59,6 @@ public abstract class MockRestRequestMatchers { /** * Assert the request URI string with the given matcher. - * * @param matcher String matcher for the expected URI * @return the request matcher */ @@ -81,7 +73,6 @@ public abstract class MockRestRequestMatchers { /** * Assert the request URI string. - * * @param expectedUri the expected URI * @return the request matcher */ @@ -96,7 +87,6 @@ public abstract class MockRestRequestMatchers { /** * Assert the {@link HttpMethod} of the request. - * * @param method the HTTP method * @return the request matcher */ @@ -111,7 +101,6 @@ public abstract class MockRestRequestMatchers { /** * Expect a request to the given URI. - * * @param uri the expected URI * @return the request matcher */ @@ -156,8 +145,8 @@ public abstract class MockRestRequestMatchers { private static void assertHeaderValueCount(final String name, HttpHeaders headers, int expectedCount) { List actualValues = headers.get(name); AssertionErrors.assertTrue("Expected header <" + name + ">", actualValues != null); - AssertionErrors.assertTrue("Expected header <" + name + "> to have at least <" + expectedCount - + "> values but found " + actualValues, expectedCount <= actualValues.size()); + AssertionErrors.assertTrue("Expected header <" + name + "> to have at least <" + expectedCount + + "> values but found " + actualValues, expectedCount <= actualValues.size()); } /** @@ -168,12 +157,11 @@ public abstract class MockRestRequestMatchers { } /** - * Access to request body matchers using a JSONPath expression to + * Access to request body matchers using a + * JSONPath expression to * inspect a specific subset of the body. The JSON path expression can be a * parameterized string using formatting specifiers as defined in * {@link String#format(String, Object...)}. - * * @param expression the JSON path optionally parameterized with arguments * @param args arguments to parameterize the JSON path expression with */ @@ -182,11 +170,10 @@ public abstract class MockRestRequestMatchers { } /** - * Access to request body matchers using a JSONPath expression to + * Access to request body matchers using a + * JSONPath expression to * inspect a specific subset of the body and a Hamcrest match for asserting * the value found at the JSON path. - * * @param expression the JSON path expression * @param matcher a matcher for the value expected at the JSON path */ @@ -199,7 +186,6 @@ public abstract class MockRestRequestMatchers { * subset of the body. The XPath expression can be a parameterized string * using formatting specifiers as defined in * {@link String#format(String, Object...)}. - * * @param expression the XPath optionally parameterized with arguments * @param args arguments to parameterize the XPath expression with */ @@ -212,7 +198,6 @@ public abstract class MockRestRequestMatchers { * subset of the body. The XPath expression can be a parameterized string * using formatting specifiers as defined in * {@link String#format(String, Object...)}. - * * @param expression the XPath optionally parameterized with arguments * @param namespaces namespaces referenced in the XPath expression * @param args arguments to parameterize the XPath expression with diff --git a/spring-test-mvc/src/main/java/org/springframework/test/web/client/match/XpathRequestMatchers.java b/spring-test-mvc/src/main/java/org/springframework/test/web/client/match/XpathRequestMatchers.java index 9c3ac04c41..332c0d7acf 100644 --- a/spring-test-mvc/src/main/java/org/springframework/test/web/client/match/XpathRequestMatchers.java +++ b/spring-test-mvc/src/main/java/org/springframework/test/web/client/match/XpathRequestMatchers.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.test.web.client.match; import java.io.IOException; @@ -44,12 +45,10 @@ public class XpathRequestMatchers { * Class constructor, not for direct instantiation. Use * {@link MockRestRequestMatchers#xpath(String, Object...)} or * {@link MockRestRequestMatchers#xpath(String, Map, Object...)}. - * * @param expression the XPath expression * @param namespaces XML namespaces referenced in the XPath expression, or {@code null} * @param args arguments to parameterize the XPath expression with using the * formatting specifiers defined in {@link String#format(String, Object...)} - * * @throws XPathExpressionException */ protected XpathRequestMatchers(String expression, Map namespaces, Object ... args) @@ -58,6 +57,7 @@ public class XpathRequestMatchers { this.xpathHelper = new XpathExpectationsHelper(expression, namespaces, args); } + /** * Apply the XPath and assert it with the given {@code Matcher}. */ diff --git a/spring-test-mvc/src/main/java/org/springframework/test/web/client/response/DefaultResponseCreator.java b/spring-test-mvc/src/main/java/org/springframework/test/web/client/response/DefaultResponseCreator.java index 7518f14f64..a1ac2d4ab7 100644 --- a/spring-test-mvc/src/main/java/org/springframework/test/web/client/response/DefaultResponseCreator.java +++ b/spring-test-mvc/src/main/java/org/springframework/test/web/client/response/DefaultResponseCreator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.test.web.client.response; import java.io.IOException; @@ -38,36 +39,24 @@ import org.springframework.util.Assert; */ public class DefaultResponseCreator implements ResponseCreator { + private HttpStatus statusCode; + private byte[] content; private Resource contentResource; private final HttpHeaders headers = new HttpHeaders(); - private HttpStatus statusCode; - /** * Protected constructor. * Use static factory methods in {@link MockRestResponseCreators}. */ protected DefaultResponseCreator(HttpStatus statusCode) { - Assert.notNull(statusCode); + Assert.notNull(statusCode, "HttpStatus must not be null"); this.statusCode = statusCode; } - public ClientHttpResponse createResponse(ClientHttpRequest request) throws IOException { - MockClientHttpResponse response; - if (this.contentResource != null ){ - InputStream stream = this.contentResource.getInputStream(); - response = new MockClientHttpResponse(stream, this.statusCode); - } - else { - response = new MockClientHttpResponse(this.content, this.statusCode); - } - response.getHeaders().putAll(this.headers); - return response; - } /** * Set the body as a UTF-8 String. @@ -76,9 +65,9 @@ public class DefaultResponseCreator implements ResponseCreator { try { this.content = content.getBytes("UTF-8"); } - catch (UnsupportedEncodingException e) { + catch (UnsupportedEncodingException ex) { // should not happen, UTF-8 is always supported - throw new IllegalStateException(e); + throw new IllegalStateException(ex); } return this; } @@ -129,4 +118,18 @@ public class DefaultResponseCreator implements ResponseCreator { return this; } + + public ClientHttpResponse createResponse(ClientHttpRequest request) throws IOException { + MockClientHttpResponse response; + if (this.contentResource != null) { + InputStream stream = this.contentResource.getInputStream(); + response = new MockClientHttpResponse(stream, this.statusCode); + } + else { + response = new MockClientHttpResponse(this.content, this.statusCode); + } + response.getHeaders().putAll(this.headers); + return response; + } + } diff --git a/spring-test-mvc/src/main/java/org/springframework/test/web/client/response/MockRestResponseCreators.java b/spring-test-mvc/src/main/java/org/springframework/test/web/client/response/MockRestResponseCreators.java index 243309b3c9..0ff14df9a1 100644 --- a/spring-test-mvc/src/main/java/org/springframework/test/web/client/response/MockRestResponseCreators.java +++ b/spring-test-mvc/src/main/java/org/springframework/test/web/client/response/MockRestResponseCreators.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,10 +33,6 @@ import org.springframework.test.web.client.ResponseCreator; */ public abstract class MockRestResponseCreators { - - private MockRestResponseCreators() { - } - /** * {@code ResponseCreator} for a 200 response (OK). */ diff --git a/spring-test/src/main/java/org/springframework/mock/http/MockHttpInputMessage.java b/spring-test/src/main/java/org/springframework/mock/http/MockHttpInputMessage.java index 5de14e9954..1029a6c534 100644 --- a/spring-test/src/main/java/org/springframework/mock/http/MockHttpInputMessage.java +++ b/spring-test/src/main/java/org/springframework/mock/http/MockHttpInputMessage.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.mock.http; import java.io.ByteArrayInputStream; @@ -37,14 +38,15 @@ public class MockHttpInputMessage implements HttpInputMessage { public MockHttpInputMessage(byte[] contents) { - this.body = (contents != null) ? new ByteArrayInputStream(contents) : null; + this.body = (contents != null ? new ByteArrayInputStream(contents) : null); } public MockHttpInputMessage(InputStream body) { - Assert.notNull(body, "'body' must not be null"); + Assert.notNull(body, "InputStream must not be null"); this.body = body; } + public HttpHeaders getHeaders() { return this.headers; } diff --git a/spring-test/src/main/java/org/springframework/mock/http/client/MockClientHttpRequest.java b/spring-test/src/main/java/org/springframework/mock/http/client/MockClientHttpRequest.java index 0f46bbbcf3..ef35be0137 100644 --- a/spring-test/src/main/java/org/springframework/mock/http/client/MockClientHttpRequest.java +++ b/spring-test/src/main/java/org/springframework/mock/http/client/MockClientHttpRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,14 +33,14 @@ import org.springframework.mock.http.MockHttpOutputMessage; */ public class MockClientHttpRequest extends MockHttpOutputMessage implements ClientHttpRequest { - private URI uri; - private HttpMethod httpMethod; - private boolean executed = false; + private URI uri; private ClientHttpResponse clientHttpResponse; + private boolean executed = false; + /** * Default constructor. @@ -56,20 +56,21 @@ public class MockClientHttpRequest extends MockHttpOutputMessage implements Clie this.uri = uri; } - public URI getURI() { - return this.uri; - } - public void setURI(URI uri) { - this.uri = uri; + public void setMethod(HttpMethod httpMethod) { + this.httpMethod = httpMethod; } public HttpMethod getMethod() { return this.httpMethod; } - public void setMethod(HttpMethod httpMethod) { - this.httpMethod = httpMethod; + public void setURI(URI uri) { + this.uri = uri; + } + + public URI getURI() { + return this.uri; } public void setResponse(ClientHttpResponse clientHttpResponse) { @@ -93,7 +94,6 @@ public class MockClientHttpRequest extends MockHttpOutputMessage implements Clie /** * The default implementation returns the configured * {@link #setResponse(ClientHttpResponse) response}. - * *

Override this method to execute the request and provide a response, * potentially different than the configured response. */ @@ -101,6 +101,7 @@ public class MockClientHttpRequest extends MockHttpOutputMessage implements Clie return this.clientHttpResponse; } + @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -111,7 +112,7 @@ public class MockClientHttpRequest extends MockHttpOutputMessage implements Clie sb.append(" ").append(this.uri); } if (!getHeaders().isEmpty()) { - sb.append(", headers : ").append(getHeaders()); + sb.append(", headers: ").append(getHeaders()); } if (sb.length() == 0) { sb.append("Not yet initialized"); diff --git a/spring-test/src/main/java/org/springframework/mock/http/client/MockClientHttpResponse.java b/spring-test/src/main/java/org/springframework/mock/http/client/MockClientHttpResponse.java index 9ed40774f1..5b7a363207 100644 --- a/spring-test/src/main/java/org/springframework/mock/http/client/MockClientHttpResponse.java +++ b/spring-test/src/main/java/org/springframework/mock/http/client/MockClientHttpResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.mock.http.client; import java.io.IOException; @@ -39,7 +40,7 @@ public class MockClientHttpResponse extends MockHttpInputMessage implements Clie */ public MockClientHttpResponse(byte[] body, HttpStatus statusCode) { super(body); - Assert.notNull(statusCode, "statisCode is required"); + Assert.notNull(statusCode, "HttpStatus is required"); this.status = statusCode; } @@ -48,10 +49,11 @@ public class MockClientHttpResponse extends MockHttpInputMessage implements Clie */ public MockClientHttpResponse(InputStream body, HttpStatus statusCode) { super(body); - Assert.notNull(statusCode, "statisCode is required"); + Assert.notNull(statusCode, "HttpStatus is required"); this.status = statusCode; } + public HttpStatus getStatusCode() throws IOException { return this.status; }