Skip to content

Commit 61c4f7c

Browse files
committed
Revert "JCL-402: RDF4J body handlers http error handling (#1162)"
This reverts commit e03eb1e.
1 parent 1886a86 commit 61c4f7c

File tree

4 files changed

+36
-499
lines changed

4 files changed

+36
-499
lines changed

jena/src/main/java/com/inrupt/client/jena/JenaBodyHandlers.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public final class JenaBodyHandlers {
4949
private static void throwOnError(final Response.ResponseInfo responseInfo) {
5050
if (!Response.isSuccess(responseInfo.statusCode())) {
5151
throw new ClientHttpException(
52-
"An HTTP error was encountered mapping to a Jena entity.",
52+
"Could not map to a Jena entity.",
5353
responseInfo.uri(),
5454
responseInfo.statusCode(),
5555
responseInfo.headers(),

jena/src/test/java/com/inrupt/client/jena/JenaBodyHandlersTest.java

Lines changed: 5 additions & 207 deletions
Original file line numberDiff line numberDiff line change
@@ -79,31 +79,6 @@ void testOfJenaModelHandler() throws IOException,
7979
);
8080
}
8181

82-
/**
83-
* @deprecated covers the deprecated JenaBodyHandlers::ofModel function. To be removed when removing the function
84-
* from the API.
85-
*/
86-
@Test
87-
void testOfModelHandler() throws IOException,
88-
InterruptedException {
89-
final Request request = Request.newBuilder()
90-
.uri(URI.create(config.get("rdf_uri") + "/oneTriple"))
91-
.GET()
92-
.build();
93-
94-
final var response = client.send(request, JenaBodyHandlers.ofModel())
95-
.toCompletableFuture().join();
96-
97-
assertEquals(200, response.statusCode());
98-
final var responseBody = response.body();
99-
assertEquals(1, responseBody.size());
100-
assertTrue(responseBody.contains(
101-
null,
102-
null,
103-
ResourceFactory.createResource("http://example.test/o"))
104-
);
105-
}
106-
10782
@Test
10883
void testOfJenaModelHandlerAsync() throws IOException,
10984
InterruptedException, ExecutionException {
@@ -127,33 +102,6 @@ void testOfJenaModelHandlerAsync() throws IOException,
127102
);
128103
}
129104

130-
/**
131-
* @deprecated covers the deprecated JenaBodyHandlers::ofModel function. To be removed when removing the function
132-
* from the API.
133-
*/
134-
@Test
135-
void testOfModelHandlerAsync() throws IOException,
136-
InterruptedException, ExecutionException {
137-
final Request request = Request.newBuilder()
138-
.uri(URI.create(config.get("rdf_uri") + "/oneTriple"))
139-
.header("Accept", "text/turtle")
140-
.GET()
141-
.build();
142-
143-
final var asyncResponse = client.send(request, JenaBodyHandlers.ofModel());
144-
145-
final int statusCode = asyncResponse.thenApply(Response::statusCode).toCompletableFuture().join();
146-
assertEquals(200, statusCode);
147-
148-
final var responseBody = asyncResponse.thenApply(Response::body).toCompletableFuture().join();
149-
assertEquals(1, responseBody.size());
150-
assertTrue(responseBody.contains(
151-
null,
152-
null,
153-
ResourceFactory.createResource("http://example.test/o"))
154-
);
155-
}
156-
157105
@Test
158106
void testOfJenaModelHandlerWithURL() throws IOException, InterruptedException {
159107
final Request request = Request.newBuilder()
@@ -173,29 +121,6 @@ void testOfJenaModelHandlerWithURL() throws IOException, InterruptedException {
173121
);
174122
}
175123

176-
/**
177-
* @deprecated covers the deprecated JenaBodyHandlers::ofModel function. To be removed when removing the function
178-
* from the API.
179-
*/
180-
@Test
181-
void testOfModelHandlerWithURL() throws IOException, InterruptedException {
182-
final Request request = Request.newBuilder()
183-
.uri(URI.create(config.get("rdf_uri") + "/example"))
184-
.GET()
185-
.build();
186-
187-
final var response = client.send(request, JenaBodyHandlers.ofModel())
188-
.toCompletableFuture().join();
189-
190-
assertEquals(200, response.statusCode());
191-
final var responseBody = response.body();
192-
assertEquals(7, responseBody.size());
193-
assertTrue(responseBody.contains(
194-
null,
195-
ResourceFactory.createProperty("http://www.w3.org/ns/pim/space#preferencesFile"))
196-
);
197-
}
198-
199124
@Test
200125
void testOfJenaModelHandlerError() throws IOException,
201126
InterruptedException {
@@ -227,42 +152,16 @@ void testOfJenaDatasetHandler() throws IOException,
227152
.build();
228153

229154
final var response = client.send(request, JenaBodyHandlers.ofJenaDataset())
230-
.toCompletableFuture().join();
231-
232-
assertEquals(200, response.statusCode());
233-
final var responseBody = response.body();
234-
assertEquals(1, responseBody.asDatasetGraph().stream().count());
235-
assertTrue(responseBody.asDatasetGraph().contains(
236-
null,
237-
NodeFactory.createURI("http://example.test/s"),
238-
null,
239-
null)
240-
);
241-
}
242-
243-
/**
244-
* @deprecated covers the deprecated JenaBodyHandlers::ofDataset function. To be removed when removing the function
245-
* from the API.
246-
*/
247-
@Test
248-
void testOfDatasetHandler() throws IOException,
249-
InterruptedException {
250-
final Request request = Request.newBuilder()
251-
.uri(URI.create(config.get("rdf_uri") + "/oneTriple"))
252-
.GET()
253-
.build();
254-
255-
final var response = client.send(request, JenaBodyHandlers.ofDataset())
256-
.toCompletableFuture().join();
155+
.toCompletableFuture().join();
257156

258157
assertEquals(200, response.statusCode());
259158
final var responseBody = response.body();
260159
assertEquals(1, responseBody.asDatasetGraph().stream().count());
261160
assertTrue(responseBody.asDatasetGraph().contains(
262-
null,
263-
NodeFactory.createURI("http://example.test/s"),
264-
null,
265-
null)
161+
null,
162+
NodeFactory.createURI("http://example.test/s"),
163+
null,
164+
null)
266165
);
267166
}
268167

@@ -287,31 +186,6 @@ void testOfJenaDatasetHandlerWithURL() throws IOException, InterruptedException
287186
);
288187
}
289188

290-
/**
291-
* @deprecated covers the deprecated JenaBodyHandlers::ofDataset function. To be removed when removing the function
292-
* from the API.
293-
*/
294-
@Test
295-
void testOfDatasetHandlerWithURL() throws IOException, InterruptedException {
296-
final Request request = Request.newBuilder()
297-
.uri(URI.create(config.get("rdf_uri") + "/example"))
298-
.GET()
299-
.build();
300-
301-
final var response = client.send(request, JenaBodyHandlers.ofDataset())
302-
.toCompletableFuture().join();
303-
304-
assertEquals(200, response.statusCode());
305-
final var responseBody = response.body();
306-
assertEquals(7, responseBody.asDatasetGraph().stream().count());
307-
assertTrue(responseBody.asDatasetGraph().contains(
308-
null,
309-
null,
310-
NodeFactory.createURI("http://www.w3.org/ns/pim/space#preferencesFile"),
311-
null)
312-
);
313-
}
314-
315189
@Test
316190
void testOfJenaDatasetHandlerError() throws IOException,
317191
InterruptedException {
@@ -357,33 +231,6 @@ void testOfJenaGraphHandlerAsync() throws IOException,
357231
);
358232
}
359233

360-
/**
361-
* @deprecated covers the deprecated JenaBodyHandlers::ofGraph function. To be removed when removing the function
362-
* from the API.
363-
*/
364-
@Test
365-
void testOfGraphHandlerAsync() throws IOException,
366-
InterruptedException, ExecutionException {
367-
final Request request = Request.newBuilder()
368-
.uri(URI.create(config.get("rdf_uri") + "/oneTriple"))
369-
.header("Accept", "text/turtle")
370-
.GET()
371-
.build();
372-
373-
final var asyncResponse = client.send(request, JenaBodyHandlers.ofGraph());
374-
375-
final int statusCode = asyncResponse.thenApply(Response::statusCode).toCompletableFuture().join();
376-
assertEquals(200, statusCode);
377-
378-
final var responseBody = asyncResponse.thenApply(Response::body).toCompletableFuture().join();
379-
assertEquals(1, responseBody.size());
380-
assertTrue(responseBody.contains(
381-
NodeFactory.createURI("http://example.test/s"),
382-
null,
383-
null)
384-
);
385-
}
386-
387234
@Test
388235
void testOfJenaGraphHandler() throws IOException,
389236
InterruptedException {
@@ -405,31 +252,6 @@ void testOfJenaGraphHandler() throws IOException,
405252
);
406253
}
407254

408-
/**
409-
* @deprecated covers the deprecated JenaBodyHandlers::ofGraph function. To be removed when removing the function
410-
* from the API.
411-
*/
412-
@Test
413-
void testOfGraphHandler() throws IOException,
414-
InterruptedException {
415-
final Request request = Request.newBuilder()
416-
.uri(URI.create(config.get("rdf_uri") + "/oneTriple"))
417-
.GET()
418-
.build();
419-
420-
final var response = client.send(request, JenaBodyHandlers.ofGraph())
421-
.toCompletableFuture().join();
422-
423-
assertEquals(200, response.statusCode());
424-
final var responseBody = response.body();
425-
assertEquals(1, responseBody.size());
426-
assertTrue(responseBody.contains(
427-
NodeFactory.createURI("http://example.test/s"),
428-
null,
429-
null)
430-
);
431-
}
432-
433255
@Test
434256
void testOfJenaGraphHandlerWithURL() throws IOException, InterruptedException {
435257
final Request request = Request.newBuilder()
@@ -450,30 +272,6 @@ void testOfJenaGraphHandlerWithURL() throws IOException, InterruptedException {
450272
);
451273
}
452274

453-
/**
454-
* @deprecated covers the deprecated JenaBodyHandlers::ofGraph function. To be removed when removing the function
455-
* from the API.
456-
*/
457-
@Test
458-
void testOfGraphHandlerWithURL() throws IOException, InterruptedException {
459-
final Request request = Request.newBuilder()
460-
.uri(URI.create(config.get("rdf_uri") + "/example"))
461-
.GET()
462-
.build();
463-
464-
final var response = client.send(request, JenaBodyHandlers.ofGraph())
465-
.toCompletableFuture().join();
466-
467-
assertEquals(200, response.statusCode());
468-
final var responseBody = response.body();
469-
assertEquals(7, responseBody.size());
470-
assertTrue(responseBody.contains(
471-
null,
472-
NodeFactory.createURI("http://www.w3.org/ns/pim/space#preferencesFile"),
473-
null)
474-
);
475-
}
476-
477275
@Test
478276
void testOfJenaGraphHandlerError() throws IOException,
479277
InterruptedException {

0 commit comments

Comments
 (0)