ProducesXmlExtension extends AbstractSampleExtension { @ExtensionDefinition(extensionPoint = ExtensionPoint.VERTEX, produces = MediaType.APPLICATION_XML) @ExtensionDescriptor(description = "returns standard properties of a vertex as XML.") public ExtensionResponse doVertexToXml(@RexsterContext Vertex vertex) { String xml = "<vertex><id>" + vertex.getId().toString() + "</id></vertex>"; 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 doVertexToXml() { Vertex v = this.graph.getVertex(1); ExtensionResponse extensionResponse = this.extension.doVertexToXml(v); 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("<vertex><id>1</id></vertex>", xml); }