Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ protected void scanUrl(URL url, String paResourceRootPath, boolean isPaLocal, St
if(isPaLocal) {

if (urlPath.startsWith("file:") || urlPath.startsWith("jar:") || urlPath.startsWith("wsjar:") || urlPath.startsWith("zip:")) {
urlPath = url.getPath();
urlPath = normalizeWindowsPath(url.getPath());
int withinArchive = urlPath.indexOf('!');
if (withinArchive != -1) {
urlPath = urlPath.substring(0, withinArchive);
Expand All @@ -120,7 +120,7 @@ protected void scanUrl(URL url, String paResourceRootPath, boolean isPaLocal, St

} else {
if (urlPath.startsWith("file:") || urlPath.startsWith("jar:") || urlPath.startsWith("wsjar:") || urlPath.startsWith("zip:")) {
urlPath = url.getPath();
urlPath = normalizeWindowsPath(url.getPath());
int withinArchive = urlPath.indexOf('!');
if (withinArchive != -1) {
urlPath = urlPath.substring(0, withinArchive);
Expand All @@ -142,6 +142,22 @@ protected void scanUrl(URL url, String paResourceRootPath, boolean isPaLocal, St

}

protected String normalizeWindowsPath(String path) {
return normalizeWindowsPath(path, File.separatorChar);
}

protected String normalizeWindowsPath(String path, char separatorChar) {
if (separatorChar == '\\'
&& path.length() > 2
&& path.charAt(0) == '/'
&& Character.isLetter(path.charAt(1))
&& path.charAt(2) == ':') {
return path.substring(1);
}

return path;
}

protected void scanPath(String urlPath, String paResourceRootPath, boolean isPaLocal, String[] additionalResourceSuffixes, Map<String, byte[]> resourceMap) {
if (urlPath.startsWith("file:")) {
urlPath = urlPath.substring(5);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* 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.finos.fluxnova.bpm.container.impl.deployment.scanning;

import static org.junit.Assert.assertEquals;

import org.junit.Before;
import org.junit.Test;

/**
* Tests Windows-specific path normalization performed by
* {@link ClassPathProcessApplicationScanner}.
*/
public class ClassPathProcessApplicationScannerWindowsPathTest {

protected ClassPathProcessApplicationScanner scanner;

@Before
public void setUp() {
scanner = new ClassPathProcessApplicationScanner();
}

@Test
public void shouldRemoveLeadingSlashFromWindowsDrivePath() {
assertEquals(
"C:/dev/fluxnova-loan-review/target/classes/META-INF/processes.xml",
scanner.normalizeWindowsPath(
"/C:/dev/fluxnova-loan-review/target/classes/META-INF/processes.xml",
'\\'));
}

@Test
public void shouldSupportLowercaseWindowsDriveLetter() {
assertEquals(
"c:/dev/fluxnova-loan-review",
scanner.normalizeWindowsPath(
"/c:/dev/fluxnova-loan-review",
'\\'));
}

@Test
public void shouldNotChangeWindowsPathWithoutLeadingSlash() {
assertEquals(
"C:/dev/fluxnova-loan-review",
scanner.normalizeWindowsPath(
"C:/dev/fluxnova-loan-review",
'\\'));
}

@Test
public void shouldNotChangeNonDriveWindowsPath() {
assertEquals(
"/dev/fluxnova-loan-review",
scanner.normalizeWindowsPath(
"/dev/fluxnova-loan-review",
'\\'));
}

@Test
public void shouldNotChangePathOnNonWindowsPlatform() {
assertEquals(
"/C:/dev/fluxnova-loan-review",
scanner.normalizeWindowsPath(
"/C:/dev/fluxnova-loan-review",
'/'));
}
}
Loading