ProducesXmlExtension extends AbstractSampleExtension { @ExtensionDefinition(extensionPoint = ExtensionPoint.EDGE, produces = MediaType.APPLICATION_XML) @ExtensionDescriptor(description = "returns standard properties of an edge as XML.") public ExtensionResponse doEdgeToXml(@RexsterContext Edge edge) { String xml = "<edge><id>" + edge.getId().toString() + "</id><label>" + edge.getLabel() + "</label></edge>"; return new ExtensionResponse(Response.ok(xml).build()); }  @ExtensionDefinition(extensionPoint = ExtensionPoint.VERTEX, produces = MediaType.APPLICATION_XML) @ExtensionDescriptor(description = "returns standard properties of a vertex as XML.") ExtensionResponse doVertexToXml(@RexsterContext Vertex vertex); @ExtensionDefinition(extensionPoint = ExtensionPoint.EDGE, produces = MediaType.APPLICATION_XML) @ExtensionDescriptor(description = "returns standard properties of an edge as XML.") ExtensionResponse doEdgeToXml(@RexsterContext Edge edge); static final String EXTENSION_NAME; }
@Test public void doEdgeToXml() { Edge e = this.graph.getEdge(11); ExtensionResponse extensionResponse = this.extension.doEdgeToXml(e); Assert.assertNotNull(extensionResponse); Response response = extensionResponse.getJerseyResponse(); Assert.assertNotNull(response); Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); String xml = (String) response.getEntity(); Assert.assertEquals("<edge><id>11</id><label>created</label></edge>", xml); }