HADOOP-15015. TestConfigurationFieldsBase to use SLF4J for logging. Contributed by Steve Loughran

This commit is contained in:
Mingliang Liu 2017-11-03 21:01:56 -07:00
parent 169cdaa38e
commit b6d8f87b8e
1 changed files with 176 additions and 246 deletions

View File

@ -25,15 +25,23 @@ import org.junit.Test;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static org.junit.Assert.assertTrue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
/**
* Base class for comparing fields in one or more Configuration classes
@ -74,6 +82,15 @@ import static org.junit.Assert.assertTrue;
@Ignore
public abstract class TestConfigurationFieldsBase {
private static final Logger LOG = LoggerFactory.getLogger(
TestConfigurationFieldsBase.class);
private static final Logger LOG_CONFIG = LoggerFactory.getLogger(
"org.apache.hadoop.conf.TestConfigurationFieldsBase.config");
private static final Logger LOG_XML = LoggerFactory.getLogger(
"org.apache.hadoop.conf.TestConfigurationFieldsBase.xml");
/**
* Member variable for storing xml filename.
*/
@ -98,27 +115,27 @@ public abstract class TestConfigurationFieldsBase {
/**
* Set of properties to skip extracting (and thus comparing later) in
* extractMemberVariablesFromConfigurationFields.
* {@link #extractMemberVariablesFromConfigurationFields(Field[])}.
*/
protected Set<String> configurationPropsToSkipCompare = null;
protected Set<String> configurationPropsToSkipCompare = new HashSet<>();
/**
* Set of property prefixes to skip extracting (and thus comparing later)
* in * extractMemberVariablesFromConfigurationFields.
*/
protected Set<String> configurationPrefixToSkipCompare = null;
protected Set<String> configurationPrefixToSkipCompare = new HashSet<>();
/**
* Set of properties to skip extracting (and thus comparing later) in
* extractPropertiesFromXml.
*/
protected Set<String> xmlPropsToSkipCompare = null;
protected Set<String> xmlPropsToSkipCompare = new HashSet<>();
/**
* Set of property prefixes to skip extracting (and thus comparing later)
* in extractPropertiesFromXml.
*/
protected Set<String> xmlPrefixToSkipCompare = null;
protected Set<String> xmlPrefixToSkipCompare = new HashSet<>();
/**
* Member variable to store Configuration variables for later comparison.
@ -155,13 +172,6 @@ public abstract class TestConfigurationFieldsBase {
@SuppressWarnings("checkstyle:visibilitymodifier")
protected Set<String> filtersForDefaultValueCollisionCheck = new HashSet<>();
/**
* Member variable for debugging base class operation
*/
protected boolean configDebug = false;
protected boolean xmlDebug = false;
protected boolean defaultDebug = false;
/**
* Abstract method to be used by subclasses for initializing base
* members.
@ -173,27 +183,24 @@ public abstract class TestConfigurationFieldsBase {
* variables from a Configuration type class.
*
* @param fields The class member variables
* @return HashMap containing <StringValue,MemberVariableName> entries
* @return HashMap containing (StringValue, MemberVariableName) entries
*/
private HashMap<String,String>
extractMemberVariablesFromConfigurationFields(Field[] fields) {
// Sanity Check
if (fields==null)
if (fields == null)
return null;
HashMap<String,String> retVal = new HashMap<String,String>();
HashMap<String,String> retVal = new HashMap<>();
// Setup regexp for valid properties
String propRegex = "^[A-Za-z][A-Za-z0-9_-]+(\\.[A-Za-z0-9_-]+)+$";
Pattern p = Pattern.compile(propRegex);
// Iterate through class member variables
int totalFields = 0;
String value;
for (Field f : fields) {
if (configDebug) {
System.out.println("Field: " + f);
}
LOG_CONFIG.debug("Field: {}", f);
// Filter out anything that isn't "public static final"
if (!Modifier.isStatic(f.getModifiers()) ||
!Modifier.isPublic(f.getModifiers()) ||
@ -217,9 +224,7 @@ public abstract class TestConfigurationFieldsBase {
} catch (IllegalAccessException iaException) {
continue;
}
if (configDebug) {
System.out.println(" Value: " + value);
}
LOG_CONFIG.debug(" Value: {}", value);
// Special Case: Detect and ignore partial properties (ending in x)
// or file properties (ending in .xml)
if (value.endsWith(".xml") ||
@ -227,20 +232,16 @@ public abstract class TestConfigurationFieldsBase {
value.endsWith("-"))
continue;
// Ignore known configuration props
if (configurationPropsToSkipCompare != null) {
if (configurationPropsToSkipCompare.contains(value)) {
continue;
}
if (configurationPropsToSkipCompare.contains(value)) {
continue;
}
// Ignore known configuration prefixes
boolean skipPrefix = false;
if (configurationPrefixToSkipCompare != null) {
for (String cfgPrefix : configurationPrefixToSkipCompare) {
if (value.startsWith(cfgPrefix)) {
skipPrefix = true;
break;
}
}
for (String cfgPrefix : configurationPrefixToSkipCompare) {
if (value.startsWith(cfgPrefix)) {
skipPrefix = true;
break;
}
}
if (skipPrefix) {
continue;
@ -249,22 +250,16 @@ public abstract class TestConfigurationFieldsBase {
// something like: blah.blah2(.blah3.blah4...)
Matcher m = p.matcher(value);
if (!m.find()) {
if (configDebug) {
System.out.println(" Passes Regex: false");
}
LOG_CONFIG.debug(" Passes Regex: false");
continue;
}
if (configDebug) {
System.out.println(" Passes Regex: true");
}
LOG_CONFIG.debug(" Passes Regex: true");
// Save member variable/value as hash
if (!retVal.containsKey(value)) {
retVal.put(value,f.getName());
} else {
if (configDebug) {
System.out.println("ERROR: Already found key for property " + value);
}
LOG_CONFIG.debug("ERROR: Already found key for property " + value);
}
}
@ -275,11 +270,10 @@ public abstract class TestConfigurationFieldsBase {
* Pull properties and values from filename.
*
* @param filename XML filename
* @return HashMap containing <Property,Value> entries from XML file
* @return HashMap containing &lt;Property,Value&gt; entries from XML file
*/
private HashMap<String,String> extractPropertiesFromXml
(String filename) {
if (filename==null) {
private HashMap<String,String> extractPropertiesFromXml(String filename) {
if (filename == null) {
return null;
}
@ -288,48 +282,28 @@ public abstract class TestConfigurationFieldsBase {
conf.setAllowNullValueProperties(true);
conf.addResource(filename);
HashMap<String,String> retVal = new HashMap<String,String>();
HashMap<String,String> retVal = new HashMap<>();
Iterator<Map.Entry<String,String>> kvItr = conf.iterator();
while (kvItr.hasNext()) {
Map.Entry<String,String> entry = kvItr.next();
String key = entry.getKey();
// Ignore known xml props
if (xmlPropsToSkipCompare != null) {
if (xmlPropsToSkipCompare.contains(key)) {
if (xmlDebug) {
System.out.println(" Skipping Full Key: " + key);
}
continue;
}
if (xmlPropsToSkipCompare.contains(key)) {
LOG_XML.debug(" Skipping Full Key: {}", key);
continue;
}
// Ignore known xml prefixes
boolean skipPrefix = false;
if (xmlPrefixToSkipCompare != null) {
for (String xmlPrefix : xmlPrefixToSkipCompare) {
if (key.startsWith(xmlPrefix)) {
skipPrefix = true;
break;
}
}
}
if (skipPrefix) {
if (xmlDebug) {
System.out.println(" Skipping Prefix Key: " + key);
}
if (xmlPrefixToSkipCompare.stream().anyMatch(key::startsWith)) {
LOG_XML.debug(" Skipping Prefix Key: " + key);
continue;
}
if (conf.onlyKeyExists(key)) {
retVal.put(key,null);
if (xmlDebug) {
System.out.println(" XML Key,Null Value: " + key);
}
retVal.put(key, null);
LOG_XML.debug(" XML Key,Null Value: " + key);
} else {
String value = conf.get(key);
if (value!=null) {
retVal.put(key,entry.getValue());
if (xmlDebug) {
System.out.println(" XML Key,Valid Value: " + key);
}
if (conf.get(key) != null) {
retVal.put(key, entry.getValue());
LOG_XML.debug(" XML Key,Valid Value: " + key);
}
}
kvItr.remove();
@ -353,12 +327,12 @@ public abstract class TestConfigurationFieldsBase {
* member variables from a Configuration type class.
*
* @param fields The class member variables
* @return HashMap containing <DefaultVariableName,DefaultValue> entries
* @return HashMap containing (DefaultVariableName, DefaultValue) entries
*/
private HashMap<String,String>
extractDefaultVariablesFromConfigurationFields(Field[] fields) {
// Sanity Check
if (fields==null) {
if (fields == null) {
return null;
}
@ -407,12 +381,11 @@ public abstract class TestConfigurationFieldsBase {
boolean bValue = (boolean) f.get(null);
retVal.put(f.getName(),Boolean.toString(bValue));
} else {
if (defaultDebug) {
System.out.println("Config variable " + f.getName() + " has unknown type " + f.getType().getName());
}
LOG.debug("Config variable {} has unknown type {}",
f.getName(), f.getType().getName());
}
} catch (IllegalAccessException iaException) {
iaException.printStackTrace();
LOG.error("{}", f, iaException);
}
}
}
@ -427,8 +400,9 @@ public abstract class TestConfigurationFieldsBase {
* @param keyMap2 The set to subtract
* @return Returns set operation keyMap1-keyMap2
*/
private static Set<String> compareConfigurationToXmlFields(Map<String,String> keyMap1, Map<String,String> keyMap2) {
Set<String> retVal = new HashSet<String>(keyMap1.keySet());
private static Set<String> compareConfigurationToXmlFields(
Map<String,String> keyMap1, Map<String,String> keyMap2) {
Set<String> retVal = new HashSet<>(keyMap1.keySet());
retVal.removeAll(keyMap2.keySet());
return retVal;
@ -443,60 +417,36 @@ public abstract class TestConfigurationFieldsBase {
initializeMemberVariables();
// Error if subclass hasn't set class members
assertTrue(xmlFilename!=null);
assertTrue(configurationClasses!=null);
assertNotNull(xmlFilename);
assertNotNull(configurationClasses);
// Create class member/value map
configurationMemberVariables = new HashMap<String,String>();
if (configDebug) {
System.out.println("Reading configuration classes");
System.out.println("");
}
configurationMemberVariables = new HashMap<>();
LOG_CONFIG.debug("Reading configuration classes\n");
for (Class c : configurationClasses) {
Field[] fields = c.getDeclaredFields();
Map<String,String> memberMap =
extractMemberVariablesFromConfigurationFields(fields);
if (memberMap!=null) {
if (memberMap != null) {
configurationMemberVariables.putAll(memberMap);
}
}
if (configDebug) {
System.out.println("");
System.out.println("=====");
System.out.println("");
}
LOG_CONFIG.debug("\n=====\n");
// Create XML key/value map
if (xmlDebug) {
System.out.println("Reading XML property files");
System.out.println("");
}
LOG_XML.debug("Reading XML property files\n");
xmlKeyValueMap = extractPropertiesFromXml(xmlFilename);
if (xmlDebug) {
System.out.println("");
System.out.println("=====");
System.out.println("");
}
LOG_XML.debug("\n=====\n");
// Create default configuration variable key/value map
if (defaultDebug) {
System.out.println("Reading Config property files for defaults");
System.out.println("");
}
configurationDefaultVariables = new HashMap<String,String>();
for (Class c : configurationClasses) {
Field[] fields = c.getDeclaredFields();
Map<String,String> defaultMap =
extractDefaultVariablesFromConfigurationFields(fields);
if (defaultMap!=null) {
configurationDefaultVariables.putAll(defaultMap);
}
}
if (defaultDebug) {
System.out.println("");
System.out.println("=====");
System.out.println("");
}
LOG.debug("Reading Config property files for defaults\n");
configurationDefaultVariables = new HashMap<>();
Arrays.stream(configurationClasses)
.map(Class::getDeclaredFields)
.map(this::extractDefaultVariablesFromConfigurationFields)
.filter(Objects::nonNull)
.forEach(map -> configurationDefaultVariables.putAll(map));
LOG.debug("\n=====\n");
// Find class members not in the XML file
configurationFieldsMissingInXmlFile = compareConfigurationToXmlFields
@ -514,17 +464,16 @@ public abstract class TestConfigurationFieldsBase {
@Test
public void testCompareConfigurationClassAgainstXml() {
// Error if subclass hasn't set class members
assertTrue(xmlFilename!=null);
assertTrue(configurationClasses!=null);
assertNotNull(xmlFilename);
assertNotNull(configurationClasses);
final int missingXmlSize = configurationFieldsMissingInXmlFile.size();
for (Class c : configurationClasses) {
System.out.println(c);
LOG.info(c.toString());
}
System.out.println(" (" + configurationMemberVariables.size() + " member variables)");
System.out.println();
StringBuffer xmlErrorMsg = new StringBuffer();
LOG.info("({} member variables)\n", configurationMemberVariables.size());
StringBuilder xmlErrorMsg = new StringBuilder();
for (Class c : configurationClasses) {
xmlErrorMsg.append(c);
xmlErrorMsg.append(" ");
@ -533,23 +482,33 @@ public abstract class TestConfigurationFieldsBase {
xmlErrorMsg.append(missingXmlSize);
xmlErrorMsg.append(" variables missing in ");
xmlErrorMsg.append(xmlFilename);
System.out.println(xmlErrorMsg.toString());
System.out.println();
if (missingXmlSize==0) {
System.out.println(" (None)");
LOG.error(xmlErrorMsg.toString());
if (missingXmlSize == 0) {
LOG.info(" (None)");
} else {
for (String missingField : configurationFieldsMissingInXmlFile) {
System.out.println(" " + missingField);
}
appendMissingEntries(xmlErrorMsg, configurationFieldsMissingInXmlFile);
}
System.out.println();
System.out.println("=====");
System.out.println();
LOG.info("\n=====\n");
if (errorIfMissingXmlProps) {
assertTrue(xmlErrorMsg.toString(), missingXmlSize==0);
assertEquals(xmlErrorMsg.toString(), 0, missingXmlSize);
}
}
/**
* Take a set of missing entries, sort, append to the string builder
* and also log at INFO.
* @param sb string builder
* @param missing set of missing entries
*/
private void appendMissingEntries(StringBuilder sb, Set<String> missing) {
sb.append(" Entries: ");
new TreeSet<>(missing).forEach(
(s) -> {
LOG.info(" {}", s);
sb.append(" ").append(s);
});
}
/**
* Compares the properties that are in the XML properties file, but not
* in the Configuration class.
@ -557,35 +516,28 @@ public abstract class TestConfigurationFieldsBase {
@Test
public void testCompareXmlAgainstConfigurationClass() {
// Error if subclass hasn't set class members
assertTrue(xmlFilename!=null);
assertTrue(configurationClasses!=null);
assertNotNull(xmlFilename);
assertNotNull(configurationClasses);
final int missingConfigSize = xmlFieldsMissingInConfiguration.size();
System.out.println("File " + xmlFilename + " (" + xmlKeyValueMap.size() + " properties)");
System.out.println();
StringBuffer configErrorMsg = new StringBuffer();
LOG.info("File {} ({} properties)", xmlFilename, xmlKeyValueMap.size());
StringBuilder configErrorMsg = new StringBuilder();
configErrorMsg.append(xmlFilename);
configErrorMsg.append(" has ");
configErrorMsg.append(missingConfigSize);
configErrorMsg.append(" properties missing in");
for (Class c : configurationClasses) {
configErrorMsg.append(" " + c);
}
System.out.println(configErrorMsg.toString());
System.out.println();
if (missingConfigSize==0) {
System.out.println(" (None)");
Arrays.stream(configurationClasses)
.forEach(c -> configErrorMsg.append(" ").append(c));
LOG.info(configErrorMsg.toString());
if (missingConfigSize == 0) {
LOG.info(" (None)");
} else {
for (String missingField : xmlFieldsMissingInConfiguration) {
System.out.println(" " + missingField);
}
appendMissingEntries(configErrorMsg, xmlFieldsMissingInConfiguration);
}
System.out.println();
System.out.println("=====");
System.out.println();
if ( errorIfMissingConfigProps ) {
assertTrue(configErrorMsg.toString(), missingConfigSize==0);
LOG.info("\n=====\n");
if (errorIfMissingConfigProps) {
assertEquals(configErrorMsg.toString(), 0, missingConfigSize);
}
}
@ -596,23 +548,23 @@ public abstract class TestConfigurationFieldsBase {
@Test
public void testXmlAgainstDefaultValuesInConfigurationClass() {
// Error if subclass hasn't set class members
assertTrue(xmlFilename!=null);
assertTrue(configurationMemberVariables!=null);
assertTrue(configurationDefaultVariables!=null);
assertNotNull(xmlFilename);
assertNotNull(configurationMemberVariables);
assertNotNull(configurationDefaultVariables);
HashSet<String> xmlPropertiesWithEmptyValue = new HashSet<String>();
HashSet<String> configPropertiesWithNoDefaultConfig = new HashSet<String>();
TreeSet<String> xmlPropertiesWithEmptyValue = new TreeSet<>();
TreeSet<String> configPropertiesWithNoDefaultConfig = new TreeSet<>();
HashMap<String,String> xmlPropertiesMatchingConfigDefault =
new HashMap<String,String>();
new HashMap<>();
// Ugly solution. Should have tuple-based solution.
HashMap<HashMap<String,String>,HashMap<String,String>> mismatchingXmlConfig =
new HashMap<HashMap<String,String>,HashMap<String,String>>();
HashMap<HashMap<String,String>, HashMap<String,String>> mismatchingXmlConfig
= new HashMap<>();
for (Map.Entry<String,String> xEntry : xmlKeyValueMap.entrySet()) {
String xmlProperty = xEntry.getKey();
String xmlDefaultValue = xEntry.getValue();
String configProperty = configurationMemberVariables.get(xmlProperty);
if (configProperty!=null) {
if (configProperty != null) {
String defaultConfigName = null;
String defaultConfigValue = null;
@ -624,7 +576,7 @@ public abstract class TestConfigurationFieldsBase {
String defaultNameCheck2 = null;
if (configProperty.endsWith("_KEY")) {
defaultNameCheck2 = configProperty
.substring(0,configProperty.length()-4) + "_DEFAULT";
.substring(0, configProperty.length() - 4) + "_DEFAULT";
}
String defaultValueCheck2 = configurationDefaultVariables
.get(defaultNameCheck2);
@ -634,115 +586,94 @@ public abstract class TestConfigurationFieldsBase {
.get(defaultNameCheck3);
// Pick the default value that exists
if (defaultValueCheck1!=null) {
if (defaultValueCheck1 != null) {
defaultConfigName = defaultNameCheck1;
defaultConfigValue = defaultValueCheck1;
} else if (defaultValueCheck2!=null) {
} else if (defaultValueCheck2 != null) {
defaultConfigName = defaultNameCheck2;
defaultConfigValue = defaultValueCheck2;
} else if (defaultValueCheck3!=null) {
} else if (defaultValueCheck3 != null) {
defaultConfigName = defaultNameCheck3;
defaultConfigValue = defaultValueCheck3;
}
if (defaultConfigValue!=null) {
if (xmlDefaultValue==null) {
if (defaultConfigValue != null) {
if (xmlDefaultValue == null) {
xmlPropertiesWithEmptyValue.add(xmlProperty);
} else if (!xmlDefaultValue.equals(defaultConfigValue)) {
HashMap<String,String> xmlEntry =
new HashMap<String,String>();
xmlEntry.put(xmlProperty,xmlDefaultValue);
HashMap<String,String> configEntry =
new HashMap<String,String>();
configEntry.put(defaultConfigName,defaultConfigValue);
mismatchingXmlConfig.put(xmlEntry,configEntry);
} else {
HashMap<String, String> xmlEntry = new HashMap<>();
xmlEntry.put(xmlProperty, xmlDefaultValue);
HashMap<String, String> configEntry = new HashMap<>();
configEntry.put(defaultConfigName, defaultConfigValue);
mismatchingXmlConfig.put(xmlEntry, configEntry);
} else {
xmlPropertiesMatchingConfigDefault
.put(xmlProperty, defaultConfigName);
}
} else {
configPropertiesWithNoDefaultConfig.add(configProperty);
}
} else {
}
}
// Print out any unknown mismatching XML value/Config default value
System.out.println(this.xmlFilename + " has " +
mismatchingXmlConfig.size() +
" properties that do not match the default Config value");
if (mismatchingXmlConfig.size()==0) {
System.out.println(" (None)");
LOG.info("{} has {} properties that do not match the default Config value",
xmlFilename, mismatchingXmlConfig.size());
if (mismatchingXmlConfig.isEmpty()) {
LOG.info(" (None)");
} else {
for (Map.Entry<HashMap<String,String>,HashMap<String,String>> xcEntry :
mismatchingXmlConfig.entrySet()) {
HashMap<String,String> xmlMap = xcEntry.getKey();
HashMap<String,String> configMap = xcEntry.getValue();
for (Map.Entry<String,String> xmlEntry : xmlMap.entrySet()) {
System.out.println(" XML Property: " + xmlEntry.getKey());
System.out.println(" XML Value: " + xmlEntry.getValue());
}
for (Map.Entry<String,String> configEntry : configMap.entrySet()) {
System.out.println(" Config Name: " + configEntry.getKey());
System.out.println(" Config Value: " + configEntry.getValue());
}
System.out.println("");
xcEntry.getKey().forEach((key, value) -> {
LOG.info("XML Property: {}", key);
LOG.info("XML Value: {}", value);
});
xcEntry.getValue().forEach((key, value) -> {
LOG.info("Config Name: {}", key);
LOG.info("Config Value: {}", value);
});
LOG.info("");
}
}
System.out.println();
LOG.info("\n");
// Print out Config properties that have no corresponding DEFAULT_*
// variable and cannot do any XML comparison (i.e. probably needs to
// be checked by hand)
System.out.println("Configuration(s) have " +
configPropertiesWithNoDefaultConfig.size() +
LOG.info("Configuration(s) have {} " +
" properties with no corresponding default member variable. These" +
" will need to be verified manually.");
if (configPropertiesWithNoDefaultConfig.size()==0) {
System.out.println(" (None)");
" will need to be verified manually.",
configPropertiesWithNoDefaultConfig.size());
if (configPropertiesWithNoDefaultConfig.isEmpty()) {
LOG.info(" (None)");
} else {
Iterator<String> cItr = configPropertiesWithNoDefaultConfig.iterator();
while (cItr.hasNext()) {
System.out.println(" " + cItr.next());
}
configPropertiesWithNoDefaultConfig.forEach(c -> LOG.info(" {}", c));
}
System.out.println();
LOG.info("\n");
// MAYBE TODO Print out any known mismatching XML value/Config default
// Print out XML properties that have empty values (i.e. should result
// in code-based default)
System.out.println(this.xmlFilename + " has " +
xmlPropertiesWithEmptyValue.size() + " properties with empty values");
if (xmlPropertiesWithEmptyValue.size()==0) {
System.out.println(" (None)");
LOG.info("{} has {} properties with empty values",
xmlFilename, xmlPropertiesWithEmptyValue.size());
if (xmlPropertiesWithEmptyValue.isEmpty()) {
LOG.info(" (None)");
} else {
Iterator<String> xItr = xmlPropertiesWithEmptyValue.iterator();
while (xItr.hasNext()) {
System.out.println(" " + xItr.next());
}
xmlPropertiesWithEmptyValue.forEach(p -> LOG.info(" {}", p));
}
System.out.println();
LOG.info("\n");
// Print out any matching XML value/Config default value
System.out.println(this.xmlFilename + " has " +
xmlPropertiesMatchingConfigDefault.size() +
" properties which match a corresponding Config variable");
if (xmlPropertiesMatchingConfigDefault.size()==0) {
System.out.println(" (None)");
LOG.info("{} has {} properties which match a corresponding Config variable",
xmlFilename, xmlPropertiesMatchingConfigDefault.size());
if (xmlPropertiesMatchingConfigDefault.isEmpty()) {
LOG.info(" (None)");
} else {
for (Map.Entry<String,String> xcEntry :
xmlPropertiesMatchingConfigDefault.entrySet()) {
System.out.println(" " + xcEntry.getKey() + " / " +
xcEntry.getValue());
}
xmlPropertiesMatchingConfigDefault.forEach(
(key, value) -> LOG.info(" {} / {}", key, value));
}
System.out.println();
// Test separator
System.out.println();
System.out.println("=====");
System.out.println();
LOG.info("\n=====\n");
}
/**
@ -754,8 +685,8 @@ public abstract class TestConfigurationFieldsBase {
@Test
public void testDefaultValueCollision() {
for (String filter : filtersForDefaultValueCollisionCheck) {
System.out.println("Checking if any of the default values whose name " +
"contains string \"" + filter + "\" collide.");
LOG.info("Checking if any of the default values whose name " +
"contains string \"{}\" collide.", filter);
// Map from filtered default value to name of the corresponding parameter.
Map<String, String> filteredValues = new HashMap<>();
@ -769,15 +700,14 @@ public abstract class TestConfigurationFieldsBase {
if (StringUtils.isNumeric(ent.getValue())) {
String crtValue =
filteredValues.putIfAbsent(ent.getValue(), ent.getKey());
assertTrue("Parameters " + ent.getKey() + " and " + crtValue +
" are using the same default value!", crtValue == null);
assertNull("Parameters " + ent.getKey() + " and " + crtValue +
" are using the same default value!", crtValue);
}
valuesChecked++;
}
}
System.out.println(
"Checked " + valuesChecked + " default values for collision.");
}
LOG.info("Checked {} default values for collision.", valuesChecked);
}