Commit d3628dcc authored by Nicolas Bailliet's avatar Nicolas Bailliet
Browse files

Revert to commit 64107 (undo XVal branch merge)

git-svn-id: https://scm.gforge.inria.fr/authscm/ycadoret/svn/gazelle/Maven/simulators/gazelle-webservice-tester/trunk@64336 356b4b1a-1d2b-0410-8bf1-ffa24008f01e
parent 8b46d33c
......@@ -45,7 +45,7 @@
<dependency>
<groupId>net.ihe.gazelle</groupId>
<artifactId>gazelle-evsclient-connector</artifactId>
<version>1.2.0-SNAPSHOT</version>
<version>1.1.19-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.ihe.gazelle.simulators</groupId>
......
......@@ -27,7 +27,7 @@ import java.util.List;
@Name("executionResult")
@Scope(ScopeType.PAGE)
public class ExecutionResult {
public class ExecutionResult {
private static final Logger LOG = LoggerFactory.getLogger(ExecutionResult.class);
private Execution execution;
......
package net.ihe.gazelle.wstester.action;
import net.ihe.gazelle.evsclient.connector.api.EVSClientResults;
import net.ihe.gazelle.evsclient.connector.api.EVSClientServletConnector;
import net.ihe.gazelle.hql.providers.EntityManagerService;
import net.ihe.gazelle.simulator.common.model.ApplicationConfiguration;
import net.ihe.gazelle.wstester.model.GwtProjectResult;
import net.ihe.gazelle.wstester.model.XValidationResult;
import net.ihe.gazelle.wstester.model.XValidatorInputInfo;
import org.apache.commons.httpclient.methods.multipart.Part;
import org.jboss.seam.faces.FacesMessages;
import org.jboss.seam.international.StatusMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.persistence.EntityManager;
import java.io.IOException;
import java.util.List;
import java.util.Map;
public class GwtProjectXValidation extends GwtValidation {
private static final Logger LOG = LoggerFactory.getLogger(GwtTestStepValidation.class);
private List<XValidatorInputInfo> xValidatorInputInfoList;
private String gwtProjectResultId;
private GwtProjectResult gwtProjectResultSelected;
private XValidationResult xvalidationResult;
public GwtProjectXValidation() {
}
public GwtProjectXValidation(GwtProjectResult gwtProjectResultSelected, String gwtProjectResultId, List<XValidatorInputInfo> xValidatorInputInfoList) {
this.gwtProjectResultSelected = gwtProjectResultSelected;
this.gwtProjectResultId = gwtProjectResultId;
this.xValidatorInputInfoList = xValidatorInputInfoList;
}
public void init() {
Map<String, String> urlParams = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
if (urlParams != null && urlParams.size() > 0) {
String externalId = urlParams.get("id");
EntityManager entityManager = EntityManagerService.provideEntityManager();
if (externalId != null) {
gwtProjectResultSelected = entityManager.find(GwtProjectResult.class, Integer.parseInt(externalId));
if (gwtProjectResultSelected == null) {
FacesMessages.instance().add(StatusMessage.Severity.ERROR, "The given id does not match any test step result in the " +
"database");
} else {
String xvalidationLogOid = EVSClientResults.getXValResultOidFromUrl(urlParams);
if (xvalidationLogOid != null) {
XValidationResult result = new XValidationResult(gwtProjectResultSelected, xvalidationLogOid);
gwtProjectResultSelected.setXvalidationResult(result);
getXValResultDetails(result);
}
gwtProjectResultSelected.save();
try {
String executionId = String.valueOf(gwtProjectResultSelected.getExecution().getId());
FacesContext.getCurrentInstance().getExternalContext().redirect("/gazelle-webservice-tester/executionResult.seam?id="
+ executionId);
} catch (IOException e) {
LOG.error(e.getMessage());
}
}
}
} else {
FacesMessages.instance().add(StatusMessage.Severity.ERROR, "The url used must have a problem, it is not possible to redirect to the " +
"execution test step.");
}
}
public void xvalidate() throws IOException {
String evsClientUrl = ApplicationConfiguration.getValueOfVariable("evs_client_url");
String toolOid = ApplicationConfiguration.getValueOfVariable("tool_instance_oid");
if (evsClientUrl == null) {
LOG.error("evs_client_url is missing in app_configuration table");
} else if (toolOid == null) {
LOG.error("tool_instance_oid is missing in app_configuration table");
} else {
ExternalContext extContext = FacesContext.getCurrentInstance().getExternalContext();
Part[] parts = createParts();
EVSClientServletConnector.sendToXValidationFromGWT(parts, extContext, evsClientUrl, toolOid, gwtProjectResultSelected.getXvalidatorOid(), String.valueOf(gwtProjectResultSelected.getId()));
}
}
private void getXValResultDetails(final XValidationResult result) {
String evsclientUrl = ApplicationConfiguration.getValueOfVariable("evs_client_url");
String xvalidationDate = EVSClientResults.getXValidationDate(result.getLogOid(), evsclientUrl);
result.setXvalidationDate(xvalidationDate);
String xvalidationStatus = EVSClientResults.getXValidationStatus(result.getLogOid(), evsclientUrl);
result.setXvalidationStatus(xvalidationStatus);
String linkToResult = EVSClientResults.getXValidationPermanentLink(result.getLogOid(), evsclientUrl);
result.setPermanentLink(linkToResult);
xvalidationResult = result.save();
}
public Part[] createParts() {
Part[] parts;
parts = new Part[xValidatorInputInfoList.size()];
if (xValidatorInputInfoList.size() != 0) {
for (int index = 0; index < xValidatorInputInfoList.size(); index++) {
//We give the keyword this time
parts[index] = EVSClientServletConnector.addToParts(xValidatorInputInfoList.get(index), xValidatorInputInfoList.get(index).getInputName());
}
return parts;
} else {
return null;
}
}
}
......@@ -6,9 +6,15 @@ import net.ihe.gazelle.evsclient.connector.model.EVSClientValidatedObject;
import net.ihe.gazelle.evsclient.connector.utils.PartSourceUtils;
import net.ihe.gazelle.hql.providers.EntityManagerService;
import net.ihe.gazelle.simulator.common.model.ApplicationConfiguration;
import net.ihe.gazelle.wstester.dao.ExecutionDao;
import net.ihe.gazelle.wstester.model.GwtTestStepResult;
import net.ihe.gazelle.wstester.model.ValidationResult;
import net.ihe.gazelle.wstester.model.XValidationResult;
import org.apache.commons.httpclient.methods.multipart.PartSource;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Create;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.faces.FacesMessages;
import org.jboss.seam.international.StatusMessage;
import org.slf4j.Logger;
......@@ -20,17 +26,26 @@ import javax.persistence.EntityManager;
import java.io.IOException;
import java.util.Map;
public class GwtTestStepValidation extends GwtValidation implements EVSClientValidatedObject {
@Name("messageValidation")
@Scope(ScopeType.PAGE)
public class GwtTestStepValidation implements EVSClientValidatedObject {
private static final Logger LOG = LoggerFactory.getLogger(GwtTestStepValidation.class);
private String gwtTestStepResultId;
private byte[] selectedMessage;
private byte[] xvalRequest;
private byte[] xvalResponse;
private GwtTestStepResult gwtTestStepResultSelected;
private String gwtTestStepXValOid;
private ValidationResult validationResult;
private XValidationResult xvalidationResult;
public GwtTestStepValidation() {
}
......@@ -41,6 +56,13 @@ public class GwtTestStepValidation extends GwtValidation implements EVSClientVal
this.selectedMessage = selectedMessage.clone();
}
//XValidation
public GwtTestStepValidation(String gwtTestStepResultId, byte[] request, byte[] response, String gwtTestStepXValOid) {
this.gwtTestStepResultId = gwtTestStepResultId;
this.xvalRequest = request;
this.xvalResponse = response;
this.gwtTestStepXValOid = gwtTestStepXValOid;
}
public byte[] getSelectedMessage() {
return selectedMessage;
......@@ -50,6 +72,22 @@ public class GwtTestStepValidation extends GwtValidation implements EVSClientVal
this.selectedMessage = selectedMessage.clone();
}
public byte[] getXvalRequest() {
return xvalRequest;
}
public void setXvalRequest(byte[] xvalRequest) {
this.xvalRequest = xvalRequest;
}
public byte[] getXvalResponse() {
return xvalResponse;
}
public void setXvalResponse(byte[] xvalResponse) {
this.xvalResponse = xvalResponse;
}
public String getGwtTestStepResultId() {
return gwtTestStepResultId;
}
......@@ -66,13 +104,38 @@ public class GwtTestStepValidation extends GwtValidation implements EVSClientVal
this.gwtTestStepResultSelected = gwtTestStepResultSelected;
}
public void init() {
public String getGwtTestStepXValOid() {
return gwtTestStepXValOid;
}
public void setGwtTestStepXValOid(String gwtTestStepXValOid) {
this.gwtTestStepXValOid = gwtTestStepXValOid;
}
public ValidationResult getValidationResult() {
return validationResult;
}
public void setValidationResult(ValidationResult validationResult) {
this.validationResult = validationResult;
}
public XValidationResult getXvalidationResult() {
return xvalidationResult;
}
public void setXvalidationResult(XValidationResult xvalidationResult) {
this.xvalidationResult = xvalidationResult;
}
@Create
public void initializePage() {
Map<String, String> urlParams = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
if (urlParams != null && urlParams.size() > 0) {
String[] parts = null;
//Validation process
if (urlParams.containsKey("id")) {
if (urlParams.containsKey("id") && !urlParams.containsKey("oidxvallog")) {
String externalId = ((String) urlParams.get("id"));
parts = externalId.split("_");
EntityManager entityManager = EntityManagerService.provideEntityManager();
......@@ -100,14 +163,33 @@ public class GwtTestStepValidation extends GwtValidation implements EVSClientVal
}
}
}
//X Validation process
else {
String externalId = urlParams.get("id");
EntityManager entityManager = EntityManagerService.provideEntityManager();
if (externalId != null) {
gwtTestStepResultSelected = entityManager.find(GwtTestStepResult.class, Integer.parseInt(externalId));
if (gwtTestStepResultSelected == null) {
FacesMessages.instance().add(StatusMessage.Severity.ERROR, "The given id does not match any test step result in the " +
"database");
} else {
String xvalidationOid = EVSClientResults.getXValResultOidFromUrl(urlParams);
if (xvalidationOid != null) {
XValidationResult result = new XValidationResult(gwtTestStepResultSelected, xvalidationOid);
gwtTestStepResultSelected.setXvalidationResult(result);
getXValResultDetails(result);
gwtTestStepResultSelected.save();
}
}
}
}
gwtTestStepResultSelected.save();
ExecutionDao.mergeExecution(gwtTestStepResultSelected.getExecution());
try {
if (gwtTestStepResultSelected != null) {
FacesContext.getCurrentInstance().getExternalContext().redirect("/gazelle-webservice-tester/executionResult.seam?id="
+ gwtTestStepResultSelected.getExecution().getId() + "&validation=" + urlParams.get("id"));
}
FacesContext.getCurrentInstance().getExternalContext().redirect("/gazelle-webservice-tester/executionResult.seam?id="
+ gwtTestStepResultSelected.getExecution().getId() + "&validation=" + urlParams.get("id"));
} catch (IOException e) {
LOG.error(e.getMessage());
}
......@@ -128,6 +210,17 @@ public class GwtTestStepValidation extends GwtValidation implements EVSClientVal
validationResult = result.save();
}
private void getXValResultDetails(final XValidationResult result) {
String evsclientUrl = ApplicationConfiguration.getValueOfVariable("evs_client_url");
String xvalidationDate = EVSClientResults.getXValidationDate(result.getLogOid(), evsclientUrl);
result.setXvalidationDate(xvalidationDate);
String xvalidationStatus = EVSClientResults.getXValidationStatus(result.getLogOid(), evsclientUrl);
result.setXvalidationStatus(xvalidationStatus);
String linkToResult = EVSClientResults.getXValidationPermanentLink(result.getLogOid(), evsclientUrl);
result.setPermanentLink(linkToResult);
xvalidationResult = result.save();
}
@Override
public String getUniqueKey() {
return gwtTestStepResultId;
......@@ -144,8 +237,8 @@ public class GwtTestStepValidation extends GwtValidation implements EVSClientVal
@Override
public PartSource getXValRequestPartSource() {
if (selectedMessage != null) {
return PartSourceUtils.buildEncoded64PartSource(selectedMessage, getType());
if (xvalRequest != null) {
return PartSourceUtils.buildEncoded64PartSource(xvalRequest, getType());
} else {
return null;
}
......@@ -153,8 +246,8 @@ public class GwtTestStepValidation extends GwtValidation implements EVSClientVal
@Override
public PartSource getXValResponsePartSource() {
if (selectedMessage != null) {
return PartSourceUtils.buildEncoded64PartSource(selectedMessage, getType());
if (xvalResponse != null) {
return PartSourceUtils.buildEncoded64PartSource(xvalResponse, getType());
} else {
return null;
}
......@@ -178,4 +271,21 @@ public class GwtTestStepValidation extends GwtValidation implements EVSClientVal
}
}
public void xvalidate() throws IOException {
String evsClientUrl = ApplicationConfiguration.getValueOfVariable("evs_client_url");
String toolOid = ApplicationConfiguration.getValueOfVariable("tool_instance_oid");
if (evsClientUrl == null) {
LOG.error("evs_client_url is missing in app_configuration table");
} else if (toolOid == null) {
LOG.error("tool_instance_oid is missing in app_configuration table");
} else {
ExternalContext extContext = FacesContext.getCurrentInstance().getExternalContext();
EVSClientServletConnector.sendToXValidation(this, extContext, evsClientUrl, toolOid, gwtTestStepXValOid);
}
}
}
package net.ihe.gazelle.wstester.action;
import net.ihe.gazelle.wstester.dao.ExecutionDao;
import net.ihe.gazelle.wstester.model.Execution;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Create;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import javax.faces.context.FacesContext;
import java.util.Map;
@Name("messageValidation")
@Scope(ScopeType.PAGE)
public class GwtValidation {
String id;
Execution execution;
GwtTestStepValidation gwtTestStepValidation;
GwtProjectXValidation gwtProjectXValidation;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Execution getExecution() {
return execution;
}
public void setExecution(Execution execution) {
this.execution = execution;
}
public GwtTestStepValidation getGwtTestStepValidation() {
return gwtTestStepValidation;
}
public void setGwtTestStepValidation(GwtTestStepValidation gwtTestStepValidation) {
this.gwtTestStepValidation = gwtTestStepValidation;
}
public GwtProjectXValidation getGwtProjectXValidation() {
return gwtProjectXValidation;
}
public void setGwtProjectXValidation(GwtProjectXValidation gwtProjectXValidation) {
this.gwtProjectXValidation = gwtProjectXValidation;
}
@Create
public void initializePage() {
Map<String, String> urlParams = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
if (urlParams != null && urlParams.size() > 0) {
if (urlParams.containsKey("id")) {
id = urlParams.get("id");
if (id != null) {
execution = ExecutionDao.getExecutionById(Integer.decode(id));
//Validation process
if (urlParams.containsKey("logoid")) {
//XValidation
gwtProjectXValidation = new GwtProjectXValidation();
gwtProjectXValidation.init();
} else {
//Validation
gwtTestStepValidation = new GwtTestStepValidation();
gwtTestStepValidation.init();
}
}
}
}
}
}
......@@ -9,7 +9,6 @@ import com.eviware.soapui.impl.wsdl.testcase.WsdlProjectRunner;
import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase;
import com.eviware.soapui.impl.wsdl.teststeps.RestRequestStepResult;
import com.eviware.soapui.impl.wsdl.teststeps.WsdlMessageExchangeTestStepResult;
import com.eviware.soapui.impl.wsdl.teststeps.WsdlPropertiesTestStep;
import com.eviware.soapui.impl.wsdl.teststeps.WsdlRunTestCaseTestStep;
import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStepResult;
import com.eviware.soapui.model.TestPropertyHolder;
......@@ -19,7 +18,6 @@ import com.eviware.soapui.model.iface.Response;
import com.eviware.soapui.model.support.PropertiesMap;
import com.eviware.soapui.model.testsuite.TestCase;
import com.eviware.soapui.model.testsuite.TestCaseRunner;
import com.eviware.soapui.model.testsuite.TestProperty;
import com.eviware.soapui.model.testsuite.TestRunner;
import com.eviware.soapui.model.testsuite.TestStep;
import com.eviware.soapui.model.testsuite.TestStepResult;
......@@ -42,8 +40,6 @@ import net.ihe.gazelle.wstester.model.CustomPropertyUsed;
import net.ihe.gazelle.wstester.model.Execution;
import net.ihe.gazelle.wstester.model.GwtAttachment;
import net.ihe.gazelle.wstester.model.GwtProject;
import net.ihe.gazelle.wstester.model.GwtProjectResult;
import net.ihe.gazelle.wstester.model.GwtProjectResultQuery;
import net.ihe.gazelle.wstester.model.GwtTestCase;
import net.ihe.gazelle.wstester.model.GwtTestStepResult;
import net.ihe.gazelle.wstester.model.GwtTestSuite;
......@@ -51,8 +47,6 @@ import net.ihe.gazelle.wstester.model.Keystore;
import net.ihe.gazelle.wstester.model.SoapuiProject;
import net.ihe.gazelle.wstester.model.TestComponent;
import net.ihe.gazelle.wstester.model.TestInstanceResult;
import net.ihe.gazelle.wstester.model.TestStepInfo;
import net.ihe.gazelle.wstester.model.XValidatorInputInfo;
import net.ihe.gazelle.wstester.model.TestStepType;
import net.ihe.gazelle.wstester.util.Application;
import net.ihe.gazelle.wstester.util.HibernateUtil;
......@@ -77,11 +71,7 @@ import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class RunInstanceAction {
private static final Logger LOG = LoggerFactory.getLogger(RunInstanceAction.class);
......@@ -181,7 +171,6 @@ public class RunInstanceAction {
if (!testCaseRunnerList.isEmpty()) {
List<GwtTestStepResult> gwtTestStepResultList = iterateThroughTestCaseRunnerList(testCaseRunnerList);
execution.setTestStepResults(gwtTestStepResultList);
execution.setProjectResults(currentProject.getGwtProject().getGwtProjectResults());
execution = ExecutionDao.mergeExecution(execution);
}
} else {
......@@ -204,7 +193,6 @@ public class RunInstanceAction {
gwtTestStepResultList = iterateThroughTestCaseRunnerList((List<TestCaseRunner>) (List<?>) testRunners);
}
execution.setTestStepResults(gwtTestStepResultList);
execution.setProjectResults(currentProject.getGwtProject().getGwtProjectResults());
execution = ExecutionDao.mergeExecution(execution);
}
moveLogs();
......@@ -212,9 +200,20 @@ public class RunInstanceAction {
}
public List<TestRunner> startExecution(WsdlProject project) {
// try {
// FileAppender fileAppender = new FileAppender();
// fileAppender.setName("ErrorTestFile");
// File file = new File("/tmp/test.log");
// boolean fileCreated = file.createNewFile();
// if (fileCreated) {
// fileAppender.setFile(file.getAbsolutePath(), false, false, 1024);
// SoapUI.getErrorLog().addAppender(fileAppender);
// }
// } catch (IOException e) {
// e.printStackTrace();
// }
List<TestRunner> listResult = new ArrayList<>();
Map<String, TestProperty> testProperties = project.getProperties();
detectOidsInProjectCustomProperties(currentProject.getGwtProject(), testProperties);
if (project != null) {
setCustomPropertiesInSoapUi(project);
if (currentProject.getKeystore() != null) {
......@@ -284,17 +283,6 @@ public class RunInstanceAction {
List<GwtTestStepResult> gwtTestStepResultList = new ArrayList<>();
for (TestCaseRunner results : listResult) {
List<WsdlPropertiesTestStep> propertiesTestSteps = results.getTestCase().getTestStepsOfType(WsdlPropertiesTestStep.class);
for (WsdlPropertiesTestStep propertytestStep : propertiesTestSteps) {
String propertyTestStepName = propertytestStep.getLabel();
if (propertyTestStepName.contains("xval_")) {
//We only keep the index in the property name
String xvalidatorIndex = propertyTestStepName.split("_")[1].split(" ")[0];
affectPropertiesToGwtProjectResult(propertytestStep, results, xvalidatorIndex);
}
}
for (TestStepResult result : results.getResults()) {
TransactionInstance transactionInstance = new TransactionInstance();
if (execution.getTestInstanceResult() != null) {
......@@ -322,11 +310,12 @@ public class RunInstanceAction {
} else if (result instanceof RestRequestStepResult) {