Skip to content

Commit

Permalink
Catch JSON-LD parsing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
acoburn committed Sep 20, 2018
1 parent 42f6668 commit acead86
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ public Stream<? extends Triple> read(final InputStream input, final RDFSyntax sy
});
}
return rdf.asGraph(graph).stream();
} catch (final RiotException | AtlasException ex) {
} catch (final RiotException | AtlasException | IllegalArgumentException ex) {
throw new RuntimeTrellisException(ex);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1235,6 +1235,18 @@ public void testPostDirectContainerResource() {
verify(myEventService, times(3)).emit(any());
}

@Test
public void testPostBadJsonLd() {
when(mockResource.getInteractionModel()).thenReturn(LDP.Container);
when(mockResourceService.get(eq(rdf.createIRI(TRELLIS_DATA_PREFIX + RESOURCE_PATH + "/" + RANDOM_VALUE))))
.thenAnswer(inv -> completedFuture(MISSING_RESOURCE));

final Response res = target(RESOURCE_PATH).request()
.post(entity("{\"@id\": \"\", \"@type\": \"some type\"}", APPLICATION_LD_JSON_TYPE));

assertEquals(SC_BAD_REQUEST, res.getStatus(), "Unexpected response code!");
}

@Test
public void testPostConstraint() {
when(mockResource.getInteractionModel()).thenReturn(LDP.Container);
Expand Down

0 comments on commit acead86

Please sign in to comment.