use of com.twinsoft.convertigo.beans.variables.TestCaseVariable in project convertigo by convertigo.
the class DefaultInternalTranslator method buildInputDocument.
public void buildInputDocument(Context context, Object inputData) throws Exception {
Engine.logContext.debug("Making input document");
Map<String, Object> request = GenericUtils.cast(inputData);
InputDocumentBuilder inputDocumentBuilder = new InputDocumentBuilder(context);
// Indicates whether variable values were generated using strict mode or nor(text/childs only)
inputDocumentBuilder.transactionVariablesElement.setAttribute("strictMode", Boolean.toString(bStrictMode));
for (Entry<String, Object> entry : request.entrySet()) {
String parameterName = entry.getKey();
Object parameterObject = entry.getValue();
if (!inputDocumentBuilder.handleSpecialParameter(parameterName, parameterObject)) {
if (parameterObject instanceof String[]) {
inputDocumentBuilder.addVariable(parameterName, (String[]) parameterObject);
} else {
addParameterObject(context.inputDocument, inputDocumentBuilder.transactionVariablesElement, parameterName, parameterObject);
}
}
}
TestCase tc = TestCase.getTestCase(request, context.projectName);
if (tc != null) {
for (TestCaseVariable var : tc.getVariables()) {
String parameterName = var.getName();
Object parameterObject = var.getValueOrNull();
if (parameterObject == null) {
// ignore variables set to <null>
continue;
}
if (!request.containsKey(parameterName) && !inputDocumentBuilder.handleSpecialParameter(parameterName, parameterObject)) {
if (parameterObject instanceof XMLVector) {
String[] strings = ((XMLVector<?>) parameterObject).toArray(new String[0]);
inputDocumentBuilder.addVariable(parameterName, strings);
} else {
addParameterObject(context.inputDocument, inputDocumentBuilder.transactionVariablesElement, parameterName, parameterObject);
}
}
}
}
Engine.logContext.info("Input document created");
}
use of com.twinsoft.convertigo.beans.variables.TestCaseVariable in project convertigo by convertigo.
the class DefaultServletTranslator method buildInputDocument.
public void buildInputDocument(Context context, Object inputData) throws Exception {
Engine.logContext.debug("Making input document");
HttpServletRequest request = (HttpServletRequest) inputData;
InputDocumentBuilder inputDocumentBuilder = new InputDocumentBuilder(context);
// We transform the HTTP post data into XML data.
Enumeration<?> parameterNames = request.getParameterNames();
// Sometimes, because of a bug about bad recycling of request facade objects in Tomcat,
// the HTTP parameters parsing is not realized, and then parameterNames is empty. In
// such a case, a (bad) workaround is to decode by ourselves the query string in GET
// or the HTTP body in POST...
// Map<String, String[]> reparsedParameters = (Map<String, String[]>) request.getAttribute(ServletRequester.REPARSED_PARAMETERS_ATTRIBUTE);
// boolean bReparsedParameters = (reparsedParameters != null);
// if (bReparsedParameters) {
// parameterNames = reparsedParameters.keys();
// }
boolean isHandleComplex = "true".equals(request.getParameter("__handleComplex"));
while (parameterNames.hasMoreElements()) {
String parameterName = (String) parameterNames.nextElement();
String[] parameterValues = request.getParameterValues(parameterName);
if (!inputDocumentBuilder.handleSpecialParameter(parameterName, parameterValues)) {
inputDocumentBuilder.addVariable(parameterName, parameterValues, isHandleComplex);
}
}
TestCase tc = TestCase.getTestCase(request, context.projectName);
if (tc != null) {
for (TestCaseVariable var : tc.getVariables()) {
String parameterName = var.getName();
if (request.getParameter(parameterName) == null) {
Object parameterObject = var.getValueOrNull();
String[] parameterValues = (parameterObject instanceof XMLVector<?>) ? ((XMLVector<?>) parameterObject).toArray(new String[0]) : new String[] { (String) parameterObject };
if (!inputDocumentBuilder.handleSpecialParameter(parameterName, parameterValues)) {
inputDocumentBuilder.addVariable(parameterName, parameterValues, isHandleComplex);
}
}
}
}
Engine.logContext.debug("Input document created");
}
Aggregations