Commit 68a38c0c authored by Malo Toudic's avatar Malo Toudic
Browse files

run_instance + execution_list

git-svn-id: https://scm.gforge.inria.fr/authscm/ycadoret/svn/gazelle/Maven/simulators/gazelle-webservice-tester/trunk@60421 356b4b1a-1d2b-0410-8bf1-ffa24008f01e
parent 74530f71
......@@ -6,7 +6,8 @@ INSERT INTO app_configuration (id, variable, value) VALUES (nextval('app_configu
INSERT INTO app_configuration (id, variable, value) VALUES (nextval('app_configuration_id_seq'), 'documentation_url', 'http://gazelle.ihe.net');
INSERT INTO app_configuration (id, variable, value) VALUES (nextval('app_configuration_id_seq'), 'application_url', 'http://localhost:8180/gazelle-webservice-tester');
INSERT INTO app_configuration (id, variable, value) VALUES (nextval('app_configuration_id_seq'), 'cas_url', 'https://gazelle.ihe.net/cas');
INSERT INTO app_configuration (id, variable, value) VALUES (nextval('app_configuration_id_seq'), 'application_works_without_cas', 'false');
INSERT INTO app_configuration (id, variable, value)
VALUES (nextval('app_configuration_id_seq'), 'application_works_without_cas', 'true');
INSERT INTO app_configuration (id, variable, value) VALUES (nextval('app_configuration_id_seq'), 'ip_login', 'true');
INSERT INTO app_configuration (id, variable, value) VALUES (nextval('app_configuration_id_seq'), 'ip_login_admin', '.*');
INSERT INTO app_configuration (id, variable, value) VALUES (nextval('app_configuration_id_seq'), 'application_issue_tracker_url', 'link to issue tracker');
......@@ -18,4 +19,6 @@ INSERT INTO app_configuration (id, variable, value) VALUES (nextval('app_configu
INSERT INTO app_configuration (id, variable, value) VALUES (nextval('app_configuration_id_seq'), 'contact_name', 'Malo Toudic');
INSERT INTO app_configuration (id, variable, value) VALUES (nextval('app_configuration_id_seq'), 'contact_title', 'Application administrator');
INSERT INTO app_configuration (id, variable, value) VALUES (nextval('app_configuration_id_seq'), 'gazelle_sts_url', 'https://gazelle.ihe.net/picketlink-sts');
INSERT INTO app_configuration (id, variable, value) VALUES (nextval('app_configuration_id_seq'), 'project_directory', '/opt/gazelle/gwt/');
\ No newline at end of file
INSERT INTO app_configuration (id, variable, value) VALUES (nextval('app_configuration_id_seq'), 'project_directory', '/opt/gazelle/gwt/');
INSERT INTO app_configuration (id, variable, value)
VALUES (nextval('app_configuration_id_seq'), 'tm_domain', 'https://ehealthsuisse.ihe-europe.net/');
\ No newline at end of file
......@@ -165,8 +165,17 @@
<groupId>javafx</groupId>
<artifactId>jfxrt</artifactId>
</exclusion>
<exclusion>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
......@@ -178,5 +187,38 @@
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
<dependency>
<groupId>net.ihe.gazelle.simulators</groupId>
<artifactId>GazelleTRMClient</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.ihe.gazelle.simulators</groupId>
<artifactId>GazelleProxyClient</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.5</version>
</dependency>
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-parsers</artifactId>
<version>1.6</version>
<exclusions>
<exclusion>
<groupId>com.uwyn</groupId>
<artifactId>jhighlight</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.codelibs</groupId>
<artifactId>jhighlight</artifactId>
<version>1.0.2</version>
</dependency>
</dependencies>
</project>
package net.ihe.gazelle.wstester.action;
import net.ihe.gazelle.common.filter.Filter;
import net.ihe.gazelle.common.filter.FilterDataModel;
import net.ihe.gazelle.hql.criterion.HQLCriterionsForFilter;
import net.ihe.gazelle.hql.paths.HQLSafePathBasicNumber;
import net.ihe.gazelle.wstester.model.Execution;
import net.ihe.gazelle.wstester.model.ExecutionQuery;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import javax.faces.context.FacesContext;
import java.io.Serializable;
import java.util.Map;
@Name("executionList")
@Scope(ScopeType.PAGE)
public class ExecutionList implements Serializable {
private FilterDataModel<Execution> executions;
private Filter<Execution> filter;
public FilterDataModel<Execution> getExecutions() {
return new FilterDataModel<Execution>(getFilter()) {
@Override
protected Object getId(Execution execution) {
return execution.getId();
}
};
}
public Filter<Execution> getFilter() {
if (filter == null) {
Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
this.filter = new Filter(this.getHqlCriterions(), params);
}
return this.filter;
}
private HQLCriterionsForFilter getHqlCriterions() {
ExecutionQuery query = new ExecutionQuery();
HQLCriterionsForFilter criterion = query.getHQLCriterionsForFilter();
criterion.addPath("launchBy", query.launchBy());
criterion.addPath("launchDate", query.launchDate());
HQLSafePathBasicNumber instance = query.testInstanceResult().testInstance();
instance.setMinValue(0);
instance.setMaxValue(100000);
criterion.addPath("testInstance", instance);
return criterion;
}
public void reset() {
if (this.filter != null) {
this.filter.clear();
}
}
}
\ No newline at end of file
package net.ihe.gazelle.wstester.action;
import com.eviware.soapui.impl.wsdl.WsdlProject;
import com.eviware.soapui.impl.wsdl.WsdlTestSuite;
import com.eviware.soapui.impl.wsdl.support.wss.WssCrypto;
import com.eviware.soapui.impl.wsdl.support.wss.crypto.KeyMaterialWssCrypto;
import com.eviware.soapui.impl.wsdl.teststeps.WsdlMessageExchangeTestStepResult;
import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStepResult;
import com.eviware.soapui.impl.wsdl.teststeps.WsdlRunTestCaseTestStep;
import com.eviware.soapui.model.iface.MessageExchange;
import com.eviware.soapui.model.support.PropertiesMap;
import com.eviware.soapui.model.testsuite.TestCaseRunner;
import com.eviware.soapui.model.testsuite.TestStepResult;
import com.eviware.soapui.model.testsuite.TestSuiteRunner;
import com.eviware.soapui.model.testsuite.*;
import net.ihe.gazelle.common.tree.GazelleTreeNodeImpl;
import net.ihe.gazelle.simulator.common.tf.model.Transaction;
import net.ihe.gazelle.simulator.message.model.MessageInstance;
import net.ihe.gazelle.simulator.message.model.TransactionInstance;
import net.ihe.gazelle.ws.client.GazelleProxyWebServiceNameStub;
import net.ihe.gazelle.ws.client.GazelleTRMServiceStub;
import net.ihe.gazelle.wstester.dao.ExecutionDao;
import net.ihe.gazelle.wstester.dao.GwtTestStepDao;
import net.ihe.gazelle.wstester.dao.GwtTestSuiteDao;
import net.ihe.gazelle.wstester.dao.SoapuiProjectDao;
import net.ihe.gazelle.wstester.model.*;
import net.ihe.gazelle.wstester.util.Application;
import net.ihe.gazelle.wstester.wsAction.GazelleTRMCaller;
import net.ihe.gazelle.wstester.util.WsClient;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVRecord;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.Reader;
import java.io.Serializable;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
......@@ -40,6 +47,8 @@ public class RunSoapui implements Serializable {
private SoapuiProject currentProject = null;
private TestParameter currentNode = null;
private Execution execution = null;
private TestInstanceResult testInstanceResult = null;
private int testInstanceId;
public SoapuiProject getCurrentProject() {
RunSoapui.LOGGER.info("Get project");
......@@ -60,6 +69,35 @@ public class RunSoapui implements Serializable {
this.currentNode = currentNode;
}
public Execution getExecution() {
return execution;
}
public void setExecution(Execution execution) {
this.execution = execution;
}
public TestInstanceResult getTestInstanceResult() {
return testInstanceResult;
}
public void setTestInstanceResult(TestInstanceResult testInstanceResult) {
this.testInstanceResult = testInstanceResult;
}
public int getTestInstanceId() {
return testInstanceId;
}
public void setTestInstanceId(String testInstanceId) throws NumberFormatException {
this.testInstanceId = Integer.valueOf(testInstanceId); // Null check to be added
}
public void setTestInstanceId(int testInstanceId) {
this.testInstanceId = testInstanceId;
}
public List<SoapuiProject> getSoapuiProjects() {
return SoapuiProjectDao.getAllSoapuiProject();
}
......@@ -90,46 +128,42 @@ public class RunSoapui implements Serializable {
return wsdlProject;
}
public void runTestComponent() {
if (currentNode instanceof SoapuiProject) {
} else if (currentNode instanceof GwtTestSuite) {
runTestSuite(((GwtTestSuite) currentNode));
} else if (currentNode instanceof GwtTestCase) {
} else if (currentNode instanceof GwtTestStep) {
}
}
public void runTestSuite(GwtTestSuite testSuite) {
public void runTestInstance() {
List<GwtTestStepResult> gwtTestStepResultList = new ArrayList<>();
//List<ParameterUsed> parameterUsedList = new ArrayList<>();
execution = newExecution();
startExecution();
WsdlProject project = loadKeyStore();
if (project != null) {
TestSuiteRunner runner = project.getTestSuiteByName(testSuite.getLabel()).run(new PropertiesMap(), false);
WsdlTestSuite testSuite = project.getTestSuiteByName(testInstanceResult.getTestSuite().getLabel());
for (ParameterUsed parameterUsed : this.execution.getParametersUsed()) {
testSuite.setPropertyValue(parameterUsed.getParameter().getLabel(), parameterUsed.getValue());
}
testSuite.setAbortOnError(false);
testSuite.setFailOnErrors(false);
TestSuiteRunner runner = testSuite.run(new PropertiesMap(), false);
List<TestCaseRunner> listResult = runner.getResults();
for (TestCaseRunner results : listResult) {
for (TestStepResult result : results.getResults()) {
TransactionInstance transactionInstance = new TransactionInstance();
/*Domain domain = new Domain();
domain.setKeyword(getValueParamByName(result, "domain"));
transactionInstance.setDomain(domain);*/
Transaction transaction = new Transaction();
transaction.setKeyword(getValueParamByName(result, "transaction"));
transactionInstance.setTransaction(transaction);
if (result instanceof WsdlTestRequestStepResult) {
/*if (result instanceof WsdlTestRequestStepResult) {
gwtTestStepResultList.add(createGwtTestStepResult(result, transactionInstance, execution));
} else if (result instanceof WsdlMessageExchangeTestStepResult) {
} else*/
if (result instanceof WsdlMessageExchangeTestStepResult) {
if (result.getTestStep().getTestCase().getProperty("transaction") != null) {
Transaction transaction = new Transaction();
transaction.setKeyword(result.getTestStep().getTestCase().getProperty("transaction").getValue());
transactionInstance.setTransaction(transaction);
}
for (MessageExchange messageExchange : ((WsdlMessageExchangeTestStepResult) result).getMessageExchanges()) {
gwtTestStepResultList.add(createGwtTestStepResult((TestStepResult) messageExchange, transactionInstance, execution));
gwtTestStepResultList.add(createGwtTestStepResult(result, messageExchange, transactionInstance, execution));
}
}
}
......@@ -139,53 +173,142 @@ public class RunSoapui implements Serializable {
execution.setTestStepResults(gwtTestStepResultList);
}
public GwtTestStepResult createGwtTestStepResult(TestStepResult result, TransactionInstance transactionInstance, Execution execution) {
MessageExchange resultAsMessage = ((MessageExchange) result);
public GwtTestStepResult createGwtTestStepResult(TestStepResult result, MessageExchange messageExchange, TransactionInstance transactionInstance, Execution execution) {
/*MessageExchange resultAsMessage = ((MessageExchange) result);*/
MessageInstance request = new MessageInstance();
String requestContent = resultAsMessage.getRequestContent();
request.setContent(requestContent);
request.setContent(messageExchange.getRequestContent());
transactionInstance.setRequest(request);
MessageInstance response = new MessageInstance();
response.setContent(resultAsMessage.getResponseContent());
transactionInstance.setRequest(response);
return new GwtTestStepResult(result.getStatus().toString(), result.getTimeTaken(), transactionInstance, GwtTestStepDao.getGwtTestStep(result, currentProject.getLabel()), execution);
}
response.setContent(messageExchange.getResponseContent());
transactionInstance.setResponse(response);
public String getValueParamByName(TestStepResult result, String name) {
return result.getTestStep().getTestCase().getProperties().get(name).getValue();
return new GwtTestStepResult(result.getStatus().toString(), result.getTimeTaken(), transactionInstance, GwtTestStepDao.getGwtTestStep(result, this.currentProject.getLabel()), execution);
}
public Execution newExecution() {
Execution execution = new Execution();
public void startExecution() {
execution.setLaunchBy(Application.getUser());
execution.setLaunchDate(new Date());
return execution;
execution.setTestInstanceResult(this.testInstanceResult);
}
/*public List<ParameterUsed> getAllParameterUsed(TestParameter component){
List<ParameterUsed> parameterUsedList = new ArrayList<>();
public void createTestInstanceResult() {
GazelleTRMServiceStub.GetTestInstanceByIdResponse response = WsClient.getTestInstanceById(testInstanceId);
this.setTestInstanceResult(new TestInstanceResult(testInstanceId, GwtTestSuiteDao.getGwtTestSuite(response.getTestInstance().getTest().getKeyword(), currentProject.getLabel())));
}
public List<ParameterUsed> parameterMapToList(){
List<ParameterUsed> parameterUsedList = new ArrayList<>();
component.ge
}
public List<StepInfo> getSystemKeywordInfo(List<String> transactions) {
List<StepInfo> stepInfos = null;
try {
GazelleTRMServiceStub.GetTestInstanceByIdResponse response = WsClient.getTestInstanceById(testInstanceId);
stepInfos = new ArrayList<>();
GazelleTRMServiceStub.TrmTestStep[] trmTestSteps = response.getTestInstance().getTest().getTrmTestSteps();
for (GazelleTRMServiceStub.TrmTestStep trmTestStep : trmTestSteps) {
if (transactions.contains(trmTestStep.getTransaction())) {
StepInfo newStepInfo = new StepInfo(trmTestStep.getTransaction(), trmTestStep.getTestRoleResponderId());
newStepInfo.setTransactionUsage(trmTestStep.getWsTransactionUsage());
GazelleTRMServiceStub.TrmTestRole[] trmTestRoles = response.getTestInstance().getTest().getTrmTestRoles();
for (GazelleTRMServiceStub.TrmTestRole trmTestRole : trmTestRoles) {
if (newStepInfo.getTestRoleResponderId() == trmTestRole.getId()) {
newStepInfo.setParticipantRoleInTestId(trmTestRole.getRoleInTest().getId());
//newStepInfo.setRoleInTest(trmTestRole.getRoleInTest().getKeyword());
GazelleTRMServiceStub.TrmParticipant[] trmParticipants = response.getTestInstance().getParticipants();
for (GazelleTRMServiceStub.TrmParticipant trmParticipant : trmParticipants) {
if (newStepInfo.getParticipantRoleInTestId() == trmParticipant.getRoleInTestId()) {
newStepInfo.setSystemKeyword(trmParticipant.getSystem());
}
}
public void getParameterUserByComponent(TestParameter component){
}
}
}*/
stepInfos.add(newStepInfo);
}
}
public void callWS() {
try {
GazelleTRMCaller.getInstanceByIdCaller("36587").getSOAPBody();
} catch (Exception e) {
RunSoapui.LOGGER.error(e.getMessage());
}
return stepInfos;
}
public List<StepInfo> getEndPointBySystem(List<StepInfo> stepInfoList) {
List<String> systemList = new ArrayList<>();
for (StepInfo stepInfo : stepInfoList) {
if (!systemList.contains(stepInfo.getSystemKeyword())) {
systemList.add(stepInfo.getSystemKeyword());
}
}
for (String system : systemList) {
GazelleProxyWebServiceNameStub.ListConfigurationsBySystemBySessionByTypeAsCSVResponse response = WsClient.listConfigurationsBySystemBySessionByTypeAsCSV("Webservice", system, "1");
String responseAsCsv = response.get_return();
Reader in = new StringReader(responseAsCsv);
try {
Iterable<CSVRecord> records = CSVFormat.RFC4180.withFirstRecordAsHeader().parse(in);
for (CSVRecord record : records) {
String[] split = record.get("ws-type").split(":", 2);
for (StepInfo stepInfo : stepInfoList) {
if (stepInfo.getSystemKeyword().equals(system) && stepInfo.getTransaction().equals(split[0]) && stepInfo.getTransactionUsage().equals(split[1])) {
stepInfo.setEndpoint(record.get("url"));
}
}
}
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return stepInfoList;
}
public void getAllInfo() {
createTestInstanceResult();
execution = new Execution();
testInstanceResult.setExecution(execution);
initializeParameterUsed();
List<StepInfo> stepInfoList = getSystemKeywordInfo(retrieveTransaction());
stepInfoList = getEndPointBySystem(stepInfoList);
List<ParameterUsed> parameterUsedList = this.getTestInstanceResult().getExecution().getParametersUsed();
for (StepInfo stepInfo : stepInfoList) {
for (ParameterUsed parameterUsed : parameterUsedList) {
if (parameterUsed.getParameter().getLabel().equals(transactionToSoapProperty(stepInfo.getTransaction()))) {
parameterUsed.setValue(stepInfo.getEndpoint());
}
}
}
}
public List<String> retrieveTransaction() {
WsdlProject project = createWsdlProject();
List<String> transactions = new ArrayList<>();
if (project != null) {
List<TestCase> testCaseList = project.getTestSuiteByName(this.getTestInstanceResult().getTestSuite().getLabel()).getTestCaseList();
for (TestCase testCase : testCaseList) {
for (TestStep testStep : testCase.getTestStepList()) {
if (testStep instanceof WsdlRunTestCaseTestStep) {
transactions.add(((WsdlRunTestCaseTestStep) testStep).getTargetTestCase().getProperty("transaction").getValue());
}
testStep.getLabel();
}
}
}
return transactions;
}
public void initializeParameterUsed() {
List<ParameterUsed> parameterUsedList = new ArrayList<>();
for (Parameter parameter : this.getTestInstanceResult().getTestSuite().getParameters()) {
ParameterUsed parameterUsed = new ParameterUsed();
parameterUsed.setExecution(execution);
parameterUsed.setParameter(parameter);
parameterUsed.setValue(parameter.getDefaultValue());
parameterUsedList.add(parameterUsed);
}
execution.setParametersUsed(parameterUsedList);
}
public WsdlProject loadKeyStore() {
......@@ -202,11 +325,35 @@ public class RunSoapui implements Serializable {
return project;
}
public String transactionToSoapProperty(String transaction) {
switch (transaction) {
case "ITI-18":
return "endPointRegistry";
case "ITI-41":
return "endPointXDS";
case "ITI-43":
return "endPointRetrieve";
case "ITI-45":
return "endPointPIX";
case "ITI-47":
return "endPointPDQ";
case "ITI-62":
return "endPointDelete";
case "RAD-69":
return "endPointRetrieveImaging";
case "CH:XUA Get X-User Assertion":
return "endPointAssertions";
case "ITI-57":
return "endPointUpdate";
default:
return null;
}
}
public String redirectToResult() {
runTestComponent();
runTestInstance();
execution = ExecutionDao.mergeExecution(execution);
return "/executionResult.seam?id=" + execution.getId();
}
......
package net.ihe.gazelle.wstester.action;
public class StepInfo {
private String transaction;
private int testRoleResponderId;
private int participantRoleInTestId;
private String systemKeyword;
private String endpoint;
private String roleInTest;
private String transactionUsage;
public StepInfo(String transaction, int testRoleResponderId) {
this.transaction = transaction;
this.testRoleResponderId = testRoleResponderId;
}
public String getTransaction() {
return transaction;
}
public void setTransaction(String transaction) {
this.transaction = transaction;
}
public int getTestRoleResponderId() {
return testRoleResponderId;
}
public void setTestRoleResponderId(int testRoleResponderId) {
this.testRoleResponderId = testRoleResponderId;
}
public int getParticipantRoleInTestId() {
return participantRoleInTestId;
}
public void setParticipantRoleInTestId(int participantRoleInTestId) {
this.participantRoleInTestId = participantRoleInTestId;
}
public String getSystemKeyword() {
return systemKeyword;
}
public void setSystemKeyword(String systemKeyword) {
this.systemKeyword = systemKeyword;
}
public String getEndpoint() {
return endpoint;
}
public void setEndpoint(String endpoint) {
this.endpoint = endpoint;
}