From f6550dd7420a28f07b5c464315bbf287dfb7e360 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Fri, 31 Jan 2020 12:03:08 -0500 Subject: 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 Change-Id: I58db71155d30b379e20e7c46bedfc6d79e26b6cb --- .../common/utils/resources/ResourceUtilsTest.java | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'utils/src') 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 resultD0 = ResourceUtils.getDirectoryContents("testdir"); assertEquals(1, resultD0.size()); - assertEquals("testdir/testfile.xml", resultD0.iterator().next()); + assertEquals("testdir/testfile.xml", normalizePath(resultD0.iterator().next())); Set 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 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 resultJ0 = ResourceUtils.getDirectoryContents("com"); assertEquals(189, resultJ0.size()); - assertEquals("com/google/", resultJ0.iterator().next()); + assertEquals("com/google/", normalizePath(resultJ0.iterator().next())); Set 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, "/"); + } } -- cgit 1.2.3-korg