aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-01-31 12:03:08 -0500
committerJim Hahn <jrh3@att.com>2020-01-31 12:05:35 -0500
commitf6550dd7420a28f07b5c464315bbf287dfb7e360 (patch)
tree32ed5487ba47fae998d5f7a89073cf0bf07b592f
parentb2899115452784712443429704d5956075e95557 (diff)
Fix ResourceUtilsTest junit
The junit for ResourceUtilsTest fails when run on a non-linux box due to the different path separator. Modified the test to normalize path names before making comparisons. Issue-ID: POLICY-1625 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: I58db71155d30b379e20e7c46bedfc6d79e26b6cb
-rw-r--r--utils/src/test/java/org/onap/policy/common/utils/resources/ResourceUtilsTest.java22
1 files changed, 16 insertions, 6 deletions
diff --git a/utils/src/test/java/org/onap/policy/common/utils/resources/ResourceUtilsTest.java b/utils/src/test/java/org/onap/policy/common/utils/resources/ResourceUtilsTest.java
index 2991009f..8f714a49 100644
--- a/utils/src/test/java/org/onap/policy/common/utils/resources/ResourceUtilsTest.java
+++ b/utils/src/test/java/org/onap/policy/common/utils/resources/ResourceUtilsTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -321,26 +321,36 @@ public class ResourceUtilsTest {
Set<String> resultD0 = ResourceUtils.getDirectoryContents("testdir");
assertEquals(1, resultD0.size());
- assertEquals("testdir/testfile.xml", resultD0.iterator().next());
+ assertEquals("testdir/testfile.xml", normalizePath(resultD0.iterator().next()));
Set<String> resultD1 = ResourceUtils.getDirectoryContents("org/onap/policy/common");
assertTrue(resultD1.size() > 0);
- assertEquals("org/onap/policy/common/utils/", resultD1.iterator().next());
+ assertEquals("org/onap/policy/common/utils/", normalizePath(resultD1.iterator().next()));
Set<String> resultD2 = ResourceUtils.getDirectoryContents("org/onap/policy/common/utils/coder");
assertTrue(resultD2.size() >= 15);
- assertEquals("org/onap/policy/common/utils/coder/CoderExceptionTest.class", resultD2.iterator().next());
+ assertEquals("org/onap/policy/common/utils/coder/CoderExceptionTest.class",
+ normalizePath(resultD2.iterator().next()));
Set<String> resultJ0 = ResourceUtils.getDirectoryContents("com");
assertEquals(189, resultJ0.size());
- assertEquals("com/google/", resultJ0.iterator().next());
+ assertEquals("com/google/", normalizePath(resultJ0.iterator().next()));
Set<String> resultJ1 = ResourceUtils.getDirectoryContents("com/google/gson/util");
assertEquals(1, resultJ1.size());
- assertEquals("com/google/gson/util/VersionUtils.class", resultJ1.iterator().next());
+ assertEquals("com/google/gson/util/VersionUtils.class", normalizePath(resultJ1.iterator().next()));
URL dummyUrl = new URL("http://even/worse");
assertTrue(ResourceUtils.getDirectoryContentsJar(dummyUrl, "nonexistantdirectory").isEmpty());
}
+
+ /**
+ * Normalizes a path name, replacing OS-specific separators with "/".
+ * @param pathName path name to be normalized
+ * @return the normalized path name
+ */
+ private String normalizePath(String pathName) {
+ return pathName.replace(File.separator, "/");
+ }
}