From d697d828df129afa52555e9381d69c45d526c7d6 Mon Sep 17 00:00:00 2001 From: Parshad Patel Date: Mon, 26 Nov 2018 18:22:40 +0900 Subject: Rename test classes in drools-applications Make test classes name consitence by adding 'Support' or 'Dummy' at start of util or dummy type of test classes Issue-ID: POLICY-1258 Change-Id: Idea946375ee46f14512d4c4bc29e65adaa4d2b37 Signed-off-by: Parshad Patel --- .../java/org/onap/policy/guard/GuardUtilTest.java | 4 +- .../policy/guard/PolicyGuardYamlToXacmlTest.java | 16 +++--- .../onap/policy/guard/SupportTextFileUtils.java | 63 ++++++++++++++++++++++ .../java/org/onap/policy/guard/TextFileUtils.java | 63 ---------------------- 4 files changed, 73 insertions(+), 73 deletions(-) create mode 100644 controlloop/common/guard/src/test/java/org/onap/policy/guard/SupportTextFileUtils.java delete mode 100644 controlloop/common/guard/src/test/java/org/onap/policy/guard/TextFileUtils.java (limited to 'controlloop/common/guard/src/test/java') diff --git a/controlloop/common/guard/src/test/java/org/onap/policy/guard/GuardUtilTest.java b/controlloop/common/guard/src/test/java/org/onap/policy/guard/GuardUtilTest.java index 8fc5a83da..1f7002a7d 100644 --- a/controlloop/common/guard/src/test/java/org/onap/policy/guard/GuardUtilTest.java +++ b/controlloop/common/guard/src/test/java/org/onap/policy/guard/GuardUtilTest.java @@ -45,7 +45,7 @@ public class GuardUtilTest { Yaml clYaml = new Yaml(new Constructor(ControlLoopPolicy.class)); String clYamlString = clYaml.dump(clPolicy); - TextFileUtils.putStringAsFile(clYamlString, tempYamlFile); + SupportTextFileUtils.putStringAsFile(clYamlString, tempYamlFile); Pair result = Util.loadYaml(tempYamlFile.getCanonicalPath()); @@ -74,7 +74,7 @@ public class GuardUtilTest { Yaml clYaml = new Yaml(new Constructor(ControlLoopPolicy.class)); String clYamlString = clYaml.dump(clGuardPolicy); - TextFileUtils.putStringAsFile(clYamlString, tempYamlFile); + SupportTextFileUtils.putStringAsFile(clYamlString, tempYamlFile); ControlLoopGuard result = Util.loadYamlGuard(tempYamlFile.getCanonicalPath()); diff --git a/controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardYamlToXacmlTest.java b/controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardYamlToXacmlTest.java index 3b517bcc1..dced2889d 100644 --- a/controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardYamlToXacmlTest.java +++ b/controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardYamlToXacmlTest.java @@ -86,11 +86,11 @@ public class PolicyGuardYamlToXacmlTest { Yaml clYaml = new Yaml(new Constructor(ControlLoopGuard.class)); String clYamlString = clYaml.dump(clGuard); - TextFileUtils.putStringAsFile(clYamlString, tempYamlFile); + SupportTextFileUtils.putStringAsFile(clYamlString, tempYamlFile); PolicyGuardYamlToXacml.fromYamlToXacml(tempYamlFile.getCanonicalPath(), tempXacmlTemplateFile.getCanonicalPath(), tempXacmlOutputFile.getCanonicalPath()); - String result = TextFileUtils.getTextFileAsString(tempXacmlOutputFile.getCanonicalPath()); + String result = SupportTextFileUtils.getTextFileAsString(tempXacmlOutputFile.getCanonicalPath()); // Assert no mote "${}" are left assertFalse(result.contains("${")); @@ -124,11 +124,11 @@ public class PolicyGuardYamlToXacmlTest { Yaml clYaml = new Yaml(new Constructor(ControlLoopGuard.class)); String clYamlString = clYaml.dump(clGuard); - TextFileUtils.putStringAsFile(clYamlString, tempYamlFile); + SupportTextFileUtils.putStringAsFile(clYamlString, tempYamlFile); PolicyGuardYamlToXacml.fromYamlToXacml(tempYamlFile.getCanonicalPath(), tempXacmlTemplateFile.getCanonicalPath(), tempXacmlOutputFile.getCanonicalPath()); - String result = TextFileUtils.getTextFileAsString(tempXacmlOutputFile.getCanonicalPath()); + String result = SupportTextFileUtils.getTextFileAsString(tempXacmlOutputFile.getCanonicalPath()); // Assert no mote "${}" are left assertFalse(result.contains("${")); @@ -184,11 +184,11 @@ public class PolicyGuardYamlToXacmlTest { Yaml clYaml = new Yaml(new Constructor(ControlLoopGuard.class)); String clYamlString = clYaml.dump(clGuard); - TextFileUtils.putStringAsFile(clYamlString, tempYamlFile); + SupportTextFileUtils.putStringAsFile(clYamlString, tempYamlFile); PolicyGuardYamlToXacml.fromYamlToXacmlBlacklist(tempYamlFile.getCanonicalPath(), tempXacmlTemplateFile.getCanonicalPath(), tempXacmlOutputFile.getCanonicalPath()); - String result = TextFileUtils.getTextFileAsString(tempXacmlOutputFile.getCanonicalPath()); + String result = SupportTextFileUtils.getTextFileAsString(tempXacmlOutputFile.getCanonicalPath()); System.err.println(result); // Assert no mote "${}" are left assertFalse(result.contains("${")); @@ -220,11 +220,11 @@ public class PolicyGuardYamlToXacmlTest { Yaml clYaml = new Yaml(new Constructor(ControlLoopGuard.class)); String clYamlString = clYaml.dump(clGuard); - TextFileUtils.putStringAsFile(clYamlString, tempYamlFile); + SupportTextFileUtils.putStringAsFile(clYamlString, tempYamlFile); PolicyGuardYamlToXacml.fromYamlToXacmlBlacklist(tempYamlFile.getCanonicalPath(), tempXacmlTemplateFile.getCanonicalPath(), tempXacmlOutputFile.getCanonicalPath()); - String result = TextFileUtils.getTextFileAsString(tempXacmlOutputFile.getCanonicalPath()); + String result = SupportTextFileUtils.getTextFileAsString(tempXacmlOutputFile.getCanonicalPath()); System.err.println(result); // Assert no mote "${}" are left assertFalse(result.contains("${")); diff --git a/controlloop/common/guard/src/test/java/org/onap/policy/guard/SupportTextFileUtils.java b/controlloop/common/guard/src/test/java/org/onap/policy/guard/SupportTextFileUtils.java new file mode 100644 index 000000000..03260ada9 --- /dev/null +++ b/controlloop/common/guard/src/test/java/org/onap/policy/guard/SupportTextFileUtils.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * guard + * ================================================================================ + * Copyright (C) 2018 Ericsson. 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. + * 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.guard; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; + +/** + * The Class TextFileUtils is class that provides useful functions for handling text files. + * Functions to read and wrtie text files to strings and strings are provided. + * + * @author Liam Fallon (liam.fallon@ericsson.com) + */ +public abstract class SupportTextFileUtils { + /** + * Method to return the contents of a text file as a string. + * + * @param textFilePath The path to the file as a string + * @return A string containing the contents of the file + * @throws IOException on errors reading text from the file + */ + public static String getTextFileAsString(final String textFilePath) throws IOException { + final File textFile = new File(textFilePath); + final FileInputStream textFileInputStream = new FileInputStream(textFile); + final byte[] textData = new byte[(int) textFile.length()]; + textFileInputStream.read(textData); + textFileInputStream.close(); + return new String(textData); + } + + /** + * Method to write contents of a string to a text file. + * + * @param outString The string to write + * @param textFile The file to write the string to + * @throws IOException on errors reading text from the file + */ + public static void putStringAsFile(final String outString, final File textFile) throws IOException { + final FileOutputStream textFileOutputStream = new FileOutputStream(textFile); + textFileOutputStream.write(outString.getBytes()); + textFileOutputStream.close(); + } +} diff --git a/controlloop/common/guard/src/test/java/org/onap/policy/guard/TextFileUtils.java b/controlloop/common/guard/src/test/java/org/onap/policy/guard/TextFileUtils.java deleted file mode 100644 index 46a2762cc..000000000 --- a/controlloop/common/guard/src/test/java/org/onap/policy/guard/TextFileUtils.java +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * guard - * ================================================================================ - * Copyright (C) 2018 Ericsson. 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. - * 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.guard; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; - -/** - * The Class TextFileUtils is class that provides useful functions for handling text files. - * Functions to read and wrtie text files to strings and strings are provided. - * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public abstract class TextFileUtils { - /** - * Method to return the contents of a text file as a string. - * - * @param textFilePath The path to the file as a string - * @return A string containing the contents of the file - * @throws IOException on errors reading text from the file - */ - public static String getTextFileAsString(final String textFilePath) throws IOException { - final File textFile = new File(textFilePath); - final FileInputStream textFileInputStream = new FileInputStream(textFile); - final byte[] textData = new byte[(int) textFile.length()]; - textFileInputStream.read(textData); - textFileInputStream.close(); - return new String(textData); - } - - /** - * Method to write contents of a string to a text file. - * - * @param outString The string to write - * @param textFile The file to write the string to - * @throws IOException on errors reading text from the file - */ - public static void putStringAsFile(final String outString, final File textFile) throws IOException { - final FileOutputStream textFileOutputStream = new FileOutputStream(textFile); - textFileOutputStream.write(outString.getBytes()); - textFileOutputStream.close(); - } -} -- cgit 1.2.3-korg