From c3003b149d7dc85e976719f72b45cd737ff20c22 Mon Sep 17 00:00:00 2001 From: Eric Barboni Date: Tue, 11 Feb 2020 20:37:01 +0100 Subject: [PATCH] Test for windows, import fix --- .../java/org/apache/archiva/common/utils/PathUtil.java | 2 -- .../main/java/org/apache/archiva/event/EventHandler.java | 1 - .../main/java/org/apache/archiva/event/EventManager.java | 4 ++-- .../src/main/java/org/apache/archiva/event/EventType.java | 2 +- .../org/apache/archiva/common/utils/PathUtilTest.java | 8 +++++--- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/archiva/common/utils/PathUtil.java b/archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/archiva/common/utils/PathUtil.java index 8c9a437a4..b8d14bb83 100644 --- a/archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/archiva/common/utils/PathUtil.java +++ b/archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/archiva/common/utils/PathUtil.java @@ -26,8 +26,6 @@ import java.net.URI; import java.nio.file.FileSystems; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.List; import java.util.StringTokenizer; import java.util.Vector; import java.util.stream.StreamSupport; diff --git a/archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/archiva/event/EventHandler.java b/archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/archiva/event/EventHandler.java index 5217f1152..f98adcdab 100644 --- a/archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/archiva/event/EventHandler.java +++ b/archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/archiva/event/EventHandler.java @@ -19,7 +19,6 @@ package org.apache.archiva.event; * under the License. */ -import org.apache.archiva.event.Event; import java.util.EventListener; diff --git a/archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/archiva/event/EventManager.java b/archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/archiva/event/EventManager.java index 189f9500e..00a240066 100644 --- a/archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/archiva/event/EventManager.java +++ b/archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/archiva/event/EventManager.java @@ -28,7 +28,7 @@ import java.util.concurrent.ConcurrentHashMap; public class EventManager implements EventSource { - private static final Logger log = LoggerFactory.getLogger(EventManager.class); + private static final Logger LOG = LoggerFactory.getLogger(EventManager.class); private final ConcurrentHashMap, Set> handlerMap = new ConcurrentHashMap<>(); @@ -71,7 +71,7 @@ public class EventManager implements EventSource handler.handle(event); } catch (Exception e) { // We catch all errors from handlers - log.error("An error occured during event handling: {}", e.getMessage(), e); + LOG.error("An error occured during event handling: {}", e.getMessage(), e); } } } diff --git a/archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/archiva/event/EventType.java b/archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/archiva/event/EventType.java index 58a921382..50d42679e 100644 --- a/archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/archiva/event/EventType.java +++ b/archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/archiva/event/EventType.java @@ -119,7 +119,7 @@ public class EventType implements Serializable { private Object writeReplace() throws ObjectStreamException { - Deque path = new LinkedList(); + Deque path = new LinkedList<>(); EventType t = this; while (t != ROOT) { path.addFirst(t.name); diff --git a/archiva-modules/archiva-base/archiva-common/src/test/java/org/apache/archiva/common/utils/PathUtilTest.java b/archiva-modules/archiva-base/archiva-common/src/test/java/org/apache/archiva/common/utils/PathUtilTest.java index dfd5b9014..af2c42389 100644 --- a/archiva-modules/archiva-base/archiva-common/src/test/java/org/apache/archiva/common/utils/PathUtilTest.java +++ b/archiva-modules/archiva-base/archiva-common/src/test/java/org/apache/archiva/common/utils/PathUtilTest.java @@ -24,6 +24,7 @@ import org.apache.commons.lang3.StringUtils; import java.nio.file.Path; import java.nio.file.Paths; +import org.apache.commons.io.FilenameUtils; /** * PathUtilTest @@ -33,15 +34,16 @@ import java.nio.file.Paths; public class PathUtilTest extends TestCase { + public void testToRelativeWithoutSlash() { - assertEquals( "path/to/resource.xml", PathUtil.getRelative( "/home/user/foo/repository", + assertEquals( FilenameUtils.separatorsToSystem( "path/to/resource.xml" ), PathUtil.getRelative( "/home/user/foo/repository", "/home/user/foo/repository/path/to/resource.xml" ) ); } public void testToRelativeWithSlash() { - assertEquals( "path/to/resource.xml", PathUtil.getRelative( "/home/user/foo/repository/", + assertEquals( FilenameUtils.separatorsToSystem( "path/to/resource.xml" ), PathUtil.getRelative( "/home/user/foo/repository/", "/home/user/foo/repository/path/to/resource.xml" ) ); } @@ -87,7 +89,7 @@ public class PathUtilTest String path = "path/to/resource.xml"; String expectedPath = "file:" + workingDirname + "/" + path; - + assertEquals( expectedPath, PathUtil.toUrl( expectedPath ) ); } } -- 2.39.5