NodeIdRepresentation { public StreamingOutput getResource(final String resourceName, final long nodeId, final Map<QueryParameter, String> queryParams) throws JaxRxException { final StreamingOutput sOutput = new StreamingOutput() { @Override public void write(final OutputStream output) throws IOException, JaxRxException { final String revision = queryParams.get(QueryParameter.REVISION); final String wrap = queryParams.get(QueryParameter.WRAP); final String doNodeId = queryParams.get(QueryParameter.OUTPUT); final boolean wrapResult = (wrap == null) ? false : wrap .equalsIgnoreCase(YESSTRING); final boolean nodeid = (doNodeId == null) ? false : doNodeId .equalsIgnoreCase(YESSTRING); final Long rev = revision == null ? null : Long.valueOf(revision); serialize(resourceName, nodeId, rev, nodeid, output, wrapResult); } }; return sOutput; } NodeIdRepresentation(final File storagePath); StreamingOutput getResource(final String resourceName,
			final long nodeId, final Map<QueryParameter, String> queryParams); StreamingOutput getResourceByAT(final String resourceName,
			final long nodeId, final Map<QueryParameter, String> queryParams,
			final IDAccessType accessType); StreamingOutput performQueryOnResource(final String resourceName,
			final long nodeId, final String query,
			final Map<QueryParameter, String> queryParams); void deleteResource(final String resourceName, final long nodeId); void modifyResource(final String resourceName, final long nodeId,
			final InputStream newValue); void addSubResource(final String resourceName, final long nodeId,
			final InputStream input, final IDAccessType type);  }
@Test public final void testGetResource() throws WebApplicationException, IOException, ParserConfigurationException, SAXException { final Map<QueryParameter, String> queryParams = new HashMap<QueryParameter, String>(); queryParams.put(QueryParameter.OUTPUT, LITERALSTRUE); queryParams.put(QueryParameter.WRAP, LITERALSTRUE); queryParams.put(QueryParameter.REVISION, "0"); ByteArrayOutputStream outputStream; StreamingOutput result; Document doc; NodeList list; Node node; Node resultNode; Attr attribute; result = ridWorker .getResource(RESOURCENAME, NODEIDGETRESOURCE, queryParams); outputStream = new ByteArrayOutputStream(); result.write(outputStream); doc = DOMHelper.buildDocument(outputStream); list = doc.getElementsByTagName("city"); node = list.item(0); attribute = (Attr) node.getAttributes().getNamedItem(IDNAME); final NodeList resultList = doc.getElementsByTagName(RESULTNAME); resultNode = resultList.item(0); outputStream.close(); assertNotNull("Test if node exist 1a", node); assertNotNull("Test if node exist 1b", resultNode); assertNotNull("Test if node exist 1c", attribute); queryParams.clear(); queryParams.put(QueryParameter.OUTPUT, LITERALSFALSE); queryParams.put(QueryParameter.QUERY, null); queryParams.put(QueryParameter.WRAP, LITERALSFALSE); queryParams.put(QueryParameter.REVISION, null); result = ridWorker .getResource(RESOURCENAME, NODEIDGETRESOURCE, queryParams); outputStream = new ByteArrayOutputStream(); result.write(outputStream); doc = DOMHelper.buildDocument(outputStream); list = doc.getElementsByTagName(COUNTRYNAME); node = list.item(0); attribute = (Attr) node.getAttributes().getNamedItem(IDNAME); resultNode = doc.getElementsByTagName(RESULTNAME).item(0); outputStream.close(); assertNotNull("Test if node exist 2a", node); assertNull("Test if node exist 2b", resultNode); assertNull("Test if node exist 2c", attribute); queryParams.clear(); queryParams.put(QueryParameter.OUTPUT, LITERALSFALSE); queryParams.put(QueryParameter.WRAP, LITERALSTRUE); queryParams.put(QueryParameter.REVISION, null); result = ridWorker .getResource(RESOURCENAME, NODEIDGETRESOURCE, queryParams); outputStream = new ByteArrayOutputStream(); result.write(outputStream); doc = DOMHelper.buildDocument(outputStream); list = doc.getElementsByTagName("city"); node = list.item(0); attribute = (Attr) node.getAttributes().getNamedItem(IDNAME); resultNode = doc.getElementsByTagName(RESULTNAME).item(0); outputStream.close(); assertNotNull("Test if node exist 3a", node); assertNotNull("Test if node exist 3b", resultNode); assertNull("Test if node exist 3c", attribute); queryParams.clear(); queryParams.put(QueryParameter.OUTPUT, LITERALSFALSE); queryParams.put(QueryParameter.WRAP, LITERALSTRUE); queryParams.put(QueryParameter.REVISION, "0"); result = ridWorker .getResource(RESOURCENAME, NODEIDGETRESOURCE, queryParams); outputStream = new ByteArrayOutputStream(); result.write(outputStream); doc = DOMHelper.buildDocument(outputStream); list = doc.getElementsByTagName(COUNTRYNAME); node = list.item(0); attribute = (Attr) node.getAttributes().getNamedItem(IDNAME); resultNode = doc.getElementsByTagName(RESULTNAME).item(0); outputStream.close(); assertNotNull("Test if node exist 4a", node); assertNotNull("Test if node exist 4b", resultNode); assertNull("Test if node exist 4c", attribute); }