From 54f6947259b0e0eb03b2ebfd4af28d2989b93530 Mon Sep 17 00:00:00 2001 From: Klaus Straubinger Date: Fri, 11 Sep 2015 16:23:30 +0200 Subject: [PATCH] [OLINGO-659] more API clean-up Signed-off-by: Michael Bolz --- .../olingo/commons/api/http/HttpHeader.java | 195 ++++-------------- .../apache/olingo/server/api/HttpHeaders.java | 121 +++++------ .../org/apache/olingo/server/api/OData.java | 11 +- .../olingo/server/api/ODataHttpHandler.java | 4 +- .../olingo/server/api/ODataRequest.java | 15 +- .../olingo/server/api/ODataResponse.java | 10 +- .../olingo/server/api/batch/BatchFacade.java | 41 ++-- .../server/api/debug/DebugResponseHelper.java | 10 +- .../api/deserializer/ODataDeserializer.java | 17 +- .../batch/BatchDeserializerException.java | 25 ++- .../api/deserializer/batch/BatchOptions.java | 26 ++- .../deserializer/batch/BatchRequestPart.java | 13 +- .../ReferenceCollectionSerializerOptions.java | 2 +- .../ReferenceSerializerOptions.java | 2 +- .../deserializer/batch/BatchParserCommon.java | 3 +- .../batch/BatchRequestTransformator.java | 12 +- .../batch/BatchTransformatorCommon.java | 5 +- .../serializer/BatchResponseSerializer.java | 6 +- .../server-core-exceptions-i18n.properties | 21 +- .../batch/BatchRequestParserTest.java | 12 +- .../AsyncResponseSerializerTest.java | 20 +- 21 files changed, 223 insertions(+), 348 deletions(-) diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/http/HttpHeader.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/http/HttpHeader.java index 323655b03..f33dbb048 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/http/HttpHeader.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/http/HttpHeader.java @@ -18,271 +18,162 @@ */ package org.apache.olingo.commons.api.http; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Locale; - /** * HTTP header constants. */ -public class HttpHeader { +public interface HttpHeader { /** * See {@link HTTP/1.1 documentation}. */ - public static final String ACCEPT = "Accept"; + String ACCEPT = "Accept"; /** * See {@link HTTP/1.1 documentation}. */ - public static final String ACCEPT_CHARSET = "Accept-Charset"; + String ACCEPT_CHARSET = "Accept-Charset"; /** * See {@link HTTP/1.1 documentation}. */ - public static final String ACCEPT_ENCODING = "Accept-Encoding"; + String ACCEPT_ENCODING = "Accept-Encoding"; /** * See {@link HTTP/1.1 documentation}. */ - public static final String ACCEPT_LANGUAGE = "Accept-Language"; + String ACCEPT_LANGUAGE = "Accept-Language"; /** * See {@link HTTP/1.1 documentation}. */ - public static final String ALLOW = "Allow"; + String ALLOW = "Allow"; /** * See {@link HTTP/1.1 documentation}. */ - public static final String AUTHORIZATION = "Authorization"; + String AUTHORIZATION = "Authorization"; /** * See {@link HTTP/1.1 documentation}. */ - public static final String CACHE_CONTROL = "Cache-Control"; + String CACHE_CONTROL = "Cache-Control"; /** * See {@link HTTP/1.1 documentation}. */ - public static final String CONTENT_ENCODING = "Content-Encoding"; + String CONTENT_ENCODING = "Content-Encoding"; /** * See {@link HTTP/1.1 documentation}. */ - public static final String CONTENT_LANGUAGE = "Content-Language"; + String CONTENT_LANGUAGE = "Content-Language"; /** See RFC 2392. */ - public static final String CONTENT_ID = "Content-ID"; + String CONTENT_ID = "Content-ID"; /** * See {@link HTTP/1.1 documentation}. */ - public static final String CONTENT_LENGTH = "Content-Length"; + String CONTENT_LENGTH = "Content-Length"; /** * See {@link HTTP/1.1 documentation}. */ - public static final String CONTENT_LOCATION = "Content-Location"; + String CONTENT_LOCATION = "Content-Location"; /** * See {@link HTTP/1.1 documentation}. */ - public static final String CONTENT_TYPE = "Content-Type"; + String CONTENT_TYPE = "Content-Type"; /** * See {@link HTTP/1.1 documentation}. */ - public static final String DATE = "Date"; + String DATE = "Date"; /** * See {@link HTTP/1.1 documentation}. */ - public static final String ETAG = "ETag"; + String ETAG = "ETag"; /** See RFC 7231. */ - public static final String EXPECT = "Expect"; + String EXPECT = "Expect"; /** * See {@link HTTP/1.1 documentation}. */ - public static final String EXPIRES = "Expires"; + String EXPIRES = "Expires"; /** See RFC 7231. */ - public static final String FROM = "From"; + String FROM = "From"; /** * See {@link HTTP/1.1 documentation}. */ - public static final String HOST = "Host"; + String HOST = "Host"; /** * See {@link HTTP/1.1 documentation}. */ - public static final String IF_MATCH = "If-Match"; + String IF_MATCH = "If-Match"; /** * See {@link HTTP/1.1 documentation}. */ - public static final String IF_MODIFIED_SINCE = "If-Modified-Since"; + String IF_MODIFIED_SINCE = "If-Modified-Since"; /** * See {@link HTTP/1.1 documentation}. */ - public static final String IF_NONE_MATCH = "If-None-Match"; + String IF_NONE_MATCH = "If-None-Match"; /** * See {@link HTTP/1.1 documentation}. */ - public static final String IF_UNMODIFIED_SINCE = "If-Unmodified-Since"; + String IF_UNMODIFIED_SINCE = "If-Unmodified-Since"; /** * See {@link HTTP/1.1 documentation}. */ - public static final String LAST_MODIFIED = "Last-Modified"; + String LAST_MODIFIED = "Last-Modified"; /** * See {@link HTTP/1.1 documentation}. */ - public static final String LOCATION = "Location"; + String LOCATION = "Location"; /** * See {@link Web Linking (IETF RFC-5988) documentation}. */ - public static final String LINK = "Link"; + String LINK = "Link"; /** See RFC 7231. */ - public static final String MAX_FORWARDS = "Max-Forwards"; + String MAX_FORWARDS = "Max-Forwards"; /** * OData Prefer Header. * See * OData Version 4.0 Part 1: Protocol and RFC 7240. */ - public static final String PREFER = "Prefer"; + String PREFER = "Prefer"; /** * OData Preference-Applied Header. * See * OData Version 4.0 Part 1: Protocol and RFC 7240. */ - public static final String PREFERENCE_APPLIED = "Preference-Applied"; + String PREFERENCE_APPLIED = "Preference-Applied"; /** See RFC 7233. */ - public static final String RANGE = "Range"; + String RANGE = "Range"; /** * See {@link HTTP/1.1 documentation}. */ - public static final String RETRY_AFTER = "Retry-After"; + String RETRY_AFTER = "Retry-After"; /** See RFC 7230. */ - public static final String TE = "TE"; + String TE = "TE"; /** * See {@link HTTP/1.1 documentation}. */ - public static final String USER_AGENT = "User-Agent"; + String USER_AGENT = "User-Agent"; /** * See {@link HTTP/1.1 documentation}. */ - public static final String VARY = "Vary"; + String VARY = "Vary"; /** * See {@link HTTP/1.1 documentation}. */ - public static final String WWW_AUTHENTICATE = "WWW-Authenticate"; + String WWW_AUTHENTICATE = "WWW-Authenticate"; /** * See {@link IETF RFC 2109}. */ - public static final String COOKIE = "Cookie"; + String COOKIE = "Cookie"; /** * See {@link IETF RFC 2109}. */ - public static final String SET_COOKIE = "Set-Cookie"; + String SET_COOKIE = "Set-Cookie"; /** Non standard header. */ - public static final String X_HTTP_METHOD = "X-HTTP-Method"; + String X_HTTP_METHOD = "X-HTTP-Method"; /** Non standard header. */ - public static final String X_HTTP_METHOD_OVERRIDE = "X-HTTP-Method-Override"; + String X_HTTP_METHOD_OVERRIDE = "X-HTTP-Method-Override"; /** Custom Header defined in the OData standard. */ - public static final String ODATA_VERSION = "OData-Version"; + String ODATA_VERSION = "OData-Version"; /** Custom Header defined in the OData standard. */ - public static final String ODATA_MAX_VERSION = "OData-MaxVersion"; + String ODATA_MAX_VERSION = "OData-MaxVersion"; /** Custom Header defined in the OData standard. */ - public static final String ODATA_ENTITY_ID = "OData-EntityID"; - - private final String name; - private final List values; - - /** - * Create header for given name - * @param name of header - */ - public HttpHeader(String name) { - this.name = name; - this.values = new ArrayList(); - } - - /** - * Create header for given name and add given values - * @param name of header - * @param values values for header - */ - public HttpHeader(String name, Collection values) { - this(name); - this.values.addAll(values); - } - - /** - * Get name of header (not the canonical name) - * @return name of header - */ - public String getName() { - return name; - } - - /** - * Get all values for this header - * @return all header values - */ - public List getValues() { - return Collections.unmodifiableList(values); - } - - /** - * Add header value - * - * @param value value to be added - * @return this header object (fluent interface) - */ - public HttpHeader addValue(String value) { - this.values.add(value); - return this; - } - - /** - * Add header values - * - * @param values values to be added - * @return this header object (fluent interface) - */ - public HttpHeader addValues(Collection values) { - this.values.addAll(values); - return this; - } - - /** - * Get the canonical name of header - * @return canonical name of header - */ - public String getCanonicalName() { - return createCanonicalName(name); - } - - /** - * Create the canonical name based on given name parameter - * - * @param name name which is canonicalised - * @return canonical name - */ - public static String createCanonicalName(String name) { - return name.toLowerCase(Locale.ROOT); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - HttpHeader that = (HttpHeader) o; - - if (!name.equals(that.name)) { - return false; - } - return values.equals(that.values); - - } - - @Override - public int hashCode() { - int result = name.hashCode(); - result = 31 * result + values.hashCode(); - return result; - } + String ODATA_ENTITY_ID = "OData-EntityID"; } diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/HttpHeaders.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/HttpHeaders.java index afbe8d202..eec22f045 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/HttpHeaders.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/HttpHeaders.java @@ -22,132 +22,111 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.LinkedHashMap; -import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.olingo.commons.api.http.HttpHeader; - /** - * HttpHeader container + * HttpHeader container. */ public class HttpHeaders { - private final Map headers = new LinkedHashMap(); + private final Map> headers = new LinkedHashMap>(); /** - * Add a header with given name and value. - * If header with name already exists the value is added to this header. - * + * Adds a header with given name and value. + * If a header with that name already exists the value is added to this header. * @param name name of header * @param value value for header * @return this container (fluent interface) */ - public HttpHeaders addHeader(String name, String value) { - HttpHeader eh = grantHeader(name); - eh.addValue(value); + public HttpHeaders addHeader(final String name, final String value) { + final String canonicalName = getCanonicalName(name); + List header = headers.get(canonicalName); + if (header == null) { + header = new ArrayList(); + } + header.add(value); + headers.put(canonicalName, header); return this; } /** - * Add a header with given name and values. - * If header with name already exists the values are added to this header. - * + * Adds a header with the given name and values. + * If a header with that name already exists the values are added to this header. * @param name name of header * @param values values for header * @return this container (fluent interface) */ - public HttpHeaders addHeader(String name, Collection values) { - HttpHeader eh = grantHeader(name); - eh.addValues(values); + public HttpHeaders addHeader(final String name, final List values) { + final String canonicalName = getCanonicalName(name); + List header = headers.get(canonicalName); + if (header == null) { + header = new ArrayList(); + } + header.addAll(values); + headers.put(canonicalName, header); return this; } /** * Set a header with given name and value. - * If header with name already exists the old header is replaced with the new one. - * + * If a header with that name already exists the old header is replaced with the new one. * @param name name of header * @param value value for header * @return this container (fluent interface) */ - public HttpHeaders setHeader(String name, String value) { + public HttpHeaders setHeader(final String name, final String value) { removeHeader(name); - - HttpHeader eh = grantHeader(name); - eh.addValue(value); + addHeader(name, value); return this; } /** - * Get header for given name. - * + * Gets header values for the given name. * @param name name of header requested - * @return corresponding header + * @return corresponding header values or null if no values have been found */ - public HttpHeader getHeader(String name) { - return headers.get(HttpHeader.createCanonicalName(name)); + public List getHeader(final String name) { + final List values = headers.get(getCanonicalName(name)); + return values == null || values.isEmpty() ? null : Collections.unmodifiableList(values); } /** - * Remove header for given name. - * + * Removes header of the given name. * @param name name of header to be removed - * @return header which was removed or null if no header was known for this name + * @return removed header values or null if no header was known for this name */ - public HttpHeader removeHeader(String name) { - return headers.remove(HttpHeader.createCanonicalName(name)); + public List removeHeader(final String name) { + return headers.remove(getCanonicalName(name)); } - /** - * Get all headers. - * - * @return all headers - */ - public Collection getHeaders() { - return Collections.unmodifiableCollection(headers.values()); - } - - - /** - * Get all headers with the according values. - * - * @return an unmodifiable Map of header names/values + * Gets all headers with the according values. + * @return an unmodifiable Map of header names/values or an empty collection if no headers have been set */ public Map> getHeaderToValues() { - Map> result = new HashMap>(); - Collection allHeaders = headers.values(); - for (HttpHeader header : allHeaders) { - result.put(header.getName(), header.getValues()); - } - return Collections.unmodifiableMap(result); + return headers.isEmpty() ? Collections.> emptyMap() : Collections.unmodifiableMap(headers); } /** - * Get all header names. - * - * @return all header names + * Gets all header names. + * @return all header names or an empty collection if no headers have been set */ public Collection getHeaderNames() { - Collection headerNames = new ArrayList(); - for (HttpHeader header : headers.values()) { - headerNames.add(header.getName()); - } - return headerNames; + return headers.isEmpty() ? Collections. emptySet() : Collections.unmodifiableSet(headers.keySet()); } /** - * Get or create a header for given name. - * - * @return new or known header + * The canonical form of a header name is the already-used form regarding case, + * enabling applications to have pretty-looking headers instead of getting them + * converted to all lowercase. + * @param name HTTP header name */ - private HttpHeader grantHeader(String name) { - String key = HttpHeader.createCanonicalName(name); - HttpHeader eh = headers.get(key); - if(eh == null) { - eh = new HttpHeader(name); - headers.put(key, eh); + private String getCanonicalName(final String name) { + for (final String headerName : headers.keySet()) { + if (headerName.equalsIgnoreCase(name)) { + return headerName; + } } - return eh; + return name; } } diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/OData.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/OData.java index f21cfb5b1..75b2e27ff 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/OData.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/OData.java @@ -125,7 +125,7 @@ public abstract class OData { /** * Creates a new deserializer object for reading content in the specified format. - * Deserializer are used in Processor implementations. + * Deserializers are used in Processor implementations. * * @param contentType any content type supported by Olingo (XML, JSON ...) */ @@ -151,10 +151,11 @@ public abstract class OData { public abstract Preferences createPreferences(Collection preferHeaders); /** - * This method creates a DebugResponseHelper for the given debugFormat. If the format is not supported no - * exception is thrown. Instead we give back the implementation for the json format. - * @param debugFormat to be used. - * @return a debug response serializer + * Creates a DebugResponseHelper for the given debugFormat. + * If the format is not supported no exception is thrown. + * Instead we give back the implementation for the JSON format. + * @param debugFormat format to be used + * @return a debug-response helper */ public abstract DebugResponseHelper createDebugResponseHelper(String debugFormat); } diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataHttpHandler.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataHttpHandler.java index d641581ad..a2180c82c 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataHttpHandler.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataHttpHandler.java @@ -62,13 +62,13 @@ public interface ODataHttpHandler { void setSplit(int split); /** - * Register this interface to support concurrency control for certain entity sets. + * Registers support for concurrency control for certain entity sets. * @param customETagSupport */ void register(CustomETagSupport customConcurrencyControlSupport); /** - * Register the debug support handler + * Registers the debug support handler. * @param debugSupport */ void register(DebugSupport debugSupport); diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataRequest.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataRequest.java index ef686531b..bb0709668 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataRequest.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataRequest.java @@ -19,11 +19,9 @@ package org.apache.olingo.server.api; import java.io.InputStream; -import java.util.ArrayList; import java.util.List; import java.util.Map; -import org.apache.olingo.commons.api.http.HttpHeader; import org.apache.olingo.commons.api.http.HttpMethod; /** @@ -93,26 +91,22 @@ public class ODataRequest { } /** - * Get header values for a given name. + * Gets header values for a given name. * @param name the header name as a case-insensitive key * @return the header value(s) or null if not found */ public List getHeaders(final String name) { - HttpHeader h = headers.getHeader(name); - if(h == null) { - return null; - } - return new ArrayList(h.getValues()); + return headers.getHeader(name); } /** - * Get first header value for a given name. + * Gets first header value for a given name. * @param name the header name as a case-insensitive key * @return the first header value or null if not found */ public String getHeader(final String name) { final List values = getHeaders(name); - return values == null ? null : values.get(0); + return values == null || values.isEmpty() ? null : values.get(0); } /** @@ -123,7 +117,6 @@ public class ODataRequest { return headers.getHeaderToValues(); } - /** * Gets the body of the request. * @return the request payload as {@link InputStream} or null diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataResponse.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataResponse.java index 36eea8d23..3b63af70f 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataResponse.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataResponse.java @@ -19,11 +19,9 @@ package org.apache.olingo.server.api; import java.io.InputStream; -import java.util.ArrayList; import java.util.List; import java.util.Map; -import org.apache.olingo.commons.api.http.HttpHeader; import org.apache.olingo.commons.api.http.HttpStatusCode; /** @@ -102,11 +100,7 @@ public class ODataResponse { * @return the header value(s) or null if not found */ public List getHeaders(final String name) { - HttpHeader h = headers.getHeader(name); - if(h == null) { - return null; - } - return new ArrayList(h.getValues()); + return headers.getHeader(name); } /** @@ -118,7 +112,7 @@ public class ODataResponse { */ public String getHeader(final String name) { final List values = getHeaders(name); - return values == null ? null : values.get(0); + return values == null || values.isEmpty() ? null : values.get(0); } diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/batch/BatchFacade.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/batch/BatchFacade.java index b5a2b1b79..72625de69 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/batch/BatchFacade.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/batch/BatchFacade.java @@ -25,50 +25,49 @@ import org.apache.olingo.server.api.deserializer.batch.BatchRequestPart; import org.apache.olingo.server.api.deserializer.batch.ODataResponsePart; /** - * Provides methods to process {@link ODataRequest} and {@link BatchRequestPart}. + *

Provides methods to process {@link ODataRequest}s and {@link BatchRequestPart}s + * in the context of a batch request.

* - * Within a {@link org.apache.olingo.server.api.processor.BatchProcessor} implementation BatchRequestsParts - * should be passed to {@link BatchFacade#handleBatchRequest(BatchRequestPart)}. - * If only if the BatchRequests part represents a change set, the request will be delegated to + *

Within a {@link org.apache.olingo.server.api.processor.BatchProcessor BatchProcessor} + * implementation BatchRequestParts should be passed to {@link #handleBatchRequest(BatchRequestPart)}. + * Only if the BatchRequestPart represents a change set, the request will be delegated to * {@link org.apache.olingo.server.api.processor.BatchProcessor#processChangeSet(BatchFacade, java.util.List)}. - * Otherwise the requests will be directly executed. + * Otherwise the requests will be directly executed.

* - * The processor implementation could use {@link BatchFacade#handleODataRequest(ODataRequest)} to processes - * requests in a change set. + *

The processor implementation could use {@link #handleODataRequest(ODataRequest)} to process + * requests in a change set.

*/ public interface BatchFacade { /** - * Executes a ODataRequest, which must be a part of a change set. - * Each requests must have a Content-Id header field, which holds an id that is unique in the whole batch request. - * + * Executes an ODataRequest, which must be a part of a change set. + * Each request must have a Content-Id header field, which holds an identifier + * that is unique in the whole batch request. * @param request ODataRequest to process - * @return Corresponding ODataResult to the given request + * @return corresponding ODataResponse to the given request * @throws ODataApplicationException * @throws ODataLibraryException */ - public ODataResponse handleODataRequest(ODataRequest request) throws ODataApplicationException, - ODataLibraryException; + public ODataResponse handleODataRequest(ODataRequest request) + throws ODataApplicationException, ODataLibraryException; /** * Handles a BatchRequestPart. - * * @param request Request to process - * @return Corresponding {@link ODataResponsePart} + * @return corresponding {@link ODataResponsePart} * @throws ODataApplicationException * @throws ODataLibraryException */ - public ODataResponsePart handleBatchRequest(BatchRequestPart request) throws ODataApplicationException, - ODataLibraryException; + public ODataResponsePart handleBatchRequest(BatchRequestPart request) + throws ODataApplicationException, ODataLibraryException; /** * Extracts the boundary of a multipart/mixed header. * See RFC 2046#5.1 - * * @param contentType Content Type - * @return Boundary + * @return boundary * @throws ODataApplicationException * @throws ODataLibraryException */ - public String extractBoundaryFromContentType(String contentType) throws ODataApplicationException, - ODataLibraryException; + public String extractBoundaryFromContentType(String contentType) + throws ODataApplicationException, ODataLibraryException; } diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/debug/DebugResponseHelper.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/debug/DebugResponseHelper.java index e2f6933b5..ec6a2c4ba 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/debug/DebugResponseHelper.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/debug/DebugResponseHelper.java @@ -21,18 +21,14 @@ package org.apache.olingo.server.api.debug; import org.apache.olingo.server.api.ODataResponse; /** - * This class supports applications in creating debug responses. + * Support for applications creating debug responses. */ public interface DebugResponseHelper { /** * Creates a debug response based on the given parameters. Will never throw an exception. - * @param request - * @param applicationResponse - * @param exception - * @param serverEnvironmentVaribles - * @param runtimeInformation - * @return the debug response or the raw application response in case an exception occurred. + * @param debugInfo debug information + * @return the debug response or the raw application response in case an exception occurred */ ODataResponse createDebugResponse(DebugInformation debugInfo); } diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/ODataDeserializer.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/ODataDeserializer.java index 41eb60baa..ac4035268 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/ODataDeserializer.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/ODataDeserializer.java @@ -30,10 +30,10 @@ import org.apache.olingo.commons.api.edm.EdmProperty; public interface ODataDeserializer { /** - * Deserializes an entity stream into an {@link org.apache.olingo.commons.api.data.Entity} object. - * Validates: property types, no double properties, correct json types - * Returns a deserialized {@link org.apache.olingo.commons.api.data.Entity} object and an - * {@link org.apache.olingo.server.api.uri.queryoption.ExpandOption} object + * Deserializes an entity stream into an {@link org.apache.olingo.commons.api.data.Entity Entity} object. + * Validates: property types, no double properties, correct json types. + * Returns a deserialized {@link org.apache.olingo.commons.api.data.Entity Entity} object and an + * {@link org.apache.olingo.server.api.uri.queryoption.ExpandOption ExpandOption} object. * @param stream * @param edmEntityType * @return {@link DeserializerResult#getEntity()} and {@link DeserializerResult#getExpandTree()} @@ -42,7 +42,8 @@ public interface ODataDeserializer { DeserializerResult entity(InputStream stream, EdmEntityType edmEntityType) throws DeserializerException; /** - * Deserializes an entity collection stream into an {@link org.apache.olingo.commons.api.data.EntityCollection} object + * Deserializes an entity collection stream into an + * {@link org.apache.olingo.commons.api.data.EntityCollection EntityCollection} object. * @param stream * @param edmEntityType * @return {@link DeserializerResult#getEntityCollection()} @@ -51,7 +52,7 @@ public interface ODataDeserializer { DeserializerResult entityCollection(InputStream stream, EdmEntityType edmEntityType) throws DeserializerException; /** - * Deserializes an action-parameters stream into an {@link org.apache.olingo.commons.api.data.Entity} object. + * Deserializes an action-parameters stream into a map of key/value pairs. * Validates: parameter types, no double parameters, correct json types. * @param stream * @param edmAction @@ -61,7 +62,7 @@ public interface ODataDeserializer { DeserializerResult actionParameters(InputStream stream, EdmAction edmAction) throws DeserializerException; /** - * Deserializes the Property or collections of properties (primitive & complex) + * Deserializes the Property or collections of properties (primitive & complex). * @param stream * @param edmProperty * @return {@link DeserializerResult#getProperty()} @@ -70,7 +71,7 @@ public interface ODataDeserializer { DeserializerResult property(InputStream stream, EdmProperty edmProperty) throws DeserializerException; /** - * Read entity references from the provided document + * Reads entity references from the provided document. * @param stream * @param keys * @return {@link DeserializerResult#getEntityReferences()} diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/batch/BatchDeserializerException.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/batch/BatchDeserializerException.java index fbc958b5b..cff3b259b 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/batch/BatchDeserializerException.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/batch/BatchDeserializerException.java @@ -22,26 +22,49 @@ import org.apache.olingo.server.api.deserializer.DeserializerException; public class BatchDeserializerException extends DeserializerException { public static enum MessageKeys implements MessageKey { + /** parameter: line */ INVALID_BOUNDARY, + /** parameter: line */ INVALID_CHANGESET_METHOD, + /** parameter: line */ INVALID_CONTENT, + /** parameter: line */ INVALID_CONTENT_LENGTH, + /** parameter: line */ INVALID_CONTENT_TRANSFER_ENCODING, + /** parameter: line */ INVALID_CONTENT_TYPE, - INVALID_HEADER, + /** parameters: line, expected content type, actual content type */ + UNEXPECTED_CONTENT_TYPE, + /** parameter: line */ + INVALID_CONTENT_ID, + /** parameter: line */ INVALID_HTTP_VERSION, + /** parameter: line */ INVALID_METHOD, + /** parameter: line */ INVALID_QUERY_OPERATION_METHOD, + /** parameter: line */ INVALID_STATUS_LINE, + /** parameter: line */ INVALID_URI, + /** parameter: line */ MISSING_BLANK_LINE, + /** parameter: line */ MISSING_BOUNDARY_DELIMITER, + /** parameter: line */ MISSING_CLOSE_DELIMITER, + /** parameter: line */ MISSING_CONTENT_ID, + /** parameter: line */ MISSING_CONTENT_TRANSFER_ENCODING, + /** parameter: line */ MISSING_CONTENT_TYPE, + /** parameter: line */ MISSING_MANDATORY_HEADER, + /** parameter: line */ FORBIDDEN_HEADER, + /** parameter: line */ INVALID_BASE_URI; @Override diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/batch/BatchOptions.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/batch/BatchOptions.java index 98b0f10f1..b0f929a7e 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/batch/BatchOptions.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/batch/BatchOptions.java @@ -20,9 +20,8 @@ package org.apache.olingo.server.api.deserializer.batch; /** * Options for the batch deserializer. - * See - * {@link org.apache.olingo.server.api.deserializer.FixedFormatDeserializer - * #parseBatchRequest(java.io.InputStream, String, BatchOptions)} + * @see org.apache.olingo.server.api.deserializer.FixedFormatDeserializer + * #parseBatchRequest(java.io.InputStream, String, BatchOptions) */ public final class BatchOptions { private boolean isStrict = true; @@ -33,8 +32,7 @@ public final class BatchOptions { /** * Returns if the batch parsing is strict. - * Default is true - * + * Default is true. * @return true if parsing is strict */ public boolean isStrict() { @@ -42,22 +40,23 @@ public final class BatchOptions { } /** - * See {@link org.apache.olingo.server.api.ODataRequest#getRawBaseUri()} + * Gets raw base URI. + * @see org.apache.olingo.server.api.ODataRequest#getRawBaseUri() */ public String getRawBaseUri() { return rawBaseUri; } /** - * See {@link org.apache.olingo.server.api.ODataRequest#getRawServiceResolutionUri()} + * Gets raw service resolution URI. + * @see org.apache.olingo.server.api.ODataRequest#getRawServiceResolutionUri() */ public String getRawServiceResolutionUri() { return rawServiceResolutionUri; } /** - * Creates a new BatchOptions builder - * + * Creates a new BatchOptions builder. * @return new BatchOptions builder instance */ public static Builder with() { @@ -76,7 +75,7 @@ public final class BatchOptions { } /** - * See {@link BatchOptions#isStrict()} + * @see BatchOptions#isStrict() */ public Builder isStrict(final boolean isStrict) { options.isStrict = isStrict; @@ -84,7 +83,7 @@ public final class BatchOptions { } /** - * See {@link org.apache.olingo.server.api.ODataRequest#getRawBaseUri()} + * @see org.apache.olingo.server.api.ODataRequest#getRawBaseUri() */ public Builder rawBaseUri(final String baseUri) { options.rawBaseUri = baseUri; @@ -92,7 +91,7 @@ public final class BatchOptions { } /** - * See {@link org.apache.olingo.server.api.ODataRequest#getRawServiceResolutionUri()} + * @see org.apache.olingo.server.api.ODataRequest#getRawServiceResolutionUri() */ public Builder rawServiceResolutionUri(final String serviceResolutionUri) { options.rawServiceResolutionUri = serviceResolutionUri; @@ -100,8 +99,7 @@ public final class BatchOptions { } /** - * Creates a new BatchOptions instance - * + * Creates a new BatchOptions instance. * @return new BatchOptions instance */ public BatchOptions build() { diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/batch/BatchRequestPart.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/batch/BatchRequestPart.java index f67410bdd..5802c9e01 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/batch/BatchRequestPart.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/batch/BatchRequestPart.java @@ -25,16 +25,14 @@ import java.util.List; import org.apache.olingo.server.api.ODataRequest; /** - * A BatchPart - *

BatchPart represents a distinct MIME part of a Batch Request body. It can be a ChangeSet or a Query Operation + * Represents a distinct MIME part of a Batch Request body - either a Change Set or a Query Operation */ public class BatchRequestPart { private List requests = new ArrayList(); private boolean isChangeSet; /** - * Creates a new instance of BachRequestPart - * + * Creates a new instance of BachRequestPart. * @param isChangeSet True, if this instance represents a change set * @param requests A list of {@link ODataRequest} */ @@ -44,8 +42,7 @@ public class BatchRequestPart { } /** - * Creates a new instance of BachRequestPart - * + * Creates a new instance of BachRequestPart. * @param isChangeSet True, if this instance represents a change set * @param request A single {@link ODataRequest} */ @@ -56,7 +53,7 @@ public class BatchRequestPart { } /** - * Get the info if a BatchPart is a ChangeSet + * Gets the info if a BatchPart is a ChangeSet. * @return true or false */ public boolean isChangeSet() { @@ -64,7 +61,7 @@ public class BatchRequestPart { } /** - * Get requests. If a BatchPart is a Query Operation, the list contains one request. + * Gets all requests of this part. If a BatchPart is a Query Operation, the list contains one request. * @return a list of {@link ODataRequest} */ public List getRequests() { diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ReferenceCollectionSerializerOptions.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ReferenceCollectionSerializerOptions.java index 2e979e694..16f03e314 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ReferenceCollectionSerializerOptions.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ReferenceCollectionSerializerOptions.java @@ -21,7 +21,7 @@ package org.apache.olingo.server.api.serializer; import org.apache.olingo.commons.api.data.ContextURL; import org.apache.olingo.server.api.uri.queryoption.CountOption; -/** Options for the OData serializer. */ +/** Options to pass as additional information to the reference-collection serializer. */ public final class ReferenceCollectionSerializerOptions { private ContextURL contextURL; private CountOption count; diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ReferenceSerializerOptions.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ReferenceSerializerOptions.java index e3a82cc29..7a5e2e662 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ReferenceSerializerOptions.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ReferenceSerializerOptions.java @@ -21,7 +21,7 @@ package org.apache.olingo.server.api.serializer; import org.apache.olingo.commons.api.data.ContextURL; /** - * Use this options calls to pass additional information to the reference serializer. + * Options to pass as additional information to the reference serializer. */ public final class ReferenceSerializerOptions { private ContextURL contextURL; diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchParserCommon.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchParserCommon.java index 256e05e56..bdb819573 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchParserCommon.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchParserCommon.java @@ -93,7 +93,8 @@ public class BatchParserCommon { return type; } else { throw new BatchDeserializerException("Content type is not the expected content type", - BatchDeserializerException.MessageKeys.INVALID_CONTENT_TYPE, expected.toContentTypeString()); + BatchDeserializerException.MessageKeys.UNEXPECTED_CONTENT_TYPE, + Integer.toString(line), expected.toContentTypeString(), type.toContentTypeString()); } } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchRequestTransformator.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchRequestTransformator.java index 4e5ef9de9..20ef8eadd 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchRequestTransformator.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchRequestTransformator.java @@ -84,14 +84,14 @@ public class BatchRequestTransformator { } private HeaderField getContentId(final BatchQueryOperation queryOperation) throws BatchDeserializerException { - final HeaderField contentTypeHeader = queryOperation.getHeaders().getHeaderField(HttpHeader.CONTENT_ID); + final HeaderField contentIdHeader = queryOperation.getHeaders().getHeaderField(HttpHeader.CONTENT_ID); - if (contentTypeHeader != null) { - if (contentTypeHeader.getValues().size() == 1) { - return contentTypeHeader; + if (contentIdHeader != null) { + if (contentIdHeader.getValues().size() == 1) { + return contentIdHeader; } else { - throw new BatchDeserializerException("Invalid header", MessageKeys.INVALID_HEADER, - Integer.toString(contentTypeHeader.getLineNumber())); + throw new BatchDeserializerException("Invalid Content-ID header", MessageKeys.INVALID_CONTENT_ID, + Integer.toString(contentIdHeader.getLineNumber())); } } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchTransformatorCommon.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchTransformatorCommon.java index 1543c43c5..2f3d8bb37 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchTransformatorCommon.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchTransformatorCommon.java @@ -56,7 +56,8 @@ public class BatchTransformatorCommon { Integer.toString(headers.getLineNumber())); } } else { - throw new BatchDeserializerException("Invalid header", MessageKeys.INVALID_HEADER, + throw new BatchDeserializerException("Invalid Content-Transfer-Encoding header", + MessageKeys.INVALID_CONTENT_TRANSFER_ENCODING, Integer.toString(headers.getLineNumber())); } } else { @@ -82,7 +83,7 @@ public class BatchTransformatorCommon { return contentLength; } catch (NumberFormatException e) { - throw new BatchDeserializerException("Invalid header", e, MessageKeys.INVALID_HEADER, + throw new BatchDeserializerException("Invalid content length", e, MessageKeys.INVALID_CONTENT_LENGTH, Integer.toString(contentLengthField.getLineNumber())); } } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/BatchResponseSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/BatchResponseSerializer.java index 83c3e1ed6..d99d94303 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/BatchResponseSerializer.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/BatchResponseSerializer.java @@ -138,13 +138,13 @@ public class BatchResponseSerializer { final Map> header = response.getAllHeaders(); for (final Map.Entry> entry : header.entrySet()) { - // Requests do never has a content id header + // Requests never have a content id header. if (!entry.getKey().equalsIgnoreCase(HttpHeader.CONTENT_ID)) { appendHeader(entry.getKey(), entry.getValue().get(0), builder); } } - appendHeader(HttpHeader.CONTENT_LENGTH, "" + contentLength, builder); + appendHeader(HttpHeader.CONTENT_LENGTH, Integer.toString(contentLength), builder); } private void appendBodyPartHeader(final ODataResponse response, final BodyBuilder builder, @@ -153,7 +153,7 @@ public class BatchResponseSerializer { appendHeader(BatchParserCommon.CONTENT_TRANSFER_ENCODING, BatchParserCommon.BINARY_ENCODING, builder); if (isChangeSet) { - if (response.getAllHeaders().get(HttpHeader.CONTENT_ID) != null) { + if (response.getHeader(HttpHeader.CONTENT_ID) != null) { appendHeader(HttpHeader.CONTENT_ID, response.getHeader(HttpHeader.CONTENT_ID), builder); } else { throw new BatchSerializerException("Missing content id", MessageKeys.MISSING_CONTENT_ID); diff --git a/lib/server-core/src/main/resources/server-core-exceptions-i18n.properties b/lib/server-core/src/main/resources/server-core-exceptions-i18n.properties index a2b92ca5a..0a2edd7df 100644 --- a/lib/server-core/src/main/resources/server-core-exceptions-i18n.properties +++ b/lib/server-core/src/main/resources/server-core-exceptions-i18n.properties @@ -126,14 +126,15 @@ DeserializerException.INVALID_NULL_PARAMETER=The parameter '%1$s' must not be nu BatchDeserializerException.INVALID_BOUNDARY=Invalid boundary at line '%1$s'. BatchDeserializerException.INVALID_CHANGESET_METHOD=Invalid method: a ChangeSet cannot contain retrieve requests at line '%1$s'. -BatchDeserializerException.INVALID_CONTENT=Retrieve requests must not contain any body content '%1$s'. -BatchDeserializerException.INVALID_CONTENT_LENGTH=Invalid content length: content length have to be an integer and positive at line '%1$s'. -BatchDeserializerException.INVALID_CONTENT_TRANSFER_ENCODING=The Content-Transfer-Encoding should be binary: line '%1$s'. -BatchDeserializerException.INVALID_CONTENT_TYPE=Content-Type should be '%1$s'. -BatchDeserializerException.INVALID_HEADER=Invalid header: '%1$s' at line '%2$s'. -BatchDeserializerException.INVALID_HTTP_VERSION=Invalid HTTP version: The version have to be HTTP/1.1 at line '%1$s'. +BatchDeserializerException.INVALID_CONTENT=The retrieve request at line '%1$s' must not contain any body content. +BatchDeserializerException.INVALID_CONTENT_LENGTH=The value of the Content-Length HTTP header at line '%1$s' must be a positive integer. +BatchDeserializerException.INVALID_CONTENT_TRANSFER_ENCODING=The Content-Transfer-Encoding at line '%1$s' must be binary. +BatchDeserializerException.INVALID_CONTENT_TYPE=Invalid Content-Type HTTP header at line '%1$s'. +BatchDeserializerException.UNEXPECTED_CONTENT_TYPE=Content-Type at line '%1$s' should be '%2$s' but is '%3$s'. +BatchDeserializerException.INVALID_CONTENT_ID=Invalid Content-ID HTTP header at line '%1$s'. +BatchDeserializerException.INVALID_HTTP_VERSION=The HTTP version must be HTTP/1.1 at line '%1$s'. BatchDeserializerException.INVALID_METHOD=Invalid HTTP method at line '%1$s'. -BatchDeserializerException.INVALID_QUERY_OPERATION_METHOD=Invalid method: a query operation can only contain retrieve requests at line '%1$s'. +BatchDeserializerException.INVALID_QUERY_OPERATION_METHOD=The query operation at line '%1$s' can only contain retrieve requests. BatchDeserializerException.INVALID_STATUS_LINE=Invalid HTTP status line at line '%1$s'. BatchDeserializerException.INVALID_URI=Invalid URI at line '%1$s'. BatchDeserializerException.FORBIDDEN_HEADER=Forbidden header at line '%1$s'. @@ -144,9 +145,9 @@ BatchDeserializerException.MISSING_CONTENT_ID=Missing content-id at line '%1$s'. BatchDeserializerException.MISSING_CONTENT_TRANSFER_ENCODING=Missing content transfer encoding at line '%1$s'. BatchDeserializerException.MISSING_CONTENT_TYPE=Missing content-type at line '%1$s'. BatchDeserializerException.MISSING_MANDATORY_HEADER=Missing mandatory header at line '%1$s'. -BatchDeserializerException.INVALID_BASE_URI=The base URI do not match the service base URI at line '%1$s'. - -BatchSerializerExecption.MISSING_CONTENT_ID=Each request within a change set required exactly one content id. +BatchDeserializerException.INVALID_BASE_URI=The base URI does not match the service base URI at line '%1$s'. + +BatchSerializerExecption.MISSING_CONTENT_ID=Each request within a change set requires exactly one content id. PreconditionException.MISSING_HEADER=The Operation you requested on this Entity requires an if-match or if-none-match header. PreconditionException.FAILED=The If-Match precondition is not fulfilled. diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/batch/BatchRequestParserTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/batch/BatchRequestParserTest.java index e43840dc4..155c6788e 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/batch/BatchRequestParserTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/batch/BatchRequestParserTest.java @@ -393,7 +393,7 @@ public class BatchRequestParserTest { } @Test - public void testMimeHeaderContentType() throws Exception { + public void mimeHeaderContentType() throws Exception { final String batch = "--batch_8194-cf13-1f56" + CRLF + "Content-Type: text/plain" + CRLF + "Content-Transfer-Encoding: binary" + CRLF @@ -403,7 +403,7 @@ public class BatchRequestParserTest { + CRLF + "--batch_8194-cf13-1f56--"; - parseInvalidBatchBody(batch, BatchDeserializerException.MessageKeys.INVALID_CONTENT_TYPE); + parseInvalidBatchBody(batch, BatchDeserializerException.MessageKeys.UNEXPECTED_CONTENT_TYPE); } @Test @@ -536,7 +536,7 @@ public class BatchRequestParserTest { } @Test - public void testNestedChangeset() throws Exception { + public void nestedChangeset() throws Exception { final String batch = "" + "--batch_8194-cf13-1f56" + CRLF + "Content-Type: multipart/mixed;boundary=changeset_f980-1cb6-94dd" + CRLF @@ -559,7 +559,7 @@ public class BatchRequestParserTest { + CRLF + "--batch_8194-cf13-1f56--"; - parseInvalidBatchBody(batch, BatchDeserializerException.MessageKeys.INVALID_CONTENT_TYPE); + parseInvalidBatchBody(batch, BatchDeserializerException.MessageKeys.UNEXPECTED_CONTENT_TYPE); } @Test @@ -801,7 +801,7 @@ public class BatchRequestParserTest { } @Test - public void testNonNumericContentLength() throws Exception { + public void nonNumericContentLength() throws Exception { final String batch = "" + "--batch_8194-cf13-1f56" + CRLF + "Content-Type: multipart/mixed; boundary=changeset_f980-1cb6-94dd" + CRLF @@ -819,7 +819,7 @@ public class BatchRequestParserTest { + CRLF + "--batch_8194-cf13-1f56--"; - parseInvalidBatchBody(batch, BatchDeserializerException.MessageKeys.INVALID_HEADER); + parseInvalidBatchBody(batch, BatchDeserializerException.MessageKeys.INVALID_CONTENT_LENGTH); } @Test diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/AsyncResponseSerializerTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/AsyncResponseSerializerTest.java index b720cb7cf..d70de6225 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/AsyncResponseSerializerTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/AsyncResponseSerializerTest.java @@ -34,7 +34,7 @@ public class AsyncResponseSerializerTest { private static final String CRLF = "\r\n"; @Test - public void testSimpleResponse() throws Exception { + public void simpleResponse() throws Exception { ODataResponse response = new ODataResponse(); response.setStatusCode(HttpStatusCode.OK.getStatusCode()); response.setHeader(HttpHeader.CONTENT_TYPE, ContentType.APPLICATION_JSON.toContentTypeString()); @@ -45,14 +45,14 @@ public class AsyncResponseSerializerTest { AsyncResponseSerializer serializer = new AsyncResponseSerializer(); InputStream in = serializer.serialize(response); String result = IOUtils.toString(in); - assertEquals("HTTP/1.1 200 OK" + CRLF + - "Content-Length: 200" + CRLF + - "Content-Type: application/json" + CRLF + CRLF + - "Walter Winter" + CRLF, result); + assertEquals("HTTP/1.1 200 OK" + CRLF + + "Content-Type: application/json" + CRLF + + "Content-Length: 200" + CRLF + CRLF + + "Walter Winter" + CRLF, result); } @Test - public void testBiggerResponse() throws Exception { + public void biggerResponse() throws Exception { ODataResponse response = new ODataResponse(); response.setStatusCode(HttpStatusCode.ACCEPTED.getStatusCode()); response.setHeader(HttpHeader.CONTENT_TYPE, ContentType.APPLICATION_JSON.toContentTypeString()); @@ -64,10 +64,10 @@ public class AsyncResponseSerializerTest { AsyncResponseSerializer serializer = new AsyncResponseSerializer(); InputStream in = serializer.serialize(response); String result = IOUtils.toString(in); - assertEquals("HTTP/1.1 202 Accepted" + CRLF + - "Content-Length: 0" + CRLF + - "Content-Type: application/json" + CRLF + CRLF + - testData, result); + assertEquals("HTTP/1.1 202 Accepted" + CRLF + + "Content-Type: application/json" + CRLF + + "Content-Length: 0" + CRLF + CRLF + + testData, result); } private String testData(int amount) {