2222
2323import static org .junit .jupiter .api .Assertions .*;
2424
25- import com .inrupt .client .ClientHttpException ;
2625import com .inrupt .client .Request ;
2726import com .inrupt .client .Response ;
2827import com .inrupt .client .spi .HttpService ;
3332import java .net .URI ;
3433import java .util .HashMap ;
3534import java .util .Map ;
36- import java .util .concurrent .CompletionException ;
3735import java .util .concurrent .ExecutionException ;
3836
3937import org .apache .jena .graph .NodeFactory ;
@@ -59,14 +57,14 @@ static void teardown() {
5957 }
6058
6159 @ Test
62- void testOfJenaModelHandler () throws IOException ,
60+ void testOfModelHandler () throws IOException ,
6361 InterruptedException {
6462 final Request request = Request .newBuilder ()
6563 .uri (URI .create (config .get ("rdf_uri" ) + "/oneTriple" ))
6664 .GET ()
6765 .build ();
6866
69- final var response = client .send (request , JenaBodyHandlers .ofJenaModel ())
67+ final var response = client .send (request , JenaBodyHandlers .ofModel ())
7068 .toCompletableFuture ().join ();
7169
7270 assertEquals (200 , response .statusCode ());
@@ -80,15 +78,15 @@ void testOfJenaModelHandler() throws IOException,
8078 }
8179
8280 @ Test
83- void testOfJenaModelHandlerAsync () throws IOException ,
81+ void testOfModelHandlerAsync () throws IOException ,
8482 InterruptedException , ExecutionException {
8583 final Request request = Request .newBuilder ()
8684 .uri (URI .create (config .get ("rdf_uri" ) + "/oneTriple" ))
8785 .header ("Accept" , "text/turtle" )
8886 .GET ()
8987 .build ();
9088
91- final var asyncResponse = client .send (request , JenaBodyHandlers .ofJenaModel ());
89+ final var asyncResponse = client .send (request , JenaBodyHandlers .ofModel ());
9290
9391 final int statusCode = asyncResponse .thenApply (Response ::statusCode ).toCompletableFuture ().join ();
9492 assertEquals (200 , statusCode );
@@ -103,13 +101,13 @@ void testOfJenaModelHandlerAsync() throws IOException,
103101 }
104102
105103 @ Test
106- void testOfJenaModelHandlerWithURL () throws IOException , InterruptedException {
104+ void testOfModelHandlerWithURL () throws IOException , InterruptedException {
107105 final Request request = Request .newBuilder ()
108106 .uri (URI .create (config .get ("rdf_uri" ) + "/example" ))
109107 .GET ()
110108 .build ();
111109
112- final var response = client .send (request , JenaBodyHandlers .ofJenaModel ())
110+ final var response = client .send (request , JenaBodyHandlers .ofModel ())
113111 .toCompletableFuture ().join ();
114112
115113 assertEquals (200 , response .statusCode ());
@@ -122,36 +120,14 @@ void testOfJenaModelHandlerWithURL() throws IOException, InterruptedException {
122120 }
123121
124122 @ Test
125- void testOfJenaModelHandlerError () throws IOException ,
126- InterruptedException {
127- final Request request = Request .newBuilder ()
128- .uri (URI .create (config .get ("rdf_uri" ) + "/error" ))
129- .GET ()
130- .build ();
131-
132- final CompletionException completionException = assertThrows (
133- CompletionException .class ,
134- () -> client .send (request , JenaBodyHandlers .ofJenaModel ()).toCompletableFuture ().join ()
135- );
136-
137- final ClientHttpException httpException = (ClientHttpException ) completionException .getCause ();
138-
139- assertEquals (429 , httpException .getProblemDetails ().getStatus ());
140- assertEquals ("Too Many Requests" , httpException .getProblemDetails ().getTitle ());
141- assertEquals ("Some details" , httpException .getProblemDetails ().getDetails ());
142- assertEquals ("https://example.org/type" , httpException .getProblemDetails ().getType ().toString ());
143- assertEquals ("https://example.org/instance" , httpException .getProblemDetails ().getInstance ().toString ());
144- }
145-
146- @ Test
147- void testOfJenaDatasetHandler () throws IOException ,
123+ void testOfDatasetHandler () throws IOException ,
148124 InterruptedException {
149125 final Request request = Request .newBuilder ()
150126 .uri (URI .create (config .get ("rdf_uri" ) + "/oneTriple" ))
151127 .GET ()
152128 .build ();
153129
154- final var response = client .send (request , JenaBodyHandlers .ofJenaDataset ())
130+ final var response = client .send (request , JenaBodyHandlers .ofDataset ())
155131 .toCompletableFuture ().join ();
156132
157133 assertEquals (200 , response .statusCode ());
@@ -166,13 +142,13 @@ void testOfJenaDatasetHandler() throws IOException,
166142 }
167143
168144 @ Test
169- void testOfJenaDatasetHandlerWithURL () throws IOException , InterruptedException {
145+ void testOfDatasetHandlerWithURL () throws IOException , InterruptedException {
170146 final Request request = Request .newBuilder ()
171147 .uri (URI .create (config .get ("rdf_uri" ) + "/example" ))
172148 .GET ()
173149 .build ();
174150
175- final var response = client .send (request , JenaBodyHandlers .ofJenaDataset ())
151+ final var response = client .send (request , JenaBodyHandlers .ofDataset ())
176152 .toCompletableFuture ().join ();
177153
178154 assertEquals (200 , response .statusCode ());
@@ -187,37 +163,15 @@ void testOfJenaDatasetHandlerWithURL() throws IOException, InterruptedException
187163 }
188164
189165 @ Test
190- void testOfJenaDatasetHandlerError () throws IOException ,
191- InterruptedException {
192- final Request request = Request .newBuilder ()
193- .uri (URI .create (config .get ("rdf_uri" ) + "/error" ))
194- .GET ()
195- .build ();
196-
197- final CompletionException completionException = assertThrows (
198- CompletionException .class ,
199- () -> client .send (request , JenaBodyHandlers .ofJenaDataset ()).toCompletableFuture ().join ()
200- );
201-
202- final ClientHttpException httpException = (ClientHttpException ) completionException .getCause ();
203-
204- assertEquals (429 , httpException .getProblemDetails ().getStatus ());
205- assertEquals ("Too Many Requests" , httpException .getProblemDetails ().getTitle ());
206- assertEquals ("Some details" , httpException .getProblemDetails ().getDetails ());
207- assertEquals ("https://example.org/type" , httpException .getProblemDetails ().getType ().toString ());
208- assertEquals ("https://example.org/instance" , httpException .getProblemDetails ().getInstance ().toString ());
209- }
210-
211- @ Test
212- void testOfJenaGraphHandlerAsync () throws IOException ,
166+ void testOfGraphHandlerAsync () throws IOException ,
213167 InterruptedException , ExecutionException {
214168 final Request request = Request .newBuilder ()
215169 .uri (URI .create (config .get ("rdf_uri" ) + "/oneTriple" ))
216170 .header ("Accept" , "text/turtle" )
217171 .GET ()
218172 .build ();
219173
220- final var asyncResponse = client .send (request , JenaBodyHandlers .ofJenaGraph ());
174+ final var asyncResponse = client .send (request , JenaBodyHandlers .ofGraph ());
221175
222176 final int statusCode = asyncResponse .thenApply (Response ::statusCode ).toCompletableFuture ().join ();
223177 assertEquals (200 , statusCode );
@@ -232,14 +186,14 @@ void testOfJenaGraphHandlerAsync() throws IOException,
232186 }
233187
234188 @ Test
235- void testOfJenaGraphHandler () throws IOException ,
189+ void testOfGraphHandler () throws IOException ,
236190 InterruptedException {
237191 final Request request = Request .newBuilder ()
238192 .uri (URI .create (config .get ("rdf_uri" ) + "/oneTriple" ))
239193 .GET ()
240194 .build ();
241195
242- final var response = client .send (request , JenaBodyHandlers .ofJenaGraph ())
196+ final var response = client .send (request , JenaBodyHandlers .ofGraph ())
243197 .toCompletableFuture ().join ();
244198
245199 assertEquals (200 , response .statusCode ());
@@ -253,13 +207,13 @@ void testOfJenaGraphHandler() throws IOException,
253207 }
254208
255209 @ Test
256- void testOfJenaGraphHandlerWithURL () throws IOException , InterruptedException {
210+ void testOfGraphHandlerWithURL () throws IOException , InterruptedException {
257211 final Request request = Request .newBuilder ()
258212 .uri (URI .create (config .get ("rdf_uri" ) + "/example" ))
259213 .GET ()
260214 .build ();
261215
262- final var response = client .send (request , JenaBodyHandlers .ofJenaGraph ())
216+ final var response = client .send (request , JenaBodyHandlers .ofGraph ())
263217 .toCompletableFuture ().join ();
264218
265219 assertEquals (200 , response .statusCode ());
@@ -271,26 +225,4 @@ void testOfJenaGraphHandlerWithURL() throws IOException, InterruptedException {
271225 null )
272226 );
273227 }
274-
275- @ Test
276- void testOfJenaGraphHandlerError () throws IOException ,
277- InterruptedException {
278- final Request request = Request .newBuilder ()
279- .uri (URI .create (config .get ("rdf_uri" ) + "/error" ))
280- .GET ()
281- .build ();
282-
283- final CompletionException completionException = assertThrows (
284- CompletionException .class ,
285- () -> client .send (request , JenaBodyHandlers .ofJenaGraph ()).toCompletableFuture ().join ()
286- );
287-
288- final ClientHttpException httpException = (ClientHttpException ) completionException .getCause ();
289-
290- assertEquals (429 , httpException .getProblemDetails ().getStatus ());
291- assertEquals ("Too Many Requests" , httpException .getProblemDetails ().getTitle ());
292- assertEquals ("Some details" , httpException .getProblemDetails ().getDetails ());
293- assertEquals ("https://example.org/type" , httpException .getProblemDetails ().getType ().toString ());
294- assertEquals ("https://example.org/instance" , httpException .getProblemDetails ().getInstance ().toString ());
295- }
296228}
0 commit comments