
org.apache.openejb.arquillian.common.ConfigurationOverrides Maven / Gradle / Ivy
The newest version!
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
package org.apache.openejb.arquillian.common;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* @version $Rev$ $Date$
*/
public class ConfigurationOverrides {
protected static final Logger LOGGER = Logger.getLogger(TomEEContainer.class.getName());
public static List apply(final Object configuration, final Properties systemProperties, final String... prefixes) {
final List propertiesFiles = findPropertiesFiles("default.arquillian-%s.properties", prefixes);
if (!propertiesFiles.isEmpty()) {
apply(configuration, systemProperties, propertiesFiles, false, prefixes);
}
final List overridePropFiles = findPropertiesFiles("arquillian-%s.properties", prefixes);
if (!overridePropFiles.isEmpty()) {
apply(configuration, systemProperties, overridePropFiles, true, prefixes);
}
propertiesFiles.addAll(overridePropFiles);
// use system properties in all cases
apply(configuration, systemProperties, Collections.emptyList(), true, prefixes);
return propertiesFiles;
}
public static void apply(final Object configuration, final Properties systemProperties, final List urls, final boolean overrideNotNull, final String... prefixes) {
final List propertiesList = read(urls);
final Properties defaults = new Properties();
// Merge all the properties
for (final Properties p : propertiesList) {
defaults.putAll(p);
}
final ObjectMap map = new ObjectMap(configuration);
for (final Map.Entry
© 2015 - 2025 Weber Informatics LLC | Privacy Policy