08-09-2011 02:31 PM
08-10-2011 07:22 AM
08-10-2011 03:38 PM
08-16-2011 08:10 AM
@Deployment
public void testGetBpmnXmlFileThroughService() {
String deploymentId = repositoryService.createDeploymentQuery().singleResult().getId();
List<String> deploymentResources = repositoryService.getDeploymentResourceNames(deploymentId);
// verify bpmn file name
assertEquals(1, deploymentResources.size());
String bpmnResourceName = "org/activiti/engine/test/bpmn/deployment/BpmnDeploymentTest.testGetBpmnXmlFileThroughService.bpmn20.xml";
assertEquals(bpmnResourceName, deploymentResources.get(0));
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
assertEquals(bpmnResourceName, processDefinition.getResourceName());
assertNull(processDefinition.getDiagramResourceName());
assertFalse(processDefinition.hasStartFormKey());
ReadOnlyProcessDefinition readOnlyProcessDefinition = ((RepositoryServiceImpl)repositoryService).getDeployedProcessDefinition(processDefinition.getId());
assertNull(readOnlyProcessDefinition.getDiagramResourceName());
// verify content
InputStream deploymentInputStream = repositoryService.getResourceAsStream(deploymentId, bpmnResourceName);
String contentFromDeployment = readInputStreamToString(deploymentInputStream);
assertTrue(contentFromDeployment.length() > 0);
assertTrue(contentFromDeployment.contains("process id=\"emptyProcess\""));
InputStream fileInputStream = ReflectUtil.getResourceAsStream("org/activiti/engine/test/bpmn/deployment/BpmnDeploymentTest.testGetBpmnXmlFileThroughService.bpmn20.xml");
String contentFromFile = readInputStreamToString(fileInputStream);
assertEquals(contentFromFile, contentFromDeployment);
}
private String readInputStreamToString(InputStream inputStream) {
byte[] bytes = IoUtil.readInputStream(inputStream, "input stream");
return new String(bytes);
}
– IOUtil:
public static byte[] readInputStream(InputStream inputStream, String inputStreamName) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
byte[] buffer = new byte[16*1024];
try {
int bytesRead = inputStream.read(buffer);
while (bytesRead!=-1) {
outputStream.write(buffer, 0, bytesRead);
bytesRead = inputStream.read(buffer);
}
} catch (Exception e) {
throw new ActivitiException("couldn't read input stream "+inputStreamName, e);
}
return outputStream.toByteArray();
}
08-19-2011 02:28 PM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.