use of com.axway.ats.config.exceptions.ConfigurationException in project ats-framework by Axway.
the class VerificationSkeleton method verify.
/**
* Verify that all rules match using the given expected result
*
* @param expectedResult the expected result
* @param endOnFirstMatch end on first match or keep testing until all polling attempts are exhausted
* @param endOnFirstFailure end or first failure or keep testing until all polling attempts are exhausted
*
* @return the matched meta data
* @throws RbvException on error doing the verifications
*/
protected List<MetaData> verify(boolean expectedResult, boolean endOnFirstMatch, boolean endOnFirstFailure) throws RbvException {
try {
this.executor.setRootRule(this.rootRule);
applyConfigurationSettings();
Monitor monitor = new Monitor(getMonitorName(), this.folder, this.executor, new PollingParameters(pollingInitialDelay, pollingInterval, pollingAttempts), expectedResult, endOnFirstMatch, endOnFirstFailure);
ArrayList<Monitor> monitors = new ArrayList<Monitor>();
monitors.add(monitor);
// run the actual evaluation
String evaluationProblem = new SimpleMonitorListener(monitors).evaluateMonitors(pollingTimeout);
if (!StringUtils.isNullOrEmpty(evaluationProblem)) {
throw new RbvVerificationException("Verification failed - " + monitor.getLastError());
}
return monitor.getAllMatchedMetaData();
} catch (ConfigurationException ce) {
throw new RbvException("RBV configuration error", ce);
}
}
use of com.axway.ats.config.exceptions.ConfigurationException in project ats-framework by Axway.
the class TestHarnessConfigurator method reloadData.
@Override
protected void reloadData() {
String propertyDataProviderString = getProperty(PROPERTY_DATA_PROVIDER);
try {
propertyDataProvider = Enum.valueOf(DataProviderType.class, propertyDataProviderString.toUpperCase());
} catch (IllegalArgumentException iae) {
throw new ConfigurationException("Data provider '" + propertyDataProviderString + "' is not supported");
}
propertyTestcasesRoot = getProperty(PROPERTY_TEST_CASES_DIRECTORY);
}
use of com.axway.ats.config.exceptions.ConfigurationException in project ats-framework by Axway.
the class ConfigurationResource method loadFromXmlFile.
public void loadFromXmlFile(InputStream resourceStream, String resourceIdentifier) {
try {
DOMParser parser = new DOMParser();
// Required settings from the DomParser
// otherwise
parser.setFeature("http://apache.org/xml/features/dom/defer-node-expansion", false);
parser.setFeature("http://apache.org/xml/features/continue-after-fatal-error", true);
parser.setFeature("http://apache.org/xml/features/allow-java-encodings", true);
parser.parse(new InputSource(resourceStream));
Document doc = parser.getDocument();
Element rootElement = doc.getDocumentElement();
// cleanup the properties
properties.clear();
// init the current element path
LinkedList<String> currentElementPath = new LinkedList<String>();
// start reading the DOM
NodeList rootElementChildren = rootElement.getChildNodes();
for (int i = 0; i < rootElementChildren.getLength(); i++) {
Node rootElementChild = rootElementChildren.item(i);
if (rootElementChild.getNodeType() == Node.ELEMENT_NODE) {
readXmlElement(currentElementPath, (Element) rootElementChild);
}
}
} catch (SAXException e) {
throw new ConfigurationException("Error while parsing config file '" + resourceIdentifier + "'", e);
} catch (IOException ioe) {
throw new ConfigurationException("Error while parsing config file '" + resourceIdentifier + "'", ioe);
}
}
use of com.axway.ats.config.exceptions.ConfigurationException in project ats-framework by Axway.
the class ConfigurationRepository method createConfigurationResourceFromStream.
/**
* Create a new configuration resource based on a given configuration file
*
* @param configFile the configuration file
* @return a config resource based on the file type
*/
private ConfigurationResource createConfigurationResourceFromStream(InputStream resourceStream, String resourceIdentifier) {
ConfigurationResource configResource;
if (resourceIdentifier.endsWith(".xml")) {
configResource = new ConfigurationResource();
configResource.loadFromXmlFile(resourceStream, resourceIdentifier);
return configResource;
} else if (resourceIdentifier.endsWith(".properties")) {
configResource = new ConfigurationResource();
configResource.loadFromPropertiesFile(resourceStream, resourceIdentifier);
return configResource;
} else {
throw new ConfigurationException("Not supported file extension. We expect either 'xml' or 'properties': " + resourceIdentifier);
}
}
use of com.axway.ats.config.exceptions.ConfigurationException in project ats-framework by Axway.
the class BoxesMap method setPropertyUsingSetter.
/**
* Try to find a setter for this property and set it
*
* @param box the box instance
* @param key the property key
* @param value the property value
* @return boolean if setter was found and successfully invoked, false if not suitable
* setter was found
*/
private boolean setPropertyUsingSetter(String boxName, Box box, String key, String value) {
Method[] boxClassMethods = box.getClass().getDeclaredMethods();
for (Method boxClassMethod : boxClassMethods) {
String methodName = boxClassMethod.getName();
String setterName = "set" + key;
// user errors in configuration files
if (!methodName.equalsIgnoreCase(setterName)) {
continue;
}
// check if the setter has the right number of arguments
Class<?>[] parameterTypes = boxClassMethod.getParameterTypes();
if (parameterTypes.length != 1 || parameterTypes[0] != String.class) {
continue;
}
String methodDescription = boxName + "." + boxClassMethod.getName() + "( '" + value + "' )";
try {
boxClassMethod.invoke(box, new Object[] { value });
return true;
} catch (IllegalArgumentException e) {
throw new ConfigurationException("Could not invoke setter " + methodDescription, e);
} catch (IllegalAccessException e) {
throw new ConfigurationException("Could not invoke setter " + methodDescription, e);
} catch (InvocationTargetException e) {
throw new ConfigurationException("Could not invoke setter " + methodDescription, e);
}
}
return false;
}
Aggregations