As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
<br> @Deployment<br> public void testGetBpmnXmlFileThroughService() {<br> String deploymentId = repositoryService.createDeploymentQuery().singleResult().getId();<br> List<String> deploymentResources = repositoryService.getDeploymentResourceNames(deploymentId);<br> <br> // verify bpmn file name<br> assertEquals(1, deploymentResources.size());<br> String bpmnResourceName = "org/activiti/engine/test/bpmn/deployment/BpmnDeploymentTest.testGetBpmnXmlFileThroughService.bpmn20.xml";<br> assertEquals(bpmnResourceName, deploymentResources.get(0));<br> <br> ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();<br> assertEquals(bpmnResourceName, processDefinition.getResourceName());<br> assertNull(processDefinition.getDiagramResourceName());<br> assertFalse(processDefinition.hasStartFormKey());<br> <br> ReadOnlyProcessDefinition readOnlyProcessDefinition = ((RepositoryServiceImpl)repositoryService).getDeployedProcessDefinition(processDefinition.getId());<br> assertNull(readOnlyProcessDefinition.getDiagramResourceName());<br> <br> // verify content<br> InputStream deploymentInputStream = repositoryService.getResourceAsStream(deploymentId, bpmnResourceName);<br> String contentFromDeployment = readInputStreamToString(deploymentInputStream);<br> assertTrue(contentFromDeployment.length() > 0);<br> assertTrue(contentFromDeployment.contains("process id=\"emptyProcess\""));<br> <br> InputStream fileInputStream = ReflectUtil.getResourceAsStream("org/activiti/engine/test/bpmn/deployment/BpmnDeploymentTest.testGetBpmnXmlFileThroughService.bpmn20.xml");<br> String contentFromFile = readInputStreamToString(fileInputStream);<br> assertEquals(contentFromFile, contentFromDeployment);<br> }<br><br> private String readInputStreamToString(InputStream inputStream) {<br> byte[] bytes = IoUtil.readInputStream(inputStream, "input stream");<br> return new String(bytes);<br> }<br><br>– IOUtil:<br><br>public static byte[] readInputStream(InputStream inputStream, String inputStreamName) {<br> ByteArrayOutputStream outputStream = new ByteArrayOutputStream();<br> byte[] buffer = new byte[16*1024];<br> try {<br> int bytesRead = inputStream.read(buffer);<br> while (bytesRead!=-1) {<br> outputStream.write(buffer, 0, bytesRead);<br> bytesRead = inputStream.read(buffer);<br> }<br> } catch (Exception e) {<br> throw new ActivitiException("couldn't read input stream "+inputStreamName, e);<br> }<br> return outputStream.toByteArray();<br> }<br>