Exemplo n.º 1
0
        public virtual void TestGetBpmnXmlFileThroughService()
        {
            string         deploymentId        = repositoryService.CreateDeploymentQuery().First().Id;
            IList <string> deploymentResources = repositoryService.GetDeploymentResourceNames(deploymentId);

            // verify bpmn file name
            Assert.AreEqual(1, deploymentResources.Count);
            string bpmnResourceName = "resources/Bpmn/Deployment/BpmnDeploymentTest.TestGetBpmnXmlFileThroughService.bpmn20.xml";

            Assert.AreEqual(bpmnResourceName, deploymentResources[0]);

            IProcessDefinition processDefinition = repositoryService.CreateProcessDefinitionQuery().First();

            Assert.AreEqual(bpmnResourceName, processDefinition.ResourceName);
            Assert.IsNull(processDefinition.DiagramResourceName);
            Assert.IsFalse(processDefinition.GetHasStartFormKey());

            IReadOnlyProcessDefinition readOnlyProcessDefinition = ((RepositoryServiceImpl)repositoryService).GetDeployedProcessDefinition(processDefinition.Id);

            Assert.IsNull(readOnlyProcessDefinition.DiagramResourceName);

            // verify content
            System.IO.Stream deploymentInputStream = repositoryService.GetResourceAsStream(deploymentId, bpmnResourceName);
            string           contentFromDeployment = ReadInputStreamToString(deploymentInputStream);

            Assert.True(contentFromDeployment.Length > 0);
            Assert.True(contentFromDeployment.Contains("process id=\"emptyProcess\""));

            System.IO.Stream fileInputStream = ReflectUtil.GetResourceAsStream("resources/Bpmn/Deployment/BpmnDeploymentTest.TestGetBpmnXmlFileThroughService.bpmn20.xml");
            string           contentFromFile = ReadInputStreamToString(fileInputStream);

            Assert.AreEqual(contentFromFile, contentFromDeployment);
        }
Exemplo n.º 2
0
        public virtual IDeploymentBuilder AddClasspathResource(string resource)
        {
            var inputStream = ReflectUtil.GetResourceAsStream(resource);

            EnsureUtil.EnsureNotNull("resource '" + resource + "' not found", "inputStream", inputStream);
            return(AddInputStream(resource, inputStream));
        }
Exemplo n.º 3
0
 public virtual IDeploymentBuilder AddClasspathResource(string resource)
 {
     System.IO.Stream inputStream = ReflectUtil.GetResourceAsStream(resource);
     if (inputStream == null)
     {
         throw new ActivitiIllegalArgumentException("resource '" + resource + "' not found");
     }
     return(AddInputStream(resource, inputStream));
 }
Exemplo n.º 4
0
 /// <summary>
 ///     get a resource location by convention based on a class (type) and a
 ///     relative resource name. The return value will be the full classpath
 ///     location of the type, plus a suffix built from the name parameter:
 ///     <code>BpmnDeployer.BPMN_RESOURCE_SUFFIXES</code>.
 ///     The first resource matching a suffix will be returned.
 /// </summary>
 public static string GetBpmnProcessDefinitionResource(Type type, string name)
 {
     if (name.IndexOf("_") > -1)
     {
         name = name.Split('_')[1];
     }
     foreach (var suffix in ResourceSuffixes)
     {
         var resource = CreateResourceName(type, name, suffix);
         if (!ReflectUtil.Existed(resource))
         {
             continue;
         }
         var inputStream = ReflectUtil.GetResourceAsStream(resource);
         if (inputStream == null)
         {
             continue;
         }
         return(resource);
     }
     return(CreateResourceName(type, name, BpmnDeployer.BpmnResourceSuffixes[0]));
 }