You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2014/05/18 07:06:49 UTC
[21/38] git commit: [OLINGO-237] Added library info to debug output
[OLINGO-237] Added library info to debug output
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/df769309
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/df769309
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/df769309
Branch: refs/heads/Olingo-129_PocJpaDataStore
Commit: df769309acae25ce1f525152c3ffdbda8094a516
Parents: 1035f92
Author: Michael Bolz <mi...@apache.org>
Authored: Fri Apr 4 13:43:42 2014 +0200
Committer: Michael Bolz <mi...@apache.org>
Committed: Fri Apr 4 13:43:42 2014 +0200
----------------------------------------------------------------------
.../odata2/core/debug/DebugInfoServer.java | 6 +++-
.../core/debug/ODataDebugResponseWrapper.java | 31 ++++++++------------
.../debug/ODataDebugResponseWrapperTest.java | 30 ++++++++++---------
3 files changed, 33 insertions(+), 34 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/df769309/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/debug/DebugInfoServer.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/debug/DebugInfoServer.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/debug/DebugInfoServer.java
index ad1fd4a..8af0876 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/debug/DebugInfoServer.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/debug/DebugInfoServer.java
@@ -64,7 +64,11 @@ public class DebugInfoServer implements DebugInfo {
@Override
public void appendHtml(final Writer writer) throws IOException {
- writer.append("<h2>Server Environment</h2>\n");
+ final Package pack = ODataDebugResponseWrapper.class.getPackage();
+ writer.append("<h2>Library Version</h2>\n")
+ .append("<p>").append(pack.getImplementationTitle())
+ .append(" Version ").append(pack.getImplementationVersion()).append("</p>\n")
+ .append("<h2>Server Environment</h2>\n");
ODataDebugResponseWrapper.appendHtmlTable(writer, environment);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/df769309/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/debug/ODataDebugResponseWrapper.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/debug/ODataDebugResponseWrapper.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/debug/ODataDebugResponseWrapper.java
index 78fe62f..52fbac4 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/debug/ODataDebugResponseWrapper.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/debug/ODataDebugResponseWrapper.java
@@ -140,30 +140,23 @@ public class ODataDebugResponseWrapper {
CircleStreamBuffer csb = new CircleStreamBuffer();
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(csb.getOutputStream(), "UTF-8"));
JsonStreamWriter jsonStreamWriter = new JsonStreamWriter(writer);
- jsonStreamWriter.beginObject();
- jsonStreamWriter.name(parts.get(0).getName().toLowerCase(Locale.ROOT));
+ jsonStreamWriter.beginObject()
+ .name(parts.get(0).getName().toLowerCase(Locale.ROOT));
parts.get(0).appendJson(jsonStreamWriter);
- jsonStreamWriter.separator();
- jsonStreamWriter.name(parts.get(1).getName().toLowerCase(Locale.ROOT));
+ jsonStreamWriter.separator()
+ .name(parts.get(1).getName().toLowerCase(Locale.ROOT));
parts.get(1).appendJson(jsonStreamWriter);
- if (parts.size() > 2) {
- jsonStreamWriter.separator();
- jsonStreamWriter.name("server")
- .beginObject();
- }
- boolean first = true;
+ jsonStreamWriter.separator()
+ .name("server")
+ .beginObject()
+ .namedStringValueRaw("version", ODataDebugResponseWrapper.class.getPackage().getImplementationVersion());
for (final DebugInfo part : parts.subList(2, parts.size())) {
- if (!first) {
- jsonStreamWriter.separator();
- }
- first = false;
- jsonStreamWriter.name(part.getName().toLowerCase(Locale.ROOT));
+ jsonStreamWriter.separator()
+ .name(part.getName().toLowerCase(Locale.ROOT));
part.appendJson(jsonStreamWriter);
}
- if (parts.size() > 2) {
- jsonStreamWriter.endObject();
- }
- jsonStreamWriter.endObject();
+ jsonStreamWriter.endObject()
+ .endObject();
writer.flush();
csb.closeWrite();
return csb.getInputStream();
http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/df769309/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/debug/ODataDebugResponseWrapperTest.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/debug/ODataDebugResponseWrapperTest.java b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/debug/ODataDebugResponseWrapperTest.java
index 1442b5f..659a54c 100644
--- a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/debug/ODataDebugResponseWrapperTest.java
+++ b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/debug/ODataDebugResponseWrapperTest.java
@@ -66,7 +66,8 @@ public class ODataDebugResponseWrapperTest extends BaseTest {
private static final String EXPECTED = "{"
+ "\"request\":{\"method\":\"GET\",\"uri\":\"http://test/entity\",\"protocol\":null},"
- + "\"response\":{\"status\":{\"code\":200,\"info\":\"OK\"}}}";
+ + "\"response\":{\"status\":{\"code\":200,\"info\":\"OK\"}},"
+ + "\"server\":{\"version\":null}}";
private ODataContext mockContext(final ODataHttpMethod method) throws ODataException {
ODataContext context = mock(ODataContext.class);
@@ -128,18 +129,18 @@ public class ODataDebugResponseWrapperTest extends BaseTest {
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("}}}",
+ assertEquals(EXPECTED.replace("}},\"server",
"},\"headers\":{\"" + HttpHeaders.CONTENT_TYPE + "\":\"" + HttpContentType.APPLICATION_JSON + "\"},"
- + "\"body\":\"test\"}}"),
+ + "\"body\":\"test\"},\"server"),
entity);
wrappedResponse = mockResponse(HttpStatusCodes.OK, "test", HttpContentType.TEXT_PLAIN);
response = new ODataDebugResponseWrapper(context, wrappedResponse, mock(UriInfo.class), null,
ODataDebugResponseWrapper.ODATA_DEBUG_JSON).wrapResponse();
entity = StringHelper.inputStreamToString((InputStream) response.getEntity());
- assertEquals(EXPECTED.replace("}}}",
+ assertEquals(EXPECTED.replace("}},\"server",
"},\"headers\":{\"" + HttpHeaders.CONTENT_TYPE + "\":\"" + HttpContentType.TEXT_PLAIN + "\"},"
- + "\"body\":\"test\"}}"),
+ + "\"body\":\"test\"},\"server"),
entity);
wrappedResponse = mockResponse(HttpStatusCodes.OK, null, "image/png");
@@ -147,9 +148,9 @@ public class ODataDebugResponseWrapperTest extends BaseTest {
response = new ODataDebugResponseWrapper(context, wrappedResponse, mock(UriInfo.class), null,
ODataDebugResponseWrapper.ODATA_DEBUG_JSON).wrapResponse();
entity = StringHelper.inputStreamToString((InputStream) response.getEntity());
- assertEquals(EXPECTED.replace("}}}",
+ assertEquals(EXPECTED.replace("}},\"server",
"},\"headers\":{\"" + HttpHeaders.CONTENT_TYPE + "\":\"image/png\"},"
- + "\"body\":\"dGVzdA==\"}}"),
+ + "\"body\":\"dGVzdA==\"},\"server"),
entity);
when(wrappedResponse.getEntity()).thenReturn(new ByteArrayInputStream("test".getBytes()));
@@ -173,8 +174,9 @@ public class ODataDebugResponseWrapperTest extends BaseTest {
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 + "\"}}}"),
+ .replace("}},\"server",
+ "},\"headers\":{\"" + HttpHeaders.CONTENT_TYPE + "\":\"" + HttpContentType.APPLICATION_JSON
+ + "\"}},\"server"),
entity);
response = new ODataDebugResponseWrapper(context, wrappedResponse, mock(UriInfo.class), null,
@@ -194,7 +196,7 @@ public class ODataDebugResponseWrapperTest extends BaseTest {
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("}}}", "}},\"server\":{\"environment\":{\"serverPort\":\"12345\"}}}"),
+ assertEquals(EXPECTED.replace("null}}", "null,\"environment\":{\"serverPort\":\"12345\"}}}"),
entity);
response = new ODataDebugResponseWrapper(context, wrappedResponse, mock(UriInfo.class), null,
@@ -234,7 +236,7 @@ public class ODataDebugResponseWrapperTest extends BaseTest {
ODataResponse response = new ODataDebugResponseWrapper(context, wrappedResponse, uriInfo, null,
ODataDebugResponseWrapper.ODATA_DEBUG_JSON).wrapResponse();
String entity = StringHelper.inputStreamToString((InputStream) response.getEntity());
- assertEquals(EXPECTED.replace("}}}", "}},\"server\":{"
+ assertEquals(EXPECTED.replace("null}}", "null,"
+ "\"uri\":{\"filter\":{\"nodeType\":\"LITERAL\",\"type\":\"Edm.Boolean\",\"value\":\"true\"},"
+ "\"orderby\":{\"nodeType\":\"order collection\","
+ "\"orders\":[{\"nodeType\":\"ORDER\",\"sortorder\":\"asc\","
@@ -266,7 +268,7 @@ public class ODataDebugResponseWrapperTest extends BaseTest {
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("}}}", "}},\"server\":{"
+ assertEquals(EXPECTED.replace("null}}", "null,"
+ "\"uri\":{\"error\":{\"expression\":\"wrong\"}},"
+ "\"stacktrace\":{\"exceptions\":[{\"class\":\"" + exception.getClass().getName() + "\","
+ "\"message\":\"Error while parsing a ODATA expression.\","
@@ -300,7 +302,7 @@ public class ODataDebugResponseWrapperTest extends BaseTest {
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("}}}", "}},\"server\":{"
+ assertEquals(EXPECTED.replace("null}}", "null,"
+ "\"runtime\":[{\"class\":\"class\",\"method\":\"method\",\"duration\":{\"value\":41,\"unit\":\"µs\"},"
+ "\"children\":[{\"class\":\"class\",\"method\":\"inner\",\"duration\":{\"value\":8,\"unit\":\"µs\"}},"
+ "{\"class\":\"class\",\"method\":\"inner\",\"duration\":{\"value\":3,\"unit\":\"µs\"},\"children\":["
@@ -339,7 +341,7 @@ public class ODataDebugResponseWrapperTest extends BaseTest {
.replace(Integer.toString(HttpStatusCodes.OK.getStatusCode()),
Integer.toString(HttpStatusCodes.BAD_REQUEST.getStatusCode()))
.replace(HttpStatusCodes.OK.getInfo(), HttpStatusCodes.BAD_REQUEST.getInfo())
- .replace("}}}", "}},\"server\":{"
+ .replace("null}}", "null,"
+ "\"stacktrace\":{\"exceptions\":[{\"class\":\"" + exception.getClass().getName() + "\","
+ "\"message\":\"Common exception\","
+ "\"invocation\":{\"class\":\"class\",\"method\":\"method\",\"line\":42}},"