From da9ff15a407be1c3824703bb8b5b9baa10481a97 Mon Sep 17 00:00:00 2001 From: Tassilo Weidner Date: Tue, 30 Nov 2021 17:28:07 +0100 Subject: [PATCH] =?UTF-8?q?fix(engine):=20trim=20`=E2=80=A6`=20value=20from=20`processes.xml`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit related to CAM-14155 --- .../impl/metadata/ProcessesXmlParse.java | 6 +- .../TestDeploymentResourceWithWhitespace.java | 61 +++++++++++++++++++ .../processes-resource-with-whitespace.xml | 20 ++++++ 3 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/deployment/cfg/TestDeploymentResourceWithWhitespace.java create mode 100644 qa/integration-tests-engine/src/test/resources/org/camunda/bpm/integrationtest/deployment/cfg/processes-resource-with-whitespace.xml diff --git a/engine/src/main/java/org/camunda/bpm/application/impl/metadata/ProcessesXmlParse.java b/engine/src/main/java/org/camunda/bpm/application/impl/metadata/ProcessesXmlParse.java index 86cf2c37572..18b261cbc77 100644 --- a/engine/src/main/java/org/camunda/bpm/application/impl/metadata/ProcessesXmlParse.java +++ b/engine/src/main/java/org/camunda/bpm/application/impl/metadata/ProcessesXmlParse.java @@ -104,7 +104,11 @@ protected void parseProcessArchive(Element element, List pars processArchive.setProcessEngineName(childElement.getText()); } else if(PROCESS.equals(childElement.getTagName()) || RESOURCE.equals(childElement.getTagName())) { - processResourceNames.add(childElement.getText()); + String resource = childElement.getText(); + if (resource != null) { + resource = resource.trim(); + } + processResourceNames.add(resource); } else if(PROPERTIES.equals(childElement.getTagName())) { parseProperties(childElement, properties); diff --git a/qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/deployment/cfg/TestDeploymentResourceWithWhitespace.java b/qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/deployment/cfg/TestDeploymentResourceWithWhitespace.java new file mode 100644 index 00000000000..9fb7f0ed4ab --- /dev/null +++ b/qa/integration-tests-engine/src/test/java/org/camunda/bpm/integrationtest/deployment/cfg/TestDeploymentResourceWithWhitespace.java @@ -0,0 +1,61 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.integrationtest.deployment.cfg; + +import org.camunda.bpm.engine.repository.ProcessDefinition; +import org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest; +import org.camunda.bpm.integrationtest.util.DeploymentHelper; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.EmptyAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.util.List; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; + +@RunWith(Arquillian.class) +public class TestDeploymentResourceWithWhitespace extends AbstractFoxPlatformIntegrationTest { + + @Deployment + public static WebArchive processArchive() { + return ShrinkWrap.create(WebArchive.class, "test.war") + .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml") + .addAsLibraries(DeploymentHelper.getEngineCdi()) + .addAsResource("org/camunda/bpm/integrationtest/deployment/cfg/processes-resource-with-whitespace.xml", "META-INF/processes.xml") + .addAsResource("org/camunda/bpm/integrationtest/deployment/cfg/invoice-it.bpmn20.xml") + .addClass(AbstractFoxPlatformIntegrationTest.class) + .addClass(DummyProcessApplication.class); + } + + @Test + public void shouldDeployProcess() { + ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery() + .processDefinitionKey("invoice-it") + .singleResult(); + + assertEquals("invoice-it", processDefinition.getKey()); + } + +} diff --git a/qa/integration-tests-engine/src/test/resources/org/camunda/bpm/integrationtest/deployment/cfg/processes-resource-with-whitespace.xml b/qa/integration-tests-engine/src/test/resources/org/camunda/bpm/integrationtest/deployment/cfg/processes-resource-with-whitespace.xml new file mode 100644 index 00000000000..abe7f8d308d --- /dev/null +++ b/qa/integration-tests-engine/src/test/resources/org/camunda/bpm/integrationtest/deployment/cfg/processes-resource-with-whitespace.xml @@ -0,0 +1,20 @@ + + + + + + + org/camunda/bpm/integrationtest/deployment/cfg/invoice-it.bpmn20.xml + + + + true + true + + + + +