diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientITCase.java index 932f9b12c..7be6ab6cd 100644 --- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientITCase.java @@ -170,7 +170,7 @@ public class BatchClientITCase extends AbstractTestITCase { assertEquals(1, oDataResonse.getHeader("OData-Version").size()); assertEquals("4.0", oDataResonse.getHeader("OData-Version").toArray()[0]); assertEquals(1, oDataResonse.getHeader("Content-Length").size()); - assertEquals("582", oDataResonse.getHeader("Content-Length").toArray()[0]); + assertEquals("583", oDataResonse.getHeader("Content-Length").toArray()[0]); assertEquals("application/json;odata.metadata=minimal", oDataResonse.getContentType()); } @@ -202,7 +202,7 @@ public class BatchClientITCase extends AbstractTestITCase { assertEquals(1, oDataResonse.getHeader("OData-Version").size()); assertEquals("4.0", oDataResonse.getHeader("OData-Version").toArray()[0]); assertEquals(1, oDataResonse.getHeader("Content-Length").size()); - assertEquals("582", oDataResonse.getHeader("Content-Length").toArray()[0]); + assertEquals("583", oDataResonse.getHeader("Content-Length").toArray()[0]); assertEquals("application/json;odata.metadata=minimal", oDataResonse.getContentType()); } @@ -234,7 +234,7 @@ public class BatchClientITCase extends AbstractTestITCase { assertEquals(1, oDataResonse.getHeader("OData-Version").size()); assertEquals("4.0", oDataResonse.getHeader("OData-Version").toArray()[0]); assertEquals(1, oDataResonse.getHeader("Content-Length").size()); - assertEquals("582", oDataResonse.getHeader("Content-Length").toArray()[0]); + assertEquals("583", oDataResonse.getHeader("Content-Length").toArray()[0]); assertEquals("application/json;odata.metadata=minimal", oDataResonse.getContentType()); // Check second get request @@ -334,7 +334,7 @@ public class BatchClientITCase extends AbstractTestITCase { assertEquals(1, oDataResonse.getHeader("OData-Version").size()); assertEquals("4.0", oDataResonse.getHeader("OData-Version").toArray()[0]); assertEquals(1, oDataResonse.getHeader("Content-Length").size()); - assertEquals("582", oDataResonse.getHeader("Content-Length").toArray()[0]); + assertEquals("583", oDataResonse.getHeader("Content-Length").toArray()[0]); assertEquals("application/json;odata.metadata=minimal", oDataResonse.getContentType()); // Check second get request @@ -357,7 +357,7 @@ public class BatchClientITCase extends AbstractTestITCase { assertEquals(1, oDataResonse.getHeader("OData-Version").size()); assertEquals("4.0", oDataResonse.getHeader("OData-Version").toArray()[0]); assertEquals(1, oDataResonse.getHeader("Content-Length").size()); - assertEquals("490", oDataResonse.getHeader("Content-Length").toArray()[0]); + assertEquals("491", oDataResonse.getHeader("Content-Length").toArray()[0]); assertEquals("application/json;odata.metadata=minimal", oDataResonse.getContentType()); } diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/BasicBatchITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/BasicBatchITCase.java index 3964d3b60..c434703c0 100644 --- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/BasicBatchITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/BasicBatchITCase.java @@ -60,7 +60,7 @@ public class BasicBatchITCase extends AbstractBaseTestITCase { assertEquals("HTTP/1.1 200 OK", reader.readLine()); assertEquals("OData-Version: 4.0", reader.readLine()); assertEquals("Content-Type: application/json;odata.metadata=minimal", reader.readLine()); - assertEquals("Content-Length: 582", reader.readLine()); + assertEquals("Content-Length: 583", reader.readLine()); blankLine(reader); reader.close(); diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalServlet.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalServlet.java index 349af30f2..40433f33b 100644 --- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalServlet.java +++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalServlet.java @@ -56,7 +56,7 @@ public class TechnicalServlet extends HttpServlet { * therefore any change must be deployed, resulting in re-loading of this class, * giving this field a new and hopefully unique value.

*/ - private static final String metadataETag = "W/\"" + System.nanoTime() + "\""; + private static final String metadataETag = getETag(); @Override protected void service(final HttpServletRequest request, final HttpServletResponse response) @@ -89,4 +89,16 @@ public class TechnicalServlet extends HttpServlet { throw new ServletException(e); } } + + private static String getETag() { + String time = "" + System.nanoTime(); + if (time.length() > 14) { + time = time.substring(0, 14); + } else { + while (time.length() < 14) { + time = "0" + time; + } + } + return "W/\"" + time + "\""; + } }