Commit ab035da8 authored by Malo Toudic's avatar Malo Toudic
Browse files

[GWT-64], [GWT-78], [GWT-53], [GWT-69]

git-svn-id: https://scm.gforge.inria.fr/authscm/ycadoret/svn/gazelle/Maven/simulators/gazelle-webservice-tester/trunk@61849 356b4b1a-1d2b-0410-8bf1-ffa24008f01e
parent c234fd22
......@@ -52,3 +52,8 @@ ALTER TABLE gwt_test_component
UPDATE gwt_test_component
SET executable = TRUE;
ALTER TABLE gwt_test_component
ADD COLUMN disable BOOLEAN;
UPDATE gwt_test_component
SET disable = FALSE;
......@@ -132,7 +132,7 @@
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.4.1208.jre7</version>
<version>42.2.1.jre7</version>
</dependency>
<dependency>
<groupId>net.ihe.gazelle.junit</groupId>
......@@ -190,7 +190,7 @@
<dependency>
<groupId>net.ihe.gazelle.maven</groupId>
<artifactId>GazelleTRMClient</artifactId>
<version>1.0.0</version>
<version>1.1.0-SNAPSHOT</version>
</dependency>
......
......@@ -66,26 +66,27 @@ public class CallingToolManager {
}
public void merge() {
List<CallingTool> callingToolList = CallingTool.getAllTool();
for (CallingTool callingTool : callingToolList) {
if (newCallingTool.getLabel().equals(callingTool.getLabel())) {
FacesMessages.instance().add(StatusMessage.Severity.ERROR, "There is already a calling tool with this name");
return;
} else if (newCallingTool.getOid().equals(callingTool.getOid())) {
FacesMessages.instance().add(StatusMessage.Severity.ERROR, "There is already a calling tool with this OID");
return;
} else if (newCallingTool.getUrl().equals(callingTool.getUrl())) {
FacesMessages.instance().add(StatusMessage.Severity.ERROR, "There is already a calling tool with this URL");
return;
}
}
newCallingTool.save();
merge(newCallingTool);
cancel();
}
public void addCallingTool(){
newCallingTool = new CallingTool();
addCallingTool = true;
public void merge(CallingTool callingToolToMerge) {
List<CallingTool> callingToolList = CallingTool.getAllTool();
if (callingToolList != null) {
for (CallingTool callingTool : callingToolList) {
if (callingToolToMerge.getLabel().equals(callingTool.getLabel()) && callingToolToMerge.getId() != callingTool.getId()) {
FacesMessages.instance().add(StatusMessage.Severity.ERROR, "There is already a calling tool with this name");
return;
} else if (callingToolToMerge.getOid().equals(callingTool.getOid()) && callingToolToMerge.getId() != callingTool.getId()) {
FacesMessages.instance().add(StatusMessage.Severity.ERROR, "There is already a calling tool with this OID");
return;
} else if (callingToolToMerge.getUrl().equals(callingTool.getUrl()) && callingToolToMerge.getId() != callingTool.getId()) {
FacesMessages.instance().add(StatusMessage.Severity.ERROR, "There is already a calling tool with this URL");
return;
}
}
}
callingToolToMerge.save();
}
public void cancel() {
......@@ -93,6 +94,11 @@ public class CallingToolManager {
addCallingTool = false;
}
public void addNewCallingTool() {
newCallingTool = new CallingTool();
addCallingTool = true;
}
public void reset() {
if (this.filter != null) {
this.filter.clear();
......
......@@ -45,6 +45,8 @@ public class ExecutionList implements Serializable {
criterion.addPath("launchBy", query.launchBy());
criterion.addPath("launchDate", query.launchDate());
criterion.addPath("company", query.company(), null, CompanyValueProvider.SINGLETON());
criterion.addPath("project", query.soapuiProject().label());
criterion.addPath("component", query.testComponent().label());
HQLSafePathBasicNumber instance = query.testInstanceResult().testInstance();
instance.setMinValue(0);
instance.setMaxValue(100000);
......
package net.ihe.gazelle.wstester.action;
import net.ihe.gazelle.common.tree.GazelleTreeNodeImpl;
import net.ihe.gazelle.wstester.dao.ExecutionDao;
import net.ihe.gazelle.wstester.dao.SoapuiProjectDao;
import net.ihe.gazelle.wstester.model.CustomProperty;
import net.ihe.gazelle.wstester.model.SoapuiProject;
import net.ihe.gazelle.wstester.model.TestComponent;
import net.ihe.gazelle.wstester.util.Tree;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Create;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import net.ihe.gazelle.wstester.util.Application;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ucar.units.Test;
import javax.faces.context.FacesContext;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ProjectDetail implements Serializable {
......@@ -50,4 +47,61 @@ public class ProjectDetail implements Serializable {
public void setCustomPropertyList(List<CustomProperty> customPropertyList) {
this.customPropertyList = customPropertyList;
}
public void setActive(boolean active) {
soapuiProject.setActive(active);
SoapuiProjectDao.mergeSoapuiProject(soapuiProject);
}
public String saveEditProject() {
SoapuiProject oldSoapuiProject = SoapuiProjectDao.getSoapuiProjectById(soapuiProject.getId());
if (!ExecutionDao.isProjectHaveBeenExecuted(oldSoapuiProject) || soapuiProject.getGwtProject().equals(oldSoapuiProject.getGwtProject())) {
SoapuiProjectDao.mergeSoapuiProject(soapuiProject);
} else {
int version;
Pattern regex = Pattern.compile("(.*_v)(\\d+)$");
Matcher matcher = regex.matcher(oldSoapuiProject.getLabel());
if (matcher.find()) {
version = newVersion(matcher.group(1), Integer.valueOf(matcher.group(2)));
oldSoapuiProject.setLabel(matcher.group(1) + version);
} else {
version = newVersion(oldSoapuiProject);
oldSoapuiProject.setLabel(oldSoapuiProject.getLabel() + "_v" + version);
}
oldSoapuiProject.setActive(false);
SoapuiProjectDao.mergeSoapuiProject(oldSoapuiProject);
soapuiProject.setId(null);
soapuiProject.setVersion(version);
soapuiProject.setCreationDate(new Date());
soapuiProject.setOwner(Application.getUser());
soapuiProject.setGwtProject(soapuiProject.getGwtProject().deepCopy());
soapuiProject.getGwtProject().setSoapuiProject(soapuiProject);
soapuiProject.setActive(true);
soapuiProject = SoapuiProjectDao.mergeSoapuiProject(soapuiProject);
}
return "/project/projectDetail.seam?id=" + soapuiProject.getId();
}
public int newVersion(SoapuiProject soapuiProject) {
int version = soapuiProject.getVersion();
while (true) {
String newLabel = soapuiProject.getLabel() + "_v" + version;
if (SoapuiProjectDao.getSoapuiProjectByLabel(newLabel) == null) {
return version;
}
version++;
}
}
public int newVersion(String label, Integer version) {
version++;
while (true) {
String newLabel = label + version;
if (SoapuiProjectDao.getSoapuiProjectByLabel(newLabel) == null) {
return version;
}
version++;
}
}
}
......@@ -3,13 +3,17 @@ 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.wstester.model.SoapuiProject;
import net.ihe.gazelle.wstester.model.SoapuiProjectQuery;
import net.ihe.gazelle.hql.providers.EntityManagerService;
import net.ihe.gazelle.wstester.dao.ExecutionDao;
import net.ihe.gazelle.wstester.model.*;
import org.jboss.seam.ScopeType;
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 javax.faces.context.FacesContext;
import javax.persistence.EntityManager;
import java.io.Serializable;
import java.util.Map;
......@@ -52,4 +56,45 @@ public class ProjectList implements Serializable {
this.filter.clear();
}
}
public boolean deleteProject(SoapuiProject project) {
if (ExecutionDao.isProjectHaveBeenExecuted(project) == true) {
FacesMessages.instance().add(StatusMessage.Severity.WARN, "This project have been executed : deletion impossible");
return false;
} else {
EntityManager entityManager = EntityManagerService.provideEntityManager();
for (GwtTestSuite gwtTestSuite : project.getGwtProject().getTestSuites()) {
for (GwtTestCase gwtTestCase : gwtTestSuite.getTestCases()) {
for (GwtTestStep gwtTestStep : gwtTestCase.getTestSteps()) {
deleteCustomProperties(gwtTestStep, entityManager);
entityManager.remove(gwtTestStep);
entityManager.flush();
}
deleteCustomProperties(gwtTestCase, entityManager);
entityManager.remove(gwtTestCase);
entityManager.flush();
}
deleteCustomProperties(gwtTestSuite, entityManager);
entityManager.remove(gwtTestSuite);
entityManager.flush();
}
deleteCustomProperties(project.getGwtProject(), entityManager);
entityManager.remove(project.getGwtProject());
entityManager.flush();
entityManager.remove(project);
entityManager.flush();
return true;
}
}
public void deleteCustomProperties(TestComponent testComponent, EntityManager entityManager) {
for (CustomProperty customProperty : testComponent.getCustomProperties()) {
for (CustomPropertyUsed customPropertyUsed : customProperty.getCustomPropertyUsedList()) {
entityManager.remove(customPropertyUsed);
entityManager.flush();
}
entityManager.remove(customProperty);
entityManager.flush();
}
}
}
\ No newline at end of file
package net.ihe.gazelle.wstester.action;
import com.eviware.soapui.SoapUI;
import com.eviware.soapui.impl.wsdl.WsdlProject;
import com.eviware.soapui.impl.wsdl.WsdlTestSuite;
import com.eviware.soapui.impl.wsdl.support.wss.WssCrypto;
......@@ -14,6 +15,7 @@ import com.eviware.soapui.model.iface.MessageExchange;
import com.eviware.soapui.model.support.PropertiesMap;
import com.eviware.soapui.model.testsuite.*;
import com.eviware.soapui.settings.HttpSettings;
import com.eviware.soapui.settings.SSLSettings;
import com.eviware.soapui.support.SoapUIException;
import net.ihe.gazelle.preferences.PreferenceService;
import net.ihe.gazelle.simulator.common.tf.model.Transaction;
......@@ -113,7 +115,6 @@ public class RunInstanceAction {
if (oldExecution.getTestInstanceResult() != null) {
TestInstanceResult newTestInstanceResult = initTestInstanceResultForReRun(oldExecution);
this.execution.setTestInstanceResult(newTestInstanceResult);
this.execution.setTestInstanceResult(newTestInstanceResult);
} else {
componentToExecute = oldExecution.getTestComponent();
}
......@@ -158,6 +159,7 @@ public class RunInstanceAction {
public Execution run() {
prepareExecution();
WsdlProject wsdlProject = createProjectWithKeyStore("soapui.jks", PreferenceService.getString("keystore_directory"));
//WsdlProject wsdlProject = createWsdlProject();
List<TestRunner> testRunners = startExecution(wsdlProject);
if (!testRunners.isEmpty()) {
List<GwtTestStepResult> gwtTestStepResultList;
......@@ -177,6 +179,7 @@ public class RunInstanceAction {
List<TestRunner> listResult = new ArrayList<>();
if (project != null) {
setCustomPropertiesInSoapUi(project);
addKeystores(execution.getKeystores());
project.getSettings().setBoolean(HttpSettings.RESPONSE_COMPRESSION, false);
if (componentToExecute instanceof GwtProject) {
project.setAbortOnError(false);
......@@ -184,6 +187,7 @@ public class RunInstanceAction {
listResult = (List<TestRunner>) (List<?>) runner.getResults();
} else if (componentToExecute instanceof GwtTestSuite) {
WsdlTestSuite testSuite = project.getTestSuiteByName(((GwtTestSuite) componentToExecute).getLabel());
project.getTestSuiteList();
testSuite.setAbortOnError(false);
testSuite.setFailOnErrors(false);
TestSuiteRunner runner = testSuite.run(new PropertiesMap(), false);
......@@ -269,7 +273,9 @@ public class RunInstanceAction {
if (PreferenceService.getString("logs_directory") != null) {
try {
String path = PreferenceService.getString("logs_directory") + this.execution.getId() + "/";
if (new File(path).mkdirs()) {
File file = new File(path);
file.mkdirs();
if (file.exists()) {
if (new File("soapui.log").exists()) {
Files.move(Paths.get("soapui.log"), Paths.get(path + "soapui.log"));
}
......@@ -320,10 +326,10 @@ public class RunInstanceAction {
}
public boolean createExecutionAndTestInstanceResult() {
GazelleTRMServiceStub.GetTestInstanceByIdResponse response = WsClient.getTestInstanceById(testInstanceId);
if (response != null) {
GazelleTRMServiceStub.TrmTestInstance testInstance = WsClient.getTestInstanceById(testInstanceId);
if (testInstance != null) {
execution = new Execution();
GwtTestSuite gwtTestSuite = GwtTestSuiteDao.getGwtTestSuite(response.getTestInstance().getTest().getKeyword(), currentProject.getLabel());
GwtTestSuite gwtTestSuite = GwtTestSuiteDao.getGwtTestSuite(testInstance.getTest().getKeyword(), currentProject.getLabel());
if (gwtTestSuite != null) {
execution.setTestInstanceResult(new TestInstanceResult(testInstanceId, gwtTestSuite));
execution.getTestInstanceResult().setExecution(execution);
......@@ -344,10 +350,9 @@ public class RunInstanceAction {
public List<StepInfo> getSystemKeywordInfo(List<String> transactions) {
List<StepInfo> stepInfos = null;
try {
GazelleTRMServiceStub.GetTestInstanceByIdResponse response = WsClient.getTestInstanceById(testInstanceId);
GazelleTRMServiceStub.TrmTestInstance trmTestInstance = WsClient.getTestInstanceById(testInstanceId);
stepInfos = new ArrayList<>();
GazelleTRMServiceStub.TrmTestInstance trmTestInstance = response.getTestInstance();
execution.getTestInstanceResult().setLastStatus(trmTestInstance.getLastStatus());
GazelleTRMServiceStub.TrmTest trmTest = trmTestInstance.getTest();
......@@ -361,13 +366,13 @@ public class RunInstanceAction {
newStepInfo.setTestRoleInitiatorId(trmTestStep.getTestRoleInitiatorId());
newStepInfo.setTransactionUsage(trmTestStep.getWsTransactionUsage());
GazelleTRMServiceStub.TrmTestRole[] trmTestRoles = response.getTestInstance().getTest().getTrmTestRoles();
GazelleTRMServiceStub.TrmTestRole[] trmTestRoles = trmTestInstance.getTest().getTrmTestRoles();
for (GazelleTRMServiceStub.TrmTestRole trmTestRole : trmTestRoles) {
if ((trmTestRole.getRoleInTest().getKeyword().substring(0, 2).equals("CC") || trmTestRole.getRoleInTest().getKeyword().substring(0, 2).equals("SS")) && newStepInfo.getTestRoleResponderId() == trmTestRole.getId()) {
newStepInfo.setParticipantRoleInTestId(trmTestRole.getRoleInTest().getId());
newStepInfo.setRoleInTest(trmTestRole.getRoleInTest().getKeyword());
GazelleTRMServiceStub.TrmParticipant[] trmParticipants = response.getTestInstance().getParticipants();
GazelleTRMServiceStub.TrmParticipant[] trmParticipants = trmTestInstance.getParticipants();
for (GazelleTRMServiceStub.TrmParticipant trmParticipant : trmParticipants) {
if (newStepInfo.getParticipantRoleInTestId() == trmParticipant.getRoleInTestId()) {
newStepInfo.setResponderSystemKeyword(trmParticipant.getSystem());
......@@ -560,6 +565,18 @@ public class RunInstanceAction {
return project;
}
public void addKeystores(List<Keystore> keystoreList) {
if (keystoreList != null) {
for (Keystore keystore : keystoreList) {
SoapUI.getSettings().setString(SSLSettings.KEYSTORE, keystore.getPath());
if (keystore.getPassword() != null) {
SoapUI.getSettings().setString(SSLSettings.KEYSTORE_PASSWORD, keystore.getPassword());
}
}
SoapUI.getSettings().setBoolean(HttpSettings.AUTHENTICATE_PREEMPTIVELY, true);
}
}
public boolean customPropertiesToModifyNull() {
boolean propertiesToModifyNull = true;
if (currentProject.getGwtProject().getCustomPropertiesToModify().size() > 0) {
......
......@@ -156,44 +156,45 @@ public class UploadProject implements Serializable {
List<TestSuite> testSuites = project.getTestSuiteList();
List<GwtTestSuite> gwtTestSuites = new ArrayList<>();
for (TestSuite suite : testSuites) {
if (!suite.isDisabled()) {
suite.getProject().getName();
GwtTestSuite gwtTestSuite = new GwtTestSuite();
gwtTestSuite.setLabel(suite.getName());
gwtTestSuite.setProject(gwtProject);
testProperties = suite.getProperties();
gwtTestSuite.setCustomProperties(updateCustomProperties(testProperties, gwtTestSuite));
List<TestCase> testCases = suite.getTestCaseList();
List<GwtTestCase> gwtTestCases = new ArrayList<>();
for (TestCase testCase : testCases) {
if (!testCase.isDisabled()) {
GwtTestCase gwtTestCase = new GwtTestCase();
gwtTestCase.setLabel(testCase.getName());
gwtTestCase.setTestSuite(gwtTestSuite);
testProperties = testCase.getProperties();
gwtTestCase.setCustomProperties(updateCustomProperties(testProperties, gwtTestCase));
List<TestStep> testSteps = testCase.getTestStepList();
List<GwtTestStep> gwtTestSteps = new ArrayList<>();
for (TestStep testStep : testSteps) {
if (!testCase.isDisabled()) {
GwtTestStep gwtTestStep = new GwtTestStep();
gwtTestStep.setLabel(testStep.getName());
gwtTestStep.setTestCase(gwtTestCase);
gwtTestSteps.add(gwtTestStep);
}
}
gwtTestCase.setTestSteps(gwtTestSteps);
gwtTestCases.add(gwtTestCase);
}
suite.getProject().getName();
GwtTestSuite gwtTestSuite = new GwtTestSuite();
gwtTestSuite.setLabel(suite.getName());
gwtTestSuite.setProject(gwtProject);
gwtTestSuite.setDisable(suite.isDisabled());
testProperties = suite.getProperties();
gwtTestSuite.setCustomProperties(updateCustomProperties(testProperties, gwtTestSuite));
List<TestCase> testCases = suite.getTestCaseList();
List<GwtTestCase> gwtTestCases = new ArrayList<>();
for (TestCase testCase : testCases) {
GwtTestCase gwtTestCase = new GwtTestCase();
gwtTestCase.setLabel(testCase.getName());
gwtTestCase.setTestSuite(gwtTestSuite);
gwtTestCase.setDisable(testCase.isDisabled());
testProperties = testCase.getProperties();
gwtTestCase.setCustomProperties(updateCustomProperties(testProperties, gwtTestCase));
List<TestStep> testSteps = testCase.getTestStepList();
List<GwtTestStep> gwtTestSteps = new ArrayList<>();
for (TestStep testStep : testSteps) {
GwtTestStep gwtTestStep = new GwtTestStep();
gwtTestStep.setLabel(testStep.getName());
gwtTestStep.setTestCase(gwtTestCase);
gwtTestStep.setDisable(testStep.isDisabled());
gwtTestSteps.add(gwtTestStep);
}
gwtTestSuite.setTestCases(gwtTestCases);
gwtTestSuites.add(gwtTestSuite);
gwtTestCase.setTestSteps(gwtTestSteps);
gwtTestCases.add(gwtTestCase);
}
gwtTestSuite.setTestCases(gwtTestCases);
gwtTestSuites.add(gwtTestSuite);
}
gwtProject.setTestSuites(gwtTestSuites);
soapuiProject.setGwtProject(gwtProject);
} else {
......@@ -228,6 +229,10 @@ public class UploadProject implements Serializable {
this.uploadedFile = null;
}
public void setMessageInvalidFileType() {
FacesMessages.instance().add(StatusMessage.Severity.ERROR, "Invalid file type. Expected file type is xml");
}
public String redirectToDetail() {
if (checkLabelInDb()) {
this.moveTmpFile();
......
......@@ -2,14 +2,11 @@ package net.ihe.gazelle.wstester.bean;
import net.ihe.gazelle.wstester.action.ProjectDetail;
import net.ihe.gazelle.wstester.dao.SoapuiProjectDao;
import net.ihe.gazelle.wstester.model.SoapuiProject;
import net.ihe.gazelle.wstester.util.Tree;
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;
import org.slf4j.LoggerFactory;
......@@ -51,24 +48,12 @@ public class ProjectDetailBean {
this.projectDetail = projectDetail;
}
private boolean checkLabelInDb() {
SoapuiProject soapuiProject = SoapuiProjectDao.getSoapuiProjectByLabel(projectDetail.getSoapuiProject().getLabel());
if (soapuiProject != null) {
if (soapuiProject.getId() != projectDetail.getSoapuiProject().getId()) {
FacesMessages.instance().add(StatusMessage.Severity.ERROR, "There is already a SoapUI project with the same label : " + projectDetail.getSoapuiProject().getLabel());
return false;
}
}
return true;
}
public void saveEditProject() {
if (checkLabelInDb()) {
SoapuiProject soapuiProject = SoapuiProjectDao.mergeSoapuiProject(projectDetail.getSoapuiProject());
editProject = false;
}
projectDetail.saveEditProject();
editProject = false;
}
public String cancel() {
return "/project/projectDetail.seam?id=" + projectDetail.getSoapuiProject().getId();
}
......
package net.ihe.gazelle.wstester.bean;
import net.ihe.gazelle.common.tree.GazelleTreeNodeImpl;
import net.ihe.gazelle.preferences.PreferenceService;
import net.ihe.gazelle.wstester.action.RunInstanceAction;
import net.ihe.gazelle.wstester.dao.SoapuiProjectDao;
import net.ihe.gazelle.wstester.model.Execution;
import net.ihe.gazelle.wstester.model.TestComponent;
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.util.Tree;
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.richfaces.event.FileUploadEvent;
import org.richfaces.event.TreeSelectionChangeEvent;
import org.richfaces.model.UploadedFile;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.faces.event.AjaxBehaviorEvent;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.Serializable;
import java.util.List;
import java.util.UUID;
@Name("runSoapui")
@Scope(ScopeType.PAGE)
......@@ -98,12 +109,18 @@ public class RunInstanceBean implements Serializable {
return Tree.getComponentAsTree(getCurrentProject().getGwtProject(), false);
}
public void resetSimple() {
public void reset() {
runInstance = false;
runInstanceAction = new RunInstanceAction();
setExecution(new Execution());
}
public void softReset(AjaxBehaviorEvent event) {
runInstance = false;