You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2013/09/20 15:33:46 UTC
[24/59] [abbrv] Cleanup of core
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/a030e42b/odata-core/src/test/java/org/apache/olingo/odata2/core/ODataExceptionWrapperTest.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/ODataExceptionWrapperTest.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/ODataExceptionWrapperTest.java
index ffe566e..e3409da 100644
--- a/odata-core/src/test/java/org/apache/olingo/odata2/core/ODataExceptionWrapperTest.java
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/ODataExceptionWrapperTest.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
******************************************************************************/
package org.apache.olingo.odata2.core;
@@ -85,13 +85,15 @@ public class ODataExceptionWrapperTest extends BaseTest {
assertEquals("text/html", contentTypeHeader);
}
- private ODataExceptionWrapper createWrapper(final ODataContextImpl context, final Map<String, String> queryParameters, final List<String> acceptContentTypes) throws URISyntaxException {
+ private ODataExceptionWrapper createWrapper(final ODataContextImpl context,
+ final Map<String, String> queryParameters, final List<String> acceptContentTypes) throws URISyntaxException {
ODataExceptionWrapper exceptionWrapper = new ODataExceptionWrapper(context, queryParameters, acceptContentTypes);
return exceptionWrapper;
}
- private ODataContextImpl getMockedContext(final String requestUri, final String serviceRoot) throws ODataException, URISyntaxException {
+ private ODataContextImpl getMockedContext(final String requestUri, final String serviceRoot) throws ODataException,
+ URISyntaxException {
ODataContextImpl context = Mockito.mock(ODataContextImpl.class);
PathInfoImpl pathInfo = new PathInfoImpl();
pathInfo.setRequestUri(new URI(requestUri));
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/a030e42b/odata-core/src/test/java/org/apache/olingo/odata2/core/ODataRequestHandlerValidationTest.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/ODataRequestHandlerValidationTest.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/ODataRequestHandlerValidationTest.java
index 505b9fc..72780c8 100644
--- a/odata-core/src/test/java/org/apache/olingo/odata2/core/ODataRequestHandlerValidationTest.java
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/ODataRequestHandlerValidationTest.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
******************************************************************************/
package org.apache.olingo.odata2.core;
@@ -77,7 +77,7 @@ import org.junit.Test;
/**
* Tests for the validation of HTTP method, URI path, query options,
* and request-body content type.
- *
+ *
*/
public class ODataRequestHandlerValidationTest extends BaseTest {
@@ -237,7 +237,7 @@ public class ODataRequestHandlerValidationTest extends BaseTest {
when(request.getAcceptHeaders()).thenReturn(acceptHeaders);
String acceptHeadersAsString = null;
for (String string : acceptHeaders) {
- if(acceptHeadersAsString == null) {
+ if (acceptHeadersAsString == null) {
acceptHeadersAsString = string;
} else {
acceptHeadersAsString += ", " + string;
@@ -246,7 +246,7 @@ public class ODataRequestHandlerValidationTest extends BaseTest {
when(request.getRequestHeaderValue("Accept")).thenReturn(acceptHeadersAsString);
return request;
}
-
+
private ODataRequest mockODataRequest(
final ODataHttpMethod method,
final List<String> pathSegments,
@@ -257,7 +257,6 @@ public class ODataRequestHandlerValidationTest extends BaseTest {
return mockODataRequest(method, pathSegments, queryParameters, acceptHeaders, requestContentType);
}
-
private ODataService mockODataService(final ODataServiceFactory serviceFactory) throws ODataException {
ODataService service = DispatcherTest.getMockService();
when(service.getEntityDataModel()).thenReturn(edm);
@@ -348,7 +347,8 @@ public class ODataRequestHandlerValidationTest extends BaseTest {
final List<String> acceptHeaders,
final HttpStatusCodes expectedStatusCode) throws ODataException {
- executeAndValidateRequest(ODataHttpMethod.GET, pathSegments, queryParameters, acceptHeaders, null, expectedStatusCode);
+ executeAndValidateRequest(ODataHttpMethod.GET, pathSegments, queryParameters, acceptHeaders, null,
+ expectedStatusCode);
}
private void executeAndValidateRequest(final ODataHttpMethod method,
@@ -362,7 +362,8 @@ public class ODataRequestHandlerValidationTest extends BaseTest {
final ODataService service = mockODataService(serviceFactory);
when(serviceFactory.createService(any(ODataContext.class))).thenReturn(service);
- final ODataRequest request = mockODataRequest(method, pathSegments, queryParameters, acceptHeaders, requestContentType);
+ final ODataRequest request =
+ mockODataRequest(method, pathSegments, queryParameters, acceptHeaders, requestContentType);
final ODataContextImpl context = new ODataContextImpl(request, serviceFactory);
final ODataResponse response = new ODataRequestHandler(serviceFactory, service, context).handle(request);
@@ -371,12 +372,13 @@ public class ODataRequestHandlerValidationTest extends BaseTest {
response.getStatus());
}
-
- private void checkValueContentType(final ODataHttpMethod method, final UriType uriType, final String requestContentType) throws Exception {
+ private void checkValueContentType(final ODataHttpMethod method, final UriType uriType,
+ final String requestContentType) throws Exception {
executeAndValidateRequest(method, createPathSegments(uriType, false, true), null, requestContentType, null);
}
- private void wrongRequest(final ODataHttpMethod method, final List<String> pathSegments, final Map<String, String> queryParameters) throws ODataException {
+ private void wrongRequest(final ODataHttpMethod method, final List<String> pathSegments,
+ final Map<String, String> queryParameters) throws ODataException {
executeAndValidateRequest(method, pathSegments, queryParameters, null, HttpStatusCodes.METHOD_NOT_ALLOWED);
}
@@ -396,7 +398,8 @@ public class ODataRequestHandlerValidationTest extends BaseTest {
null);
}
- private void wrongProperty(final ODataHttpMethod method, final boolean ofComplex, final Boolean key) throws ODataException {
+ private void wrongProperty(final ODataHttpMethod method, final boolean ofComplex, final Boolean key)
+ throws ODataException {
EdmProperty property = (EdmProperty) (ofComplex ?
edm.getComplexType("RefScenario", "c_Location").getProperty("Country") :
edm.getEntityType("RefScenario", "Employee").getProperty("Age"));
@@ -416,20 +419,25 @@ public class ODataRequestHandlerValidationTest extends BaseTest {
wrongRequest(method, pathSegments, null);
}
- private void wrongNavigationPath(final ODataHttpMethod method, final UriType uriType, final HttpStatusCodes expectedStatusCode) throws ODataException {
+ private void wrongNavigationPath(final ODataHttpMethod method, final UriType uriType,
+ final HttpStatusCodes expectedStatusCode) throws ODataException {
executeAndValidateRequest(method, createPathSegments(uriType, true, false), null, null, expectedStatusCode);
}
- private void wrongRequestContentType(final ODataHttpMethod method, final UriType uriType, final ContentType requestContentType) throws ODataException {
+ private void wrongRequestContentType(final ODataHttpMethod method, final UriType uriType,
+ final ContentType requestContentType) throws ODataException {
wrongRequestContentType(method, uriType, false, requestContentType);
}
- private void wrongRequestContentType(final ODataHttpMethod method, final UriType uriType, final boolean isValue, final ContentType requestContentType) throws ODataException {
+ private void wrongRequestContentType(final ODataHttpMethod method, final UriType uriType, final boolean isValue,
+ final ContentType requestContentType) throws ODataException {
wrongRequestContentType(method, uriType, isValue, requestContentType.toContentTypeString());
}
- private void wrongRequestContentType(final ODataHttpMethod method, final UriType uriType, final boolean isValue, final String requestContentType) throws ODataException {
- executeAndValidateRequest(method, createPathSegments(uriType, false, isValue), null, requestContentType, HttpStatusCodes.UNSUPPORTED_MEDIA_TYPE);
+ private void wrongRequestContentType(final ODataHttpMethod method, final UriType uriType, final boolean isValue,
+ final String requestContentType) throws ODataException {
+ executeAndValidateRequest(method, createPathSegments(uriType, false, isValue), null, requestContentType,
+ HttpStatusCodes.UNSUPPORTED_MEDIA_TYPE);
}
@Test
@@ -438,7 +446,8 @@ public class ODataRequestHandlerValidationTest extends BaseTest {
final ODataService service = mockODataService(serviceFactory);
when(serviceFactory.createService(any(ODataContext.class))).thenReturn(service);
- ODataRequest request = mockODataRequest(ODataHttpMethod.GET, createPathSegments(UriType.URI0, false, false), null, null);
+ ODataRequest request =
+ mockODataRequest(ODataHttpMethod.GET, createPathSegments(UriType.URI0, false, false), null, null);
ODataContextImpl context = new ODataContextImpl(request, serviceFactory);
final ODataRequestHandler handler = new ODataRequestHandler(serviceFactory, service, context);
@@ -472,13 +481,17 @@ public class ODataRequestHandlerValidationTest extends BaseTest {
public void allowedMethods() throws Exception {
executeAndValidateRequest(ODataHttpMethod.GET, createPathSegments(UriType.URI0, false, false), null, null, null);
executeAndValidateRequest(ODataHttpMethod.GET, createPathSegments(UriType.URI1, false, false), null, null, null);
- executeAndValidateRequest(ODataHttpMethod.POST, createPathSegments(UriType.URI1, false, false), null, HttpContentType.APPLICATION_JSON, null);
+ executeAndValidateRequest(ODataHttpMethod.POST, createPathSegments(UriType.URI1, false, false), null,
+ HttpContentType.APPLICATION_JSON, null);
executeAndValidateRequest(ODataHttpMethod.GET, createPathSegments(UriType.URI2, false, false), null, null, null);
executeAndValidateRequest(ODataHttpMethod.GET, createPathSegments(UriType.URI3, false, false), null, null, null);
- executeAndValidateRequest(ODataHttpMethod.PATCH, createPathSegments(UriType.URI3, false, false), null, HttpContentType.APPLICATION_JSON, null);
- executeAndValidateRequest(ODataHttpMethod.MERGE, createPathSegments(UriType.URI3, false, false), null, HttpContentType.APPLICATION_JSON, null);
+ executeAndValidateRequest(ODataHttpMethod.PATCH, createPathSegments(UriType.URI3, false, false), null,
+ HttpContentType.APPLICATION_JSON, null);
+ executeAndValidateRequest(ODataHttpMethod.MERGE, createPathSegments(UriType.URI3, false, false), null,
+ HttpContentType.APPLICATION_JSON, null);
executeAndValidateRequest(ODataHttpMethod.GET, createPathSegments(UriType.URI4, false, false), null, null, null);
- executeAndValidateRequest(ODataHttpMethod.POST, createPathSegments(UriType.URI9, false, false), null, HttpContentType.MULTIPART_MIXED, null);
+ executeAndValidateRequest(ODataHttpMethod.POST, createPathSegments(UriType.URI9, false, false), null,
+ HttpContentType.MULTIPART_MIXED, null);
executeAndValidateRequest(ODataHttpMethod.GET, createPathSegments(UriType.URI15, false, false), null, null, null);
executeAndValidateRequest(ODataHttpMethod.GET, createPathSegments(UriType.URI17, false, false), null, null, null);
}
@@ -558,12 +571,12 @@ public class ODataRequestHandlerValidationTest extends BaseTest {
wrongOptions(ODataHttpMethod.POST, UriType.URI7B, false, false, false, false, false, false, true, false, false);
wrongOptions(ODataHttpMethod.PUT, UriType.URI17, false, true, false, false, false, false, false, false, false);
- executeAndValidateRequest(ODataHttpMethod.PUT, createPathSegments(UriType.URI17, false, false),
- createOptions(true, false, false, false, false, false, false, false, false),
+ executeAndValidateRequest(ODataHttpMethod.PUT, createPathSegments(UriType.URI17, false, false),
+ createOptions(true, false, false, false, false, false, false, false, false),
null, HttpStatusCodes.BAD_REQUEST);
-
- executeAndValidateRequest(ODataHttpMethod.DELETE, createPathSegments(UriType.URI17, false, false),
- createOptions(true, false, false, false, false, false, false, false, false),
+
+ executeAndValidateRequest(ODataHttpMethod.DELETE, createPathSegments(UriType.URI17, false, false),
+ createOptions(true, false, false, false, false, false, false, false, false),
null, HttpStatusCodes.BAD_REQUEST);
// wrongOptions(ODataHttpMethod.DELETE, UriType.URI17, true, false, false, false, false, false, false, false, false);
@@ -615,84 +628,106 @@ public class ODataRequestHandlerValidationTest extends BaseTest {
wrongNavigationPath(ODataHttpMethod.DELETE, UriType.URI17, HttpStatusCodes.BAD_REQUEST);
}
-
@Test
public void requestAcceptHeader() throws Exception {
- executeAndValidateGetRequest(createPathSegments(UriType.URI1, false, false), null,
+ executeAndValidateGetRequest(createPathSegments(UriType.URI1, false, false), null,
Arrays.asList(HttpContentType.APPLICATION_JSON), null);
- executeAndValidateGetRequest(createPathSegments(UriType.URI2, false, false), null,
+ executeAndValidateGetRequest(createPathSegments(UriType.URI2, false, false), null,
Arrays.asList(HttpContentType.APPLICATION_JSON), null);
- executeAndValidateGetRequest(createPathSegments(UriType.URI3, false, false), null,
+ executeAndValidateGetRequest(createPathSegments(UriType.URI3, false, false), null,
Arrays.asList(HttpContentType.APPLICATION_JSON), null);
- executeAndValidateGetRequest(createPathSegments(UriType.URI4, false, false), null,
+ executeAndValidateGetRequest(createPathSegments(UriType.URI4, false, false), null,
Arrays.asList(HttpContentType.APPLICATION_JSON), null);
- executeAndValidateGetRequest(createPathSegments(UriType.URI5, false, false), null,
+ executeAndValidateGetRequest(createPathSegments(UriType.URI5, false, false), null,
Arrays.asList(HttpContentType.APPLICATION_JSON), null);
- executeAndValidateGetRequest(createPathSegments(UriType.URI6A, false, false), null,
+ executeAndValidateGetRequest(createPathSegments(UriType.URI6A, false, false), null,
Arrays.asList(HttpContentType.APPLICATION_JSON), null);
- executeAndValidateGetRequest(createPathSegments(UriType.URI6B, false, false), null,
+ executeAndValidateGetRequest(createPathSegments(UriType.URI6B, false, false), null,
Arrays.asList(HttpContentType.APPLICATION_JSON), null);
- executeAndValidateGetRequest(createPathSegments(UriType.URI7A, false, false), null,
+ executeAndValidateGetRequest(createPathSegments(UriType.URI7A, false, false), null,
Arrays.asList(HttpContentType.APPLICATION_JSON), null);
- executeAndValidateGetRequest(createPathSegments(UriType.URI7B, false, false), null,
+ executeAndValidateGetRequest(createPathSegments(UriType.URI7B, false, false), null,
Arrays.asList(HttpContentType.APPLICATION_JSON), null);
- executeAndValidateGetRequest(createPathSegments(UriType.URI8, false, false), null,
+ executeAndValidateGetRequest(createPathSegments(UriType.URI8, false, false), null,
Arrays.asList(HttpContentType.APPLICATION_XML), null);
// in discussion, hence currently not implemented (see ODataRequestHandler#doContentNegotiation(...))
// executeAndValidateGetRequest(createPathSegments(UriType.URI8, false, false), null,
// Arrays.asList(HttpContentType.TEXT_PLAIN), null);
- executeAndValidateGetRequest(createPathSegments(UriType.URI9, false, false), null,
+ executeAndValidateGetRequest(createPathSegments(UriType.URI9, false, false), null,
Arrays.asList(HttpContentType.APPLICATION_XML), HttpStatusCodes.METHOD_NOT_ALLOWED);
- executeAndValidateGetRequest(createPathSegments(UriType.URI15, false, false), null,
+ executeAndValidateGetRequest(createPathSegments(UriType.URI15, false, false), null,
Arrays.asList(HttpContentType.TEXT_PLAIN), null);
- executeAndValidateGetRequest(createPathSegments(UriType.URI16, false, false), null,
+ executeAndValidateGetRequest(createPathSegments(UriType.URI16, false, false), null,
Arrays.asList(HttpContentType.TEXT_PLAIN), null);
- executeAndValidateGetRequest(createPathSegments(UriType.URI17, false, true), null,
+ executeAndValidateGetRequest(createPathSegments(UriType.URI17, false, true), null,
Arrays.asList(HttpContentType.APPLICATION_OCTET_STREAM), null);
- executeAndValidateGetRequest(createPathSegments(UriType.URI50A, false, false), null,
+ executeAndValidateGetRequest(createPathSegments(UriType.URI50A, false, false), null,
Arrays.asList(HttpContentType.APPLICATION_XML), null);
- executeAndValidateGetRequest(createPathSegments(UriType.URI50B, false, false), null,
+ executeAndValidateGetRequest(createPathSegments(UriType.URI50B, false, false), null,
Arrays.asList(HttpContentType.APPLICATION_XML), null);
}
-
+
@Test
public void requestContentType() throws Exception {
- executeAndValidateRequest(ODataHttpMethod.PUT, createPathSegments(UriType.URI2, false, false), null, HttpContentType.APPLICATION_XML, null);
- executeAndValidateRequest(ODataHttpMethod.PATCH, createPathSegments(UriType.URI2, false, false), null, HttpContentType.APPLICATION_XML, null);
- executeAndValidateRequest(ODataHttpMethod.MERGE, createPathSegments(UriType.URI2, false, false), null, HttpContentType.APPLICATION_XML, null);
-
- executeAndValidateRequest(ODataHttpMethod.PUT, createPathSegments(UriType.URI3, false, false), null, HttpContentType.APPLICATION_XML, null);
- executeAndValidateRequest(ODataHttpMethod.PATCH, createPathSegments(UriType.URI3, false, false), null, HttpContentType.APPLICATION_XML, null);
- executeAndValidateRequest(ODataHttpMethod.MERGE, createPathSegments(UriType.URI3, false, false), null, HttpContentType.APPLICATION_XML, null);
-
- executeAndValidateRequest(ODataHttpMethod.PUT, createPathSegments(UriType.URI4, false, false), null, HttpContentType.APPLICATION_XML, null);
- executeAndValidateRequest(ODataHttpMethod.PATCH, createPathSegments(UriType.URI4, false, false), null, HttpContentType.APPLICATION_XML, null);
- executeAndValidateRequest(ODataHttpMethod.MERGE, createPathSegments(UriType.URI4, false, false), null, HttpContentType.APPLICATION_XML, null);
-
- executeAndValidateRequest(ODataHttpMethod.PUT, createPathSegments(UriType.URI5, false, false), null, HttpContentType.APPLICATION_XML, null);
- executeAndValidateRequest(ODataHttpMethod.PATCH, createPathSegments(UriType.URI5, false, false), null, HttpContentType.APPLICATION_XML, null);
- executeAndValidateRequest(ODataHttpMethod.MERGE, createPathSegments(UriType.URI5, false, false), null, HttpContentType.APPLICATION_XML, null);
-
- executeAndValidateRequest(ODataHttpMethod.PUT, createPathSegments(UriType.URI6A, false, false), null, HttpContentType.APPLICATION_XML, HttpStatusCodes.BAD_REQUEST);
- executeAndValidateRequest(ODataHttpMethod.PATCH, createPathSegments(UriType.URI6A, false, false), null, HttpContentType.APPLICATION_XML, HttpStatusCodes.BAD_REQUEST);
- executeAndValidateRequest(ODataHttpMethod.MERGE, createPathSegments(UriType.URI6A, false, false), null, HttpContentType.APPLICATION_XML, HttpStatusCodes.BAD_REQUEST);
-
- executeAndValidateRequest(ODataHttpMethod.POST, createPathSegments(UriType.URI6B, false, false), null, HttpContentType.APPLICATION_XML, null);
-
- executeAndValidateRequest(ODataHttpMethod.PUT, createPathSegments(UriType.URI7A, false, false), null, HttpContentType.APPLICATION_XML, null);
- executeAndValidateRequest(ODataHttpMethod.PATCH, createPathSegments(UriType.URI7A, false, false), null, HttpContentType.APPLICATION_XML, null);
- executeAndValidateRequest(ODataHttpMethod.MERGE, createPathSegments(UriType.URI7A, false, false), null, HttpContentType.APPLICATION_XML, null);
-
- executeAndValidateRequest(ODataHttpMethod.POST, createPathSegments(UriType.URI7B, false, false), null, HttpContentType.APPLICATION_XML, null);
-
- executeAndValidateRequest(ODataHttpMethod.POST, createPathSegments(UriType.URI9, false, false), null, HttpContentType.MULTIPART_MIXED, null);
+ executeAndValidateRequest(ODataHttpMethod.PUT, createPathSegments(UriType.URI2, false, false), null,
+ HttpContentType.APPLICATION_XML, null);
+ executeAndValidateRequest(ODataHttpMethod.PATCH, createPathSegments(UriType.URI2, false, false), null,
+ HttpContentType.APPLICATION_XML, null);
+ executeAndValidateRequest(ODataHttpMethod.MERGE, createPathSegments(UriType.URI2, false, false), null,
+ HttpContentType.APPLICATION_XML, null);
+
+ executeAndValidateRequest(ODataHttpMethod.PUT, createPathSegments(UriType.URI3, false, false), null,
+ HttpContentType.APPLICATION_XML, null);
+ executeAndValidateRequest(ODataHttpMethod.PATCH, createPathSegments(UriType.URI3, false, false), null,
+ HttpContentType.APPLICATION_XML, null);
+ executeAndValidateRequest(ODataHttpMethod.MERGE, createPathSegments(UriType.URI3, false, false), null,
+ HttpContentType.APPLICATION_XML, null);
+
+ executeAndValidateRequest(ODataHttpMethod.PUT, createPathSegments(UriType.URI4, false, false), null,
+ HttpContentType.APPLICATION_XML, null);
+ executeAndValidateRequest(ODataHttpMethod.PATCH, createPathSegments(UriType.URI4, false, false), null,
+ HttpContentType.APPLICATION_XML, null);
+ executeAndValidateRequest(ODataHttpMethod.MERGE, createPathSegments(UriType.URI4, false, false), null,
+ HttpContentType.APPLICATION_XML, null);
+
+ executeAndValidateRequest(ODataHttpMethod.PUT, createPathSegments(UriType.URI5, false, false), null,
+ HttpContentType.APPLICATION_XML, null);
+ executeAndValidateRequest(ODataHttpMethod.PATCH, createPathSegments(UriType.URI5, false, false), null,
+ HttpContentType.APPLICATION_XML, null);
+ executeAndValidateRequest(ODataHttpMethod.MERGE, createPathSegments(UriType.URI5, false, false), null,
+ HttpContentType.APPLICATION_XML, null);
+
+ executeAndValidateRequest(ODataHttpMethod.PUT, createPathSegments(UriType.URI6A, false, false), null,
+ HttpContentType.APPLICATION_XML, HttpStatusCodes.BAD_REQUEST);
+ executeAndValidateRequest(ODataHttpMethod.PATCH, createPathSegments(UriType.URI6A, false, false), null,
+ HttpContentType.APPLICATION_XML, HttpStatusCodes.BAD_REQUEST);
+ executeAndValidateRequest(ODataHttpMethod.MERGE, createPathSegments(UriType.URI6A, false, false), null,
+ HttpContentType.APPLICATION_XML, HttpStatusCodes.BAD_REQUEST);
+
+ executeAndValidateRequest(ODataHttpMethod.POST, createPathSegments(UriType.URI6B, false, false), null,
+ HttpContentType.APPLICATION_XML, null);
+
+ executeAndValidateRequest(ODataHttpMethod.PUT, createPathSegments(UriType.URI7A, false, false), null,
+ HttpContentType.APPLICATION_XML, null);
+ executeAndValidateRequest(ODataHttpMethod.PATCH, createPathSegments(UriType.URI7A, false, false), null,
+ HttpContentType.APPLICATION_XML, null);
+ executeAndValidateRequest(ODataHttpMethod.MERGE, createPathSegments(UriType.URI7A, false, false), null,
+ HttpContentType.APPLICATION_XML, null);
+
+ executeAndValidateRequest(ODataHttpMethod.POST, createPathSegments(UriType.URI7B, false, false), null,
+ HttpContentType.APPLICATION_XML, null);
+
+ executeAndValidateRequest(ODataHttpMethod.POST, createPathSegments(UriType.URI9, false, false), null,
+ HttpContentType.MULTIPART_MIXED, null);
}
@Test
public void requestContentTypeMediaResource() throws Exception {
- executeAndValidateRequest(ODataHttpMethod.POST, createPathSegments(UriType.URI1, false, false), null, "image/jpeg", null);
+ executeAndValidateRequest(ODataHttpMethod.POST, createPathSegments(UriType.URI1, false, false), null, "image/jpeg",
+ null);
- executeAndValidateRequest(ODataHttpMethod.PUT, createPathSegments(UriType.URI17, false, true), null, "image/jpeg", null);
+ executeAndValidateRequest(ODataHttpMethod.PUT, createPathSegments(UriType.URI17, false, true), null, "image/jpeg",
+ null);
}
@Test
@@ -700,7 +735,8 @@ public class ODataRequestHandlerValidationTest extends BaseTest {
EdmFunctionImport function = edm.getDefaultEntityContainer().getFunctionImport("MaximalAge");
when(function.getHttpMethod()).thenReturn(ODataHttpMethod.PUT.name());
executeAndValidateRequest(ODataHttpMethod.PUT, createPathSegments(UriType.URI14, false, false), null, null, null);
- executeAndValidateRequest(ODataHttpMethod.PUT, createPathSegments(UriType.URI14, false, false), null, HttpContentType.WILDCARD, null);
+ executeAndValidateRequest(ODataHttpMethod.PUT, createPathSegments(UriType.URI14, false, false), null,
+ HttpContentType.WILDCARD, null);
checkValueContentType(ODataHttpMethod.PUT, UriType.URI14, null);
checkValueContentType(ODataHttpMethod.PUT, UriType.URI14, HttpContentType.WILDCARD);
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/a030e42b/odata-core/src/test/java/org/apache/olingo/odata2/core/ODataResponseTest.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/ODataResponseTest.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/ODataResponseTest.java
index fe5d8e9..fb20afc 100644
--- a/odata-core/src/test/java/org/apache/olingo/odata2/core/ODataResponseTest.java
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/ODataResponseTest.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
******************************************************************************/
package org.apache.olingo.odata2.core;
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/a030e42b/odata-core/src/test/java/org/apache/olingo/odata2/core/PathSegmentTest.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/PathSegmentTest.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/PathSegmentTest.java
index 013cd4c..969a07c 100644
--- a/odata-core/src/test/java/org/apache/olingo/odata2/core/PathSegmentTest.java
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/PathSegmentTest.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
******************************************************************************/
package org.apache.olingo.odata2.core;
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/a030e42b/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/AcceptParserTest.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/AcceptParserTest.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/AcceptParserTest.java
index 3b530e9..a3c0512 100644
--- a/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/AcceptParserTest.java
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/AcceptParserTest.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
******************************************************************************/
package org.apache.olingo.odata2.core.batch;
@@ -31,7 +31,8 @@ public class AcceptParserTest {
@Test
public void testAcceptHeader() throws BatchException {
- List<String> acceptHeaders = AcceptParser.parseAcceptHeaders("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
+ List<String> acceptHeaders =
+ AcceptParser.parseAcceptHeaders("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
assertNotNull(acceptHeaders);
assertEquals(4, acceptHeaders.size());
assertEquals("text/html", acceptHeaders.get(0));
@@ -72,7 +73,8 @@ public class AcceptParserTest {
@Test
public void testAcceptHeaderWithTwoParameters() throws BatchException {
- List<String> acceptHeaders = AcceptParser.parseAcceptHeaders("application/xml;another=test ; param=alskdf, */*;q=0.1");
+ List<String> acceptHeaders =
+ AcceptParser.parseAcceptHeaders("application/xml;another=test ; param=alskdf, */*;q=0.1");
assertNotNull(acceptHeaders);
assertEquals(2, acceptHeaders.size());
assertEquals("application/xml;another=test ; param=alskdf", acceptHeaders.get(0));
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/a030e42b/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestParserTest.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestParserTest.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestParserTest.java
index 725a810..f66a864 100644
--- a/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestParserTest.java
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestParserTest.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
******************************************************************************/
package org.apache.olingo.odata2.core.batch;
@@ -95,7 +95,8 @@ public class BatchRequestParserTest {
if (retrieveRequest.getQueryParameters().get("$format") != null) {
assertEquals("json", retrieveRequest.getQueryParameters().get("$format"));
}
- assertEquals(SERVICE_ROOT + "Employees('2')/EmployeeName?$format=json", retrieveRequest.getPathInfo().getRequestUri().toASCIIString());
+ assertEquals(SERVICE_ROOT + "Employees('2')/EmployeeName?$format=json", retrieveRequest.getPathInfo()
+ .getRequestUri().toASCIIString());
} else {
List<ODataRequest> requests = object.getRequests();
for (ODataRequest request : requests) {
@@ -108,7 +109,8 @@ public class BatchRequestParserTest {
assertTrue(request.getAcceptableLanguages().isEmpty());
assertEquals("*/*", request.getAcceptHeaders().get(2));
assertEquals("application/atomsvc+xml", request.getAcceptHeaders().get(0));
- assertEquals(new URI(SERVICE_ROOT + "Employees('2')/EmployeeName").toASCIIString(), request.getPathInfo().getRequestUri().toASCIIString());
+ assertEquals(new URI(SERVICE_ROOT + "Employees('2')/EmployeeName").toASCIIString(), request.getPathInfo()
+ .getRequestUri().toASCIIString());
ODataPathSegmentImpl pathSegment = new ODataPathSegmentImpl("Employees('2')", null);
assertEquals(pathSegment.getPath(), request.getPathInfo().getODataSegments().get(0).getPath());
@@ -159,7 +161,8 @@ public class BatchRequestParserTest {
ODataRequest retrieveRequest = object.getRequests().get(0);
assertEquals(ODataHttpMethod.GET, retrieveRequest.getMethod());
assertEquals("Age gt 40", retrieveRequest.getQueryParameters().get("$filter"));
- assertEquals(new URI("http://localhost/odata/Employees?$filter=Age%20gt%2040"), retrieveRequest.getPathInfo().getRequestUri());
+ assertEquals(new URI("http://localhost/odata/Employees?$filter=Age%20gt%2040"), retrieveRequest.getPathInfo()
+ .getRequestUri());
} else {
List<ODataRequest> requests = object.getRequests();
for (ODataRequest request : requests) {
@@ -283,7 +286,7 @@ public class BatchRequestParserTest {
public void testNoBoundaryString() throws BatchException {
String batch = "--batch_8194-cf13-1f56" + LF
+ GET_REQUEST
- //+ no boundary string
+ // + no boundary string
+ GET_REQUEST
+ "--batch_8194-cf13-1f56--";
parseInvalidBatchBody(batch);
@@ -371,7 +374,7 @@ public class BatchRequestParserTest {
String batch = "--batch_8194-cf13-1f56" + LF
+ MIME_HEADERS
+ LF
- + /*GET*/"Employees('1')/EmployeeName HTTP/1.1" + LF
+ + /* GET */"Employees('1')/EmployeeName HTTP/1.1" + LF
+ LF
+ "--batch_8194-cf13-1f56--";
parseInvalidBatchBody(batch);
@@ -398,7 +401,7 @@ public class BatchRequestParserTest {
String batch = "--batch_8194-cf13-1f56" + LF
+ "Content-Type: multipart/mixed;boundary=changeset_f980-1cb6-94dd" + LF
+ LF
- + "--changeset_f980-1cb6-94d"/*+"d"*/+ LF
+ + "--changeset_f980-1cb6-94d"/* +"d" */+ LF
+ MIME_HEADERS
+ LF
+ "POST Employees('2') HTTP/1.1" + LF
@@ -451,22 +454,29 @@ public class BatchRequestParserTest {
@Test(expected = BatchException.class)
public void testNoCloseDelimiter3() throws BatchException {
- String batch = "--batch_8194-cf13-1f56" + LF + GET_REQUEST + "--batch_8194-cf13-1f56-"/*no hash*/;
+ String batch = "--batch_8194-cf13-1f56" + LF + GET_REQUEST + "--batch_8194-cf13-1f56-"/* no hash */;
parseInvalidBatchBody(batch);
}
@Test
public void testAcceptHeaders() throws BatchException, URISyntaxException {
- String batch = "--batch_8194-cf13-1f56" + LF
- + MIME_HEADERS
- + LF
- + "GET Employees('2')/EmployeeName HTTP/1.1" + LF
- + "Content-Length: 100000" + LF
- + "Content-Type: application/json;odata=verbose" + LF
- + "Accept: application/xml;q=0.3, application/atomsvc+xml;q=0.8, application/json;odata=verbose;q=0.5, */*;q=0.001" + LF
- + LF
- + LF
- + "--batch_8194-cf13-1f56--";
+ String batch =
+ "--batch_8194-cf13-1f56"
+ + LF
+ + MIME_HEADERS
+ + LF
+ + "GET Employees('2')/EmployeeName HTTP/1.1"
+ + LF
+ + "Content-Length: 100000"
+ + LF
+ + "Content-Type: application/json;odata=verbose"
+ + LF
+ + "Accept: application/xml;q=0.3, application/atomsvc+xml;q=0.8, " +
+ "application/json;odata=verbose;q=0.5, */*;q=0.001"
+ + LF
+ + LF
+ + LF
+ + "--batch_8194-cf13-1f56--";
List<BatchRequestPart> batchRequestParts = parse(batch);
for (BatchRequestPart multipart : batchRequestParts) {
if (!multipart.isChangeSet()) {
@@ -585,10 +595,13 @@ public class BatchRequestParserTest {
} else {
for (ODataRequest request : multipart.getRequests()) {
if (ODataHttpMethod.POST.equals(request.getMethod())) {
- assertEquals(CONTENT_ID_REFERENCE, request.getRequestHeaderValue(BatchHelper.MIME_HEADER_CONTENT_ID.toLowerCase()));
+ assertEquals(CONTENT_ID_REFERENCE, request.getRequestHeaderValue(BatchHelper.MIME_HEADER_CONTENT_ID
+ .toLowerCase()));
} else if (ODataHttpMethod.PUT.equals(request.getMethod())) {
- assertEquals(PUT_MIME_HEADER_CONTENT_ID, request.getRequestHeaderValue(BatchHelper.MIME_HEADER_CONTENT_ID.toLowerCase()));
- assertEquals(PUT_REQUEST_HEADER_CONTENT_ID, request.getRequestHeaderValue(BatchHelper.REQUEST_HEADER_CONTENT_ID.toLowerCase()));
+ assertEquals(PUT_MIME_HEADER_CONTENT_ID, request.getRequestHeaderValue(BatchHelper.MIME_HEADER_CONTENT_ID
+ .toLowerCase()));
+ assertEquals(PUT_REQUEST_HEADER_CONTENT_ID, request
+ .getRequestHeaderValue(BatchHelper.REQUEST_HEADER_CONTENT_ID.toLowerCase()));
assertNull(request.getPathInfo().getRequestUri());
assertEquals("$" + CONTENT_ID_REFERENCE, request.getPathInfo().getODataSegments().get(0).getPath());
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/a030e42b/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestWriterTest.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestWriterTest.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestWriterTest.java
index 61e6709..1331e73 100644
--- a/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestWriterTest.java
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestWriterTest.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
******************************************************************************/
package org.apache.olingo.odata2.core.batch;
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/a030e42b/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchResponseParserTest.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchResponseParserTest.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchResponseParserTest.java
index 7936051..06daa2a 100644
--- a/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchResponseParserTest.java
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchResponseParserTest.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
******************************************************************************/
package org.apache.olingo.odata2.core.batch;
@@ -152,7 +152,7 @@ public class BatchResponseParserTest {
@Test(expected = BatchException.class)
public void testInvalidContentType() throws BatchException {
String putResponse = "--batch_123" + LF
- + "Content-Type: " + HttpContentType.MULTIPART_MIXED + LF //Missing boundary parameter
+ + "Content-Type: " + HttpContentType.MULTIPART_MIXED + LF // Missing boundary parameter
+ LF
+ "--changeset_12ks93js84d" + LF
+ "Content-Type: application/http" + LF
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/a030e42b/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchResponseWriterTest.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchResponseWriterTest.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchResponseWriterTest.java
index 8ea770a..ea7d2bb 100644
--- a/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchResponseWriterTest.java
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchResponseWriterTest.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
******************************************************************************/
package org.apache.olingo.odata2.core.batch;
@@ -72,7 +72,8 @@ public class BatchResponseWriterTest {
@Test
public void testResponse() throws BatchException, IOException {
List<BatchResponsePart> parts = new ArrayList<BatchResponsePart>();
- ODataResponse response = ODataResponse.entity("Walter Winter").status(HttpStatusCodes.OK).contentHeader("application/json").build();
+ ODataResponse response =
+ ODataResponse.entity("Walter Winter").status(HttpStatusCodes.OK).contentHeader("application/json").build();
List<ODataResponse> responses = new ArrayList<ODataResponse>(1);
responses.add(response);
parts.add(BatchResponsePart.responses(responses).changeSet(false).build());
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/a030e42b/odata-core/src/test/java/org/apache/olingo/odata2/core/commons/ContentTypeTest.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/commons/ContentTypeTest.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/commons/ContentTypeTest.java
index 14cac0f..439bb89 100644
--- a/odata-core/src/test/java/org/apache/olingo/odata2/core/commons/ContentTypeTest.java
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/commons/ContentTypeTest.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
******************************************************************************/
package org.apache.olingo.odata2.core.commons;
@@ -77,7 +77,7 @@ public class ContentTypeTest extends BaseTest {
assertFalse(ContentType.isParseable("application /atom+xml; charset=UTF-8"));
//
assertFalse(ContentType.isParseable("app/app/moreapp"));
- //assertFalse(ContentType.isParseable("application/atom+xml; charset = UTF-8"));
+ // assertFalse(ContentType.isParseable("application/atom+xml; charset = UTF-8"));
assertFalse(ContentType.isParseable(null));
assertFalse(ContentType.isParseable(""));
assertFalse(ContentType.isParseable("hugo"));
@@ -94,7 +94,7 @@ public class ContentTypeTest extends BaseTest {
assertFalse(ContentType.isParseable("application /atom+xml; charset=UTF-8"));
//
assertNull(ContentType.parse("app/app/moreapp"));
- //assertFalse(ContentType.isParseable("application/atom+xml; charset = UTF-8"));
+ // assertFalse(ContentType.isParseable("application/atom+xml; charset = UTF-8"));
assertNull(ContentType.parse(null));
assertNull(ContentType.parse("hugo"));
assertNull(ContentType.parse("hugo"));
@@ -126,14 +126,14 @@ public class ContentTypeTest extends BaseTest {
List<ContentType> contentTypes = ContentType.createAsCustom(Arrays.asList("custom", "image/jpeg"));
Assert.assertEquals(2, contentTypes.size());
-
- for (ContentType contentType: contentTypes) {
- if(contentType.getType().equals("custom")) {
+
+ for (ContentType contentType : contentTypes) {
+ if (contentType.getType().equals("custom")) {
assertEquals("custom", contentType.getType());
assertNull(contentType.getSubtype());
assertEquals("custom", contentType.toString());
assertEquals(ODataFormat.CUSTOM, contentType.getODataFormat());
- } else if(contentType.getType().equals("image")) {
+ } else if (contentType.getType().equals("image")) {
assertEquals("image", contentType.getType());
assertEquals("jpeg", contentType.getSubtype());
assertEquals("image/jpeg", contentType.toString());
@@ -241,11 +241,13 @@ public class ContentTypeTest extends BaseTest {
/**
* See: RFC 2616:
- * The type, subtype, and parameter attribute names are case-insensitive. Parameter values might or might not be case-sensitive,
- * depending on the semantics of the parameter name. Linear white space (LWS) MUST NOT be used between the type and subtype,
+ * The type, subtype, and parameter attribute names are case-insensitive. Parameter values might or might not be
+ * case-sensitive,
+ * depending on the semantics of the parameter name. Linear white space (LWS) MUST NOT be used between the type and
+ * subtype,
* nor between an attribute and its value.
* </p>
- * @throws Throwable
+ * @throws Throwable
*/
@Test
public void testContentTypeCreationInvalidWithSpaces() throws Throwable {
@@ -254,7 +256,9 @@ public class ContentTypeTest extends BaseTest {
failContentTypeCreation("app / space", IllegalArgumentException.class);
}
- private void failContentTypeCreation(final String contentType, final Class<? extends Exception> expectedExceptionClass) throws Exception {
+ private void
+ failContentTypeCreation(final String contentType, final Class<? extends Exception> expectedExceptionClass)
+ throws Exception {
try {
ContentType.create(contentType);
Assert.fail("Expected exception class " + expectedExceptionClass +
@@ -366,7 +370,8 @@ public class ContentTypeTest extends BaseTest {
@Test
public void testContentTypeCreationFromStrings() {
- List<ContentType> types = ContentType.create(Arrays.asList("type/subtype", "application/xml", "application/json;key=value"));
+ List<ContentType> types =
+ ContentType.create(Arrays.asList("type/subtype", "application/xml", "application/json;key=value"));
assertEquals(3, types.size());
@@ -392,7 +397,8 @@ public class ContentTypeTest extends BaseTest {
@Test(expected = IllegalArgumentException.class)
public void testContentTypeCreationFromStringsFail() {
- List<ContentType> types = ContentType.create(Arrays.asList("type/subtype", "application/xml", "application/json/FAIL;key=value"));
+ List<ContentType> types =
+ ContentType.create(Arrays.asList("type/subtype", "application/xml", "application/json/FAIL;key=value"));
assertEquals(3, types.size());
}
@@ -471,27 +477,27 @@ public class ContentTypeTest extends BaseTest {
assertEquals("type/subtype;key1=value1;key2=value2", mt.toString());
}
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testFormatParserInValidInputOnlyType() {
ContentType.create("aaa");
}
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testFormatParserInValidInputOnlyTypeWithSepartor() {
ContentType.create("aaa/");
}
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testFormatParserInValidInputOnlySubTypeWithSepartor() {
ContentType.create("/aaa");
}
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testFormatParserInValidInputOnlySepartor() {
ContentType.create("/");
}
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testFormatParserInValidInputEmpty() {
ContentType.create("");
}
@@ -529,7 +535,7 @@ public class ContentTypeTest extends BaseTest {
assertEquals(2, t.getParameters().size());
}
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testFormatParserInValidInputTypeNullPara() {
ContentType.create("aaa;x=y;a");
}
@@ -973,14 +979,14 @@ public class ContentTypeTest extends BaseTest {
@Test
public void testQParameterSort() {
- validateSort(Arrays.asList("a1/b1;q=0.2", "a2/b2;q=0.5", "a3/b3;q=0.333"), 1,2,0);
- validateSort(Arrays.asList("a1/b1;q=0", "a2/b2;q=0.5", "a3/b3;q=0.333"), 1,2,0);
- validateSort(Arrays.asList("a1/b1;q=1", "a2/b2;q=0.5", "a3/b3;q=0.333"), 0,1,2);
- validateSort(Arrays.asList("a1/b1;q=1", "a2/b2;q=0.5", "a3/b3;q=1.333"), 0,1,2);
- validateSort(Arrays.asList("a1/b1;q=0.2", "a2/b2;q=0.9", "a3/b3"), 2,1,0);
+ validateSort(Arrays.asList("a1/b1;q=0.2", "a2/b2;q=0.5", "a3/b3;q=0.333"), 1, 2, 0);
+ validateSort(Arrays.asList("a1/b1;q=0", "a2/b2;q=0.5", "a3/b3;q=0.333"), 1, 2, 0);
+ validateSort(Arrays.asList("a1/b1;q=1", "a2/b2;q=0.5", "a3/b3;q=0.333"), 0, 1, 2);
+ validateSort(Arrays.asList("a1/b1;q=1", "a2/b2;q=0.5", "a3/b3;q=1.333"), 0, 1, 2);
+ validateSort(Arrays.asList("a1/b1;q=0.2", "a2/b2;q=0.9", "a3/b3"), 2, 1, 0);
}
- private void validateSort(List<String> toSort, int ... expectedSequence) {
+ private void validateSort(final List<String> toSort, final int... expectedSequence) {
List<String> expected = new ArrayList<String>();
for (int i : expectedSequence) {
expected.add(toSort.get(i));
@@ -991,7 +997,7 @@ public class ContentTypeTest extends BaseTest {
assertEquals(expected.get(i), toSort.get(i));
}
}
-
+
private Map<String, String> addParameters(final String... content) {
Map<String, String> map = new HashMap<String, String>();
for (int i = 0; i < content.length - 1; i += 2) {
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/a030e42b/odata-core/src/test/java/org/apache/olingo/odata2/core/commons/DecoderTest.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/commons/DecoderTest.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/commons/DecoderTest.java
index 1a33259..a9c8299 100644
--- a/odata-core/src/test/java/org/apache/olingo/odata2/core/commons/DecoderTest.java
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/commons/DecoderTest.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
******************************************************************************/
package org.apache.olingo.odata2.core.commons;
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/a030e42b/odata-core/src/test/java/org/apache/olingo/odata2/core/commons/EncoderTest.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/commons/EncoderTest.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/commons/EncoderTest.java
index a313828..f22dea0 100644
--- a/odata-core/src/test/java/org/apache/olingo/odata2/core/commons/EncoderTest.java
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/commons/EncoderTest.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
******************************************************************************/
package org.apache.olingo.odata2.core.commons;
@@ -28,7 +28,7 @@ import org.junit.Test;
/**
* Tests for percent-encoding.
- *
+ *
*/
public class EncoderTest extends BaseTest {
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/a030e42b/odata-core/src/test/java/org/apache/olingo/odata2/core/debug/DebugInfoBodyTest.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/debug/DebugInfoBodyTest.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/debug/DebugInfoBodyTest.java
index 3a147cd..954a310 100644
--- a/odata-core/src/test/java/org/apache/olingo/odata2/core/debug/DebugInfoBodyTest.java
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/debug/DebugInfoBodyTest.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
******************************************************************************/
package org.apache.olingo.odata2.core.debug;
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/a030e42b/odata-core/src/test/java/org/apache/olingo/odata2/core/debug/ODataDebugResponseWrapperTest.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/debug/ODataDebugResponseWrapperTest.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/debug/ODataDebugResponseWrapperTest.java
index 31ad5e0..f13d8a4 100644
--- a/odata-core/src/test/java/org/apache/olingo/odata2/core/debug/ODataDebugResponseWrapperTest.java
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/debug/ODataDebugResponseWrapperTest.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
******************************************************************************/
package org.apache.olingo.odata2.core.debug;
@@ -58,7 +58,7 @@ import org.junit.Test;
/**
* Tests for the debug information output.
- *
+ *
*/
public class ODataDebugResponseWrapperTest extends BaseTest {
@@ -88,7 +88,8 @@ public class ODataDebugResponseWrapperTest extends BaseTest {
return response;
}
- private RuntimeMeasurement mockRuntimeMeasurement(final String method, final long startTime, final long stopTime, final long startMemory, final long stopMemory) {
+ private RuntimeMeasurement mockRuntimeMeasurement(final String method, final long startTime, final long stopTime,
+ final long startMemory, final long stopMemory) {
RuntimeMeasurement measurement = mock(RuntimeMeasurement.class);
when(measurement.getClassName()).thenReturn("class");
when(measurement.getMethodName()).thenReturn(method);
@@ -108,11 +109,14 @@ public class ODataDebugResponseWrapperTest extends BaseTest {
final ODataContext context = mockContext(ODataHttpMethod.PUT);
final ODataResponse wrappedResponse = mockResponse(HttpStatusCodes.NO_CONTENT, null, null);
- final ODataResponse response = new ODataDebugResponseWrapper(context, wrappedResponse, mock(UriInfo.class), null, ODataDebugResponseWrapper.ODATA_DEBUG_JSON)
- .wrapResponse();
+ final ODataResponse response =
+ new ODataDebugResponseWrapper(context, wrappedResponse, mock(UriInfo.class), null,
+ ODataDebugResponseWrapper.ODATA_DEBUG_JSON)
+ .wrapResponse();
String actualJson = StringHelper.inputStreamToString((InputStream) response.getEntity());
assertEquals(EXPECTED.replace(ODataHttpMethod.GET.name(), ODataHttpMethod.PUT.name())
- .replace(Integer.toString(HttpStatusCodes.OK.getStatusCode()), Integer.toString(HttpStatusCodes.NO_CONTENT.getStatusCode()))
+ .replace(Integer.toString(HttpStatusCodes.OK.getStatusCode()),
+ Integer.toString(HttpStatusCodes.NO_CONTENT.getStatusCode()))
.replace(HttpStatusCodes.OK.getInfo(), HttpStatusCodes.NO_CONTENT.getInfo()),
actualJson);
}
@@ -122,25 +126,34 @@ public class ODataDebugResponseWrapperTest extends BaseTest {
final ODataContext context = mockContext(ODataHttpMethod.GET);
ODataResponse wrappedResponse = mockResponse(HttpStatusCodes.OK, "\"test\"", HttpContentType.APPLICATION_JSON);
- ODataResponse response = new ODataDebugResponseWrapper(context, wrappedResponse, mock(UriInfo.class), null, ODataDebugResponseWrapper.ODATA_DEBUG_JSON)
- .wrapResponse();
+ ODataResponse response =
+ new ODataDebugResponseWrapper(context, wrappedResponse, mock(UriInfo.class), null,
+ ODataDebugResponseWrapper.ODATA_DEBUG_JSON)
+ .wrapResponse();
String entity = StringHelper.inputStreamToString((InputStream) response.getEntity());
assertEquals(EXPECTED.replace("{\"request", "{\"body\":\"test\",\"request")
- .replace("}}}", "},\"headers\":{\"" + HttpHeaders.CONTENT_TYPE + "\":\"" + HttpContentType.APPLICATION_JSON + "\"}}}"),
+ .replace("}}}",
+ "},\"headers\":{\"" + HttpHeaders.CONTENT_TYPE + "\":\"" + HttpContentType.APPLICATION_JSON + "\"}}}"),
entity);
wrappedResponse = mockResponse(HttpStatusCodes.OK, "test", HttpContentType.TEXT_PLAIN);
- response = new ODataDebugResponseWrapper(context, wrappedResponse, mock(UriInfo.class), null, ODataDebugResponseWrapper.ODATA_DEBUG_JSON)
- .wrapResponse();
+ response =
+ new ODataDebugResponseWrapper(context, wrappedResponse, mock(UriInfo.class), null,
+ ODataDebugResponseWrapper.ODATA_DEBUG_JSON)
+ .wrapResponse();
entity = StringHelper.inputStreamToString((InputStream) response.getEntity());
- assertEquals(EXPECTED.replace("{\"request", "{\"body\":\"test\",\"request")
- .replace("}}}", "},\"headers\":{\"" + HttpHeaders.CONTENT_TYPE + "\":\"" + HttpContentType.TEXT_PLAIN + "\"}}}"),
+ assertEquals(
+ EXPECTED.replace("{\"request", "{\"body\":\"test\",\"request")
+ .replace("}}}",
+ "},\"headers\":{\"" + HttpHeaders.CONTENT_TYPE + "\":\"" + HttpContentType.TEXT_PLAIN + "\"}}}"),
entity);
wrappedResponse = mockResponse(HttpStatusCodes.OK, null, "image/png");
when(wrappedResponse.getEntity()).thenReturn(new ByteArrayInputStream("test".getBytes()));
- response = new ODataDebugResponseWrapper(context, wrappedResponse, mock(UriInfo.class), null, ODataDebugResponseWrapper.ODATA_DEBUG_JSON)
- .wrapResponse();
+ response =
+ new ODataDebugResponseWrapper(context, wrappedResponse, mock(UriInfo.class), null,
+ ODataDebugResponseWrapper.ODATA_DEBUG_JSON)
+ .wrapResponse();
entity = StringHelper.inputStreamToString((InputStream) response.getEntity());
assertEquals(EXPECTED.replace("{\"request", "{\"body\":\"dGVzdA==\",\"request")
.replace("}}}", "},\"headers\":{\"" + HttpHeaders.CONTENT_TYPE + "\":\"image/png\"}}}"),
@@ -156,11 +169,15 @@ public class ODataDebugResponseWrapperTest extends BaseTest {
final ODataResponse wrappedResponse = mockResponse(HttpStatusCodes.OK, null, HttpContentType.APPLICATION_JSON);
- final ODataResponse response = new ODataDebugResponseWrapper(context, wrappedResponse, mock(UriInfo.class), null, ODataDebugResponseWrapper.ODATA_DEBUG_JSON)
- .wrapResponse();
+ final ODataResponse response =
+ new ODataDebugResponseWrapper(context, wrappedResponse, mock(UriInfo.class), null,
+ ODataDebugResponseWrapper.ODATA_DEBUG_JSON)
+ .wrapResponse();
String entity = StringHelper.inputStreamToString((InputStream) response.getEntity());
- assertEquals(EXPECTED.replace("},\"response", ",\"headers\":{\"" + HttpHeaders.CONTENT_TYPE + "\":\"" + HttpContentType.APPLICATION_JSON + "\"}},\"response")
- .replace("}}}", "},\"headers\":{\"" + HttpHeaders.CONTENT_TYPE + "\":\"" + HttpContentType.APPLICATION_JSON + "\"}}}"),
+ assertEquals(EXPECTED.replace("},\"response",
+ ",\"headers\":{\"" + HttpHeaders.CONTENT_TYPE + "\":\"" + HttpContentType.APPLICATION_JSON + "\"}},\"response")
+ .replace("}}}",
+ "},\"headers\":{\"" + HttpHeaders.CONTENT_TYPE + "\":\"" + HttpContentType.APPLICATION_JSON + "\"}}}"),
entity);
}
@@ -192,8 +209,10 @@ public class ODataDebugResponseWrapperTest extends BaseTest {
when(select2.getNavigationPropertySegments()).thenReturn(segments);
when(uriInfo.getSelect()).thenReturn(Arrays.asList(select1, select2));
- final ODataResponse response = new ODataDebugResponseWrapper(context, wrappedResponse, uriInfo, null, ODataDebugResponseWrapper.ODATA_DEBUG_JSON)
- .wrapResponse();
+ final ODataResponse response =
+ new ODataDebugResponseWrapper(context, wrappedResponse, uriInfo, null,
+ ODataDebugResponseWrapper.ODATA_DEBUG_JSON)
+ .wrapResponse();
String entity = StringHelper.inputStreamToString((InputStream) response.getEntity());
assertEquals(EXPECTED.replace("}}}",
"}},\"uri\":{\"filter\":{\"nodeType\":\"LITERAL\",\"type\":\"Edm.Boolean\",\"value\":\"true\"},"
@@ -222,8 +241,10 @@ public class ODataDebugResponseWrapperTest extends BaseTest {
when(filterTree.getUriLiteral()).thenReturn("wrong");
when(exception.getFilterTree()).thenReturn(filterTree);
- final ODataResponse response = new ODataDebugResponseWrapper(context, wrappedResponse, uriInfo, exception, ODataDebugResponseWrapper.ODATA_DEBUG_JSON)
- .wrapResponse();
+ final ODataResponse response =
+ new ODataDebugResponseWrapper(context, wrappedResponse, uriInfo, exception,
+ ODataDebugResponseWrapper.ODATA_DEBUG_JSON)
+ .wrapResponse();
String entity = StringHelper.inputStreamToString((InputStream) response.getEntity());
assertEquals(EXPECTED.replace("}}}",
"}},\"uri\":{\"error\":{\"filter\":\"wrong\"},\"filter\":null},"
@@ -249,8 +270,10 @@ public class ODataDebugResponseWrapperTest extends BaseTest {
final ODataResponse wrappedResponse = mockResponse(HttpStatusCodes.OK, null, null);
- ODataResponse response = new ODataDebugResponseWrapper(context, wrappedResponse, mock(UriInfo.class), null, ODataDebugResponseWrapper.ODATA_DEBUG_JSON)
- .wrapResponse();
+ ODataResponse response =
+ new ODataDebugResponseWrapper(context, wrappedResponse, mock(UriInfo.class), null,
+ ODataDebugResponseWrapper.ODATA_DEBUG_JSON)
+ .wrapResponse();
String entity = StringHelper.inputStreamToString((InputStream) response.getEntity());
assertEquals(EXPECTED.replace("}}}",
"}},\"runtime\":[{\"class\":\"class\",\"method\":\"method\",\"duration\":41,\"memory\":3,"
@@ -279,11 +302,14 @@ public class ODataDebugResponseWrapperTest extends BaseTest {
when(exception.getCause()).thenReturn(innerException);
when(exception.getStackTrace()).thenReturn(Arrays.copyOfRange(stackTrace, 1, 3));
- final ODataResponse response = new ODataDebugResponseWrapper(context, wrappedResponse, mock(UriInfo.class), exception, ODataDebugResponseWrapper.ODATA_DEBUG_JSON)
- .wrapResponse();
+ final ODataResponse response =
+ new ODataDebugResponseWrapper(context, wrappedResponse, mock(UriInfo.class), exception,
+ ODataDebugResponseWrapper.ODATA_DEBUG_JSON)
+ .wrapResponse();
String entity = StringHelper.inputStreamToString((InputStream) response.getEntity());
assertEquals(EXPECTED
- .replace(Integer.toString(HttpStatusCodes.OK.getStatusCode()), Integer.toString(HttpStatusCodes.BAD_REQUEST.getStatusCode()))
+ .replace(Integer.toString(HttpStatusCodes.OK.getStatusCode()),
+ Integer.toString(HttpStatusCodes.BAD_REQUEST.getStatusCode()))
.replace(HttpStatusCodes.OK.getInfo(), HttpStatusCodes.BAD_REQUEST.getInfo())
.replace("}}}", "}},"
+ "\"stacktrace\":{\"exceptions\":[{\"class\":\"" + exception.getClass().getName() + "\","
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/a030e42b/odata-core/src/test/java/org/apache/olingo/odata2/core/edm/EdmImplTest.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/edm/EdmImplTest.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/edm/EdmImplTest.java
index 86e6fbb..8d2cfa3 100644
--- a/odata-core/src/test/java/org/apache/olingo/odata2/core/edm/EdmImplTest.java
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/edm/EdmImplTest.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
******************************************************************************/
package org.apache.olingo.odata2.core.edm;