summaryrefslogtreecommitdiffstats
path: root/applications
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-02-19 15:41:24 -0500
committerJim Hahn <jrh3@att.com>2021-02-19 15:52:32 -0500
commit58266a1beabbeb46186cc44e3625d35183727506 (patch)
tree6c65b250ae8b4103fd2e6882607caeb7904419c6 /applications
parent0415057132ae04f1d75cb60f7a62d9fa65d6e04d (diff)
Fix junit for "native" on Windows
Windows doesn't like file names containing ":". Added code to replace ":" with "_", but only when the JVM is run on a Windows OS. Issue-ID: POLICY-3085 Change-Id: I1d3b6819bf564571eddda69e4c5fbd2bb807a3aa Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'applications')
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlPolicyUtils.java14
1 files changed, 12 insertions, 2 deletions
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlPolicyUtils.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlPolicyUtils.java
index 1babe30c..a2ecf8c0 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlPolicyUtils.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlPolicyUtils.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,6 +38,7 @@ import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
import java.util.StringJoiner;
+import java.util.function.Function;
import java.util.stream.Collectors;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.IdReferenceType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.ObjectFactory;
@@ -57,6 +58,15 @@ public class XacmlPolicyUtils {
private static final String DOT_FILE_SUFFIX = ".file";
private static final String NOT_FOUND_MESSAGE = "NOT FOUND";
+ /**
+ * Function that sanitizes a file name, if the OS is Windows, so that it's a valid
+ * file name. Does nothing for other OSs.
+ */
+ private static final Function<String, String> SANITIZE_FILE_NAME =
+ System.getProperty("os.name").startsWith("Windows")
+ ? filename -> filename.replace(':', '_')
+ : filename -> filename;
+
private XacmlPolicyUtils() {
super();
}
@@ -371,7 +381,7 @@ public class XacmlPolicyUtils {
//
// Construct the Path
//
- return Paths.get(path.toAbsolutePath().toString(), filename);
+ return Paths.get(path.toAbsolutePath().toString(), SANITIZE_FILE_NAME.apply(filename));
}
/**