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 2015/03/03 10:28:35 UTC
olingo-odata4 git commit: [OLINGO-575] Fix xhttp header test
Repository: olingo-odata4
Updated Branches:
refs/heads/master f38d54dcf -> 68ddcaf37
[OLINGO-575] Fix xhttp header test
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/68ddcaf3
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/68ddcaf3
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/68ddcaf3
Branch: refs/heads/master
Commit: 68ddcaf37fb9759fe4a29d5c20a0a730276e4983
Parents: f38d54d
Author: Christian Amend <ch...@apache.org>
Authored: Tue Mar 3 10:28:03 2015 +0100
Committer: Christian Amend <ch...@apache.org>
Committed: Tue Mar 3 10:28:03 2015 +0100
----------------------------------------------------------------------
.../client/BasicHttpExceptionHandling.java | 56 --------------------
.../BasicHttpExceptionHandlingITCase.java | 56 ++++++++++++++++++++
.../server/core/ODataHttpHandlerImpl.java | 9 ++--
3 files changed, 60 insertions(+), 61 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/68ddcaf3/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicHttpExceptionHandling.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicHttpExceptionHandling.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicHttpExceptionHandling.java
deleted file mode 100644
index 8248ee5..0000000
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicHttpExceptionHandling.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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
- *
- * 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.
- */
-package org.apache.olingo.fit.tecsvc.client;
-
-import static org.junit.Assert.assertEquals;
-
-import java.net.HttpURLConnection;
-import java.net.URL;
-
-import org.apache.olingo.client.api.ODataClient;
-import org.apache.olingo.commons.api.http.HttpHeader;
-import org.apache.olingo.fit.AbstractBaseTestITCase;
-import org.apache.olingo.fit.tecsvc.TecSvcConst;
-import org.junit.Test;
-
-public class BasicHttpExceptionHandling extends AbstractBaseTestITCase {
-
- private static final String SERVICE_URI = TecSvcConst.BASE_URI + "/";
-
- @Test
- public void ambigiousXHTTPMethod() throws Exception{
- URL url = new URL(SERVICE_URI + "?$format=json");
-
- HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- connection.setRequestMethod("POST");
- connection.setRequestProperty(HttpHeader.ACCEPT, "application/json");
- connection.setRequestProperty(HttpHeader.X_HTTP_METHOD, "value");
- connection.setRequestProperty(HttpHeader.X_HTTP_METHOD_OVERRIDE, "differentValue");
- connection.connect();
-
- int code = connection.getResponseCode();
- assertEquals(400, code);
- }
-
- @Override
- protected ODataClient getClient() {
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/68ddcaf3/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicHttpExceptionHandlingITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicHttpExceptionHandlingITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicHttpExceptionHandlingITCase.java
new file mode 100644
index 0000000..17eb334
--- /dev/null
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicHttpExceptionHandlingITCase.java
@@ -0,0 +1,56 @@
+/*
+ * 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
+ *
+ * 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.
+ */
+package org.apache.olingo.fit.tecsvc.client;
+
+import static org.junit.Assert.assertEquals;
+
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.commons.api.http.HttpHeader;
+import org.apache.olingo.fit.AbstractBaseTestITCase;
+import org.apache.olingo.fit.tecsvc.TecSvcConst;
+import org.junit.Test;
+
+public class BasicHttpExceptionHandlingITCase extends AbstractBaseTestITCase {
+
+ private static final String SERVICE_URI = TecSvcConst.BASE_URI + "/";
+
+ @Test
+ public void ambigiousXHTTPMethod() throws Exception{
+ URL url = new URL(SERVICE_URI + "?$format=json");
+
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ connection.setRequestMethod("POST");
+ connection.setRequestProperty(HttpHeader.ACCEPT, "application/json");
+ connection.setRequestProperty(HttpHeader.X_HTTP_METHOD, "value");
+ connection.setRequestProperty(HttpHeader.X_HTTP_METHOD_OVERRIDE, "differentValue");
+ connection.connect();
+
+ int code = connection.getResponseCode();
+ assertEquals(400, code);
+ }
+
+ @Override
+ protected ODataClient getClient() {
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/68ddcaf3/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHttpHandlerImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHttpHandlerImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHttpHandlerImpl.java
index 36cbd18..41750c7 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHttpHandlerImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHttpHandlerImpl.java
@@ -62,7 +62,8 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler {
ODataRequest odRequest = null;
ODataResponse odResponse;
try {
- odRequest = createODataRequest(request, split);
+ odRequest = new ODataRequest();
+ fillODataRequest(odRequest, request, split);
odResponse = handler.process(odRequest);
// ALL future methods after process must not throw exceptions!
} catch (Exception e) {
@@ -128,15 +129,13 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler {
}
}
- private ODataRequest createODataRequest(final HttpServletRequest httpRequest, final int split)
+ private ODataRequest fillODataRequest(ODataRequest odRequest, final HttpServletRequest httpRequest, final int split)
throws ODataTranslatedException {
try {
- ODataRequest odRequest = new ODataRequest();
-
odRequest.setBody(httpRequest.getInputStream());
extractHeaders(odRequest, httpRequest);
- extractMethod(odRequest, httpRequest);
extractUri(odRequest, httpRequest, split);
+ extractMethod(odRequest, httpRequest);
return odRequest;
} catch (final IOException e) {