### Question:
ImageWebservice extends LdpWebService { @GET @Produces("image/*") public Response GET(@Context final UriInfo uriInfo, @HeaderParam(HttpHeaders.ACCEPT) @DefaultValue(MediaType.WILDCARD) final String type, @HeaderParam(LdpWebService.HTTP_HEADER_PREFER) PreferHeader preferHeader, @QueryParam("xywh") Rectangle rectangle ) throws RepositoryException, IOException { String uri = uriInfo.getAbsolutePathBuilder().build().toString(); if(rectangle != null) { try { final BufferedImage image = imageService.getImage(uri, rectangle.getX(), rectangle.getY(), rectangle.getW(), rectangle.getH() ); final String mimetype = imageService.getMimeType(uri); log.debug("New image has size: {}x{}", image.getWidth(), image.getHeight()); log.debug("image has mimetype: {}", mimetype); final StreamingOutput entity = new StreamingOutput() { @Override public void write(OutputStream output) throws IOException, WebApplicationException { final String format = mimetype.replaceFirst("^image/", ""); if (ImageIO.getImageWritersByFormatName(format).hasNext()) { ImageIO.write(image, format, output); } else { throw new NoLogWebApplicationException(Response.Status.NOT_ACCEPTABLE); } } }; return Response.ok().header("Content-Type", mimetype).entity(entity).build(); } catch (IllegalArgumentException e) { return super.GET(uriInfo, type, preferHeader); } } return super.GET(uriInfo, type, preferHeader); }  @GET @Produces("image/*") Response GET(@Context final UriInfo uriInfo,
                        @HeaderParam(HttpHeaders.ACCEPT) @DefaultValue(MediaType.WILDCARD) final String type,
                        @HeaderParam(LdpWebService.HTTP_HEADER_PREFER) PreferHeader preferHeader,
                        @QueryParam("xywh") Rectangle rectangle
    );  }### Answer:
@Test public void testWorkflow() throws IOException, InterruptedException { byte[] img = Resources.toByteArray(Resources.getResource("lions.jpg")); Response response1 = RestAssured .given() .content(img) .header(HttpHeaders.CONTENT_TYPE, "image/jpeg") .expect() .statusCode(201) .when() .post(LdpWebService.PATH) .andReturn(); String resourceUri = response1.getHeader("Location"); Response response3 = RestAssured .given() .header(HttpHeaders.ACCEPT, "image/jpeg") .expect() .statusCode(200) .body(CoreMatchers.notNullValue()) .when() .get(resourceUri + "?xywh=333,354,135,115") .andReturn(); BufferedImage image = ImageIO.read(response3.body().asInputStream()); draw(image); Assert.assertEquals(135, image.getWidth()); Assert.assertEquals(115, image.getHeight()); Response response4 = RestAssured .given() .content(( "<> a <" + OA.Annotation + ">; " + "<" + OA.hasTarget + "> <" + resourceUri + "#xywh=333,354,135,115>; " + "<" + OA.hasBody + "> \"Lion\".").getBytes()) .header(HttpHeaders.CONTENT_TYPE, RDFFormat.TURTLE.getDefaultMIMEType()) .expect() .statusCode(201) .when() .post(resourceUri.substring(0,resourceUri.length() - ".jpg".length())) .andReturn(); String annotationUri = response4.getHeader("Location"); Response response5 = RestAssured .given() .header(HttpHeaders.ACCEPT, RDFFormat.TURTLE.getDefaultMIMEType()) .expect() .statusCode(200) .when() .get(annotationUri) .andReturn(); String result = response5.getBody().print(); Assert.assertTrue(result.contains("<http: }