Skip to content
This repository was archived by the owner on May 28, 2018. It is now read-only.

Commit 0e1f350

Browse files
author
Marek Potociar
committed
Added some additional test diagnostics.
- Trying to catch the reason of intermittent test failures in entity filtering E2E tests. Change-Id: I70711e225e7139e6b982d9e4d844c2acce789999 Signed-off-by: Marek Potociar <[email protected]>
1 parent 251fa90 commit 0e1f350

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/FilteringMessageBodyProvider.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,15 @@ public long getSize(final Object o, final Class<?> type, final Type genericType,
102102
public Object readFrom(final Class<Object> type, final Type genericType, final Annotation[] annotations,
103103
final MediaType mediaType, final MultivaluedMap<String, String> httpHeaders,
104104
final InputStream entityStream) throws IOException, WebApplicationException {
105-
final ObjectGraph objectGraph = provider.get()
106-
.getFilteringObject(FilteringHelper.getEntityClass(genericType), false, annotations);
105+
try {
106+
final ObjectGraph objectGraph = provider.get()
107+
.getFilteringObject(FilteringHelper.getEntityClass(genericType), false, annotations);
107108

108-
return objectGraphToString(objectGraph);
109+
return objectGraphToString(objectGraph);
110+
} catch (final Throwable t) {
111+
LOGGER.log(Level.WARNING, "Error during reading an object graph.", t);
112+
return "ERROR: " + t.getMessage();
113+
}
109114
}
110115

111116
@Override
@@ -117,12 +122,12 @@ public void writeTo(final Object o, final Class<?> type, final Type genericType,
117122

118123
try {
119124
entityStream.write(objectGraphToString(objectGraph).getBytes());
120-
} catch (final Throwable e) {
121-
LOGGER.log(Level.WARNING, "Error during writing an object graph to string.", e);
125+
} catch (final Throwable t) {
126+
LOGGER.log(Level.WARNING, "Error during writing an object graph.", t);
122127
}
123128
}
124129

125-
private String objectGraphToString(final ObjectGraph objectGraph) {
130+
private static String objectGraphToString(final ObjectGraph objectGraph) {
126131
final StringBuilder sb = new StringBuilder();
127132
for (final String field : objectGraphToFields("", objectGraph)) {
128133
if (!field.contains("Transient")) {
@@ -135,7 +140,7 @@ private String objectGraphToString(final ObjectGraph objectGraph) {
135140
return sb.toString();
136141
}
137142

138-
private List<String> objectGraphToFields(final String prefix, final ObjectGraph objectGraph) {
143+
private static List<String> objectGraphToFields(final String prefix, final ObjectGraph objectGraph) {
139144
final List<String> fields = Lists.newArrayList();
140145

141146
// Fields.

0 commit comments

Comments
 (0)