Commit 6f8aad73 authored by Malo Toudic's avatar Malo Toudic
Browse files
parents ac779a2c 5e22cfcf
......@@ -157,7 +157,7 @@
</dependency>
<dependency>
<groupId>com.smartbear.soapui</groupId>
<artifactId>soapui</artifactId>
<artifactId>soapui</artifactId>
<version>5.3.0</version>
<exclusions>
<exclusion>
......
......@@ -5,6 +5,7 @@ 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.dao.CompanyValueProvider;
import net.ihe.gazelle.wstester.dao.ExecutionDao;
import net.ihe.gazelle.wstester.model.Execution;
import net.ihe.gazelle.wstester.model.ExecutionQuery;
import org.jboss.seam.ScopeType;
......@@ -59,4 +60,10 @@ public class ExecutionList implements Serializable {
this.filter.clear();
}
}
public void refreshStatus() {
for (Execution execution : ExecutionDao.getAllExecution()) {
ExecutionDao.mergeExecution(execution);
}
}
}
\ No newline at end of file
......@@ -6,6 +6,7 @@ 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;
......@@ -184,6 +185,8 @@ public class GwtTestStepValidation implements EVSClientValidatedObject {
}
}
ExecutionDao.mergeExecution(gwtTestStepResultSelected.getExecution());
try {
FacesContext.getCurrentInstance().getExternalContext().redirect("/gazelle-webservice-tester/executionResult.seam?id="
+ gwtTestStepResultSelected.getExecution().getId() + "&validation=" + urlParams.get("id"));
......
......@@ -10,7 +10,6 @@ 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.WsdlRunTestCaseTestStep;
import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep;
import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStepResult;
import com.eviware.soapui.model.TestPropertyHolder;
import com.eviware.soapui.model.iface.Attachment;
......@@ -50,10 +49,12 @@ import net.ihe.gazelle.wstester.model.TestComponent;
import net.ihe.gazelle.wstester.model.TestInstanceResult;
import net.ihe.gazelle.wstester.model.TestStepType;
import net.ihe.gazelle.wstester.util.Application;
import net.ihe.gazelle.wstester.util.HibernateUtil;
import net.ihe.gazelle.wstester.util.WsClient;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVRecord;
import org.apache.xmlbeans.XmlException;
import org.hibernate.Hibernate;
import org.jboss.seam.faces.FacesMessages;
import org.jboss.seam.international.StatusMessage;
import org.slf4j.Logger;
......@@ -221,6 +222,7 @@ public class RunInstanceAction {
addKeystore(KeystoreDao.getDefaultKeystore());
}
project.getSettings().setBoolean(HttpSettings.RESPONSE_COMPRESSION, false);
componentToExecute = HibernateUtil.initializeAndUnproxy(componentToExecute);
if (componentToExecute instanceof GwtProject) {
project.setAbortOnError(false);
WsdlProjectRunner runner = project.run(new PropertiesMap(), false);
......@@ -246,6 +248,7 @@ public class RunInstanceAction {
public void setCustomPropertiesInSoapUi(WsdlProject project) {
for (CustomPropertyUsed customPropertyUsed : execution.getCustomPropertiesUsed()) {
TestComponent testComponent = customPropertyUsed.getCustomProperty().getTestComponent();
testComponent = HibernateUtil.initializeAndUnproxy(testComponent);
if (testComponent instanceof GwtProject) {
project.getProperties().get(customPropertyUsed.getCustomProperty().getLabel()).setValue(customPropertyUsed.getValue());
} else if (testComponent instanceof GwtTestSuite) {
......@@ -349,11 +352,7 @@ public class RunInstanceAction {
transactionInstance.setRequest(request);
LOG.info("Request : " + messageExchange.getRequestContent());
WsdlTestRequestStep testStep = (WsdlTestRequestStep) result.getTestStep();
Attachment[] attachments = testStep.getTestRequest().getAttachments();
List<GwtAttachment> attachmentListRequest = getGwtAttachmentsRequest(attachments);
List<GwtAttachment> attachmentListRequest = getGwtAttachmentsRequest(messageExchange.getRequestAttachments());
List<GwtAttachment> attachmentListResponse = getGwtAttachmentsRequest(messageExchange.getResponseAttachments());
MessageInstance response = new MessageInstance();
......@@ -450,6 +449,8 @@ public class RunInstanceAction {
public void createExecutionWithCustomProperties() {
execution = new Execution();
componentToExecute = HibernateUtil.initializeAndUnproxy(componentToExecute);
Hibernate.initialize(componentToExecute.getCustomProperties());
execution.setCustomPropertiesUsed(getCustomPropertiesUsed(componentToExecute));
}
......@@ -624,6 +625,7 @@ public class RunInstanceAction {
public List<CustomPropertyUsed> getCustomPropertiesUsed(TestComponent testComponent) {
List<CustomPropertyUsed> customPropertyUsedList = new ArrayList<>();
if (testComponent instanceof GwtProject) {
Hibernate.initialize(((GwtProject) testComponent).getTestSuites());
customPropertyUsedList = getProjectCustomPropertiesUsed(customPropertyUsedList, (GwtProject) testComponent, true);
} else if (testComponent instanceof GwtTestSuite) {
customPropertyUsedList = getTestSuiteCustomPropertiesUsed(customPropertyUsedList, (GwtTestSuite) testComponent, true);
......@@ -639,8 +641,11 @@ public class RunInstanceAction {
public List<CustomPropertyUsed> getProjectCustomPropertiesUsed(List<CustomPropertyUsed> customPropertyUsedList, GwtProject gwtProject, boolean
propagate) {
for (CustomProperty customProperty : gwtProject.getCustomProperties()) {
addCustomPropertyUsedToCustomProperty(customPropertyUsedList, customProperty);
List<CustomProperty> customProperties = gwtProject.getCustomProperties();
if (customProperties != null) {
for (CustomProperty customProperty : customProperties) {
addCustomPropertyUsedToCustomProperty(customPropertyUsedList, customProperty);
}
}
if (propagate) {
for (GwtTestSuite gwtTestSuite : gwtProject.getTestSuites()) {
......@@ -652,8 +657,11 @@ public class RunInstanceAction {
public List<CustomPropertyUsed> getTestSuiteCustomPropertiesUsed(List<CustomPropertyUsed> customPropertyUsedList, GwtTestSuite gwtTestSuite,
boolean propagate) {
for (CustomProperty customProperty : gwtTestSuite.getCustomProperties()) {
addCustomPropertyUsedToCustomProperty(customPropertyUsedList, customProperty);
List<CustomProperty> customProperties = gwtTestSuite.getCustomProperties();
if (customProperties != null) {
for (CustomProperty customProperty : customProperties) {
addCustomPropertyUsedToCustomProperty(customPropertyUsedList, customProperty);
}
}
if (propagate) {
for (GwtTestCase gwtTestCase : gwtTestSuite.getTestCases()) {
......@@ -665,8 +673,11 @@ public class RunInstanceAction {
public List<CustomPropertyUsed> getTestCaseCustomPropertiesUsed(List<CustomPropertyUsed> customPropertyUsedList, GwtTestCase gwtTestCase,
boolean propagate) {
for (CustomProperty customProperty : gwtTestCase.getCustomProperties()) {
addCustomPropertyUsedToCustomProperty(customPropertyUsedList, customProperty);
List<CustomProperty> customProperties = gwtTestCase.getCustomProperties();
if (customProperties != null) {
for (CustomProperty customProperty : customProperties) {
addCustomPropertyUsedToCustomProperty(customPropertyUsedList, customProperty);
}
}
return customPropertyUsedList;
}
......@@ -687,10 +698,10 @@ public class RunInstanceAction {
public void addKeystore(Keystore keystore) {
if (keystore != null) {
SoapUI.getSettings().setString(SSLSettings.KEYSTORE, keystore.getPath());
if (keystore.getPassword() != null) {
SoapUI.getSettings().setString(SSLSettings.KEYSTORE_PASSWORD, keystore.getPassword());
}
SoapUI.getSettings().setString(SSLSettings.KEYSTORE, keystore.getPath());
SoapUI.getSettings().setBoolean(HttpSettings.AUTHENTICATE_PREEMPTIVELY, true);
}
}
......
......@@ -127,7 +127,7 @@ public class UploadProject implements Serializable {
FacesMessages.instance().add(StatusMessage.Severity.WARN, "Could not modify the label");
}
updateTestComponents();
tree = Tree.getComponentAsTree(soapuiProject.getGwtProject(), false);
tree = Tree.getComponentAsTree(soapuiProject.getGwtProject(), false, false);
} else {
LOGGER.error("uploadEventListener() : file " + soapuiProject.getXmlFilePath() + " couldn't be created");
}
......
......@@ -36,7 +36,7 @@ public class ProjectDetailBean {
String projectIdString = urlParams.get("id");
projectDetail = new ProjectDetail();
projectDetail.setSoapuiProject(SoapuiProjectDao.getSoapuiProjectById(Integer.parseInt(projectIdString)));
projectDetail.setTree(Tree.getComponentAsTree(projectDetail.getSoapuiProject().getGwtProject(), true));
projectDetail.setTree(Tree.getComponentAsTree(projectDetail.getSoapuiProject().getGwtProject(), true, false));
String edit = urlParams.get("edit");
if (edit != null && edit.equals("true") && Identity.instance().hasRole("admin_role")) {
editProject = true;
......
......@@ -12,11 +12,13 @@ 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.annotations.Transactional;
import org.richfaces.event.TreeSelectionChangeEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.faces.event.AjaxBehaviorEvent;
import java.io.File;
import java.io.Serializable;
import java.util.List;
......@@ -92,12 +94,14 @@ public class RunInstanceBean implements Serializable {
return SoapuiProjectDao.getActiveSoapuiProjects();
}
@Transactional
public GazelleTreeNodeImpl<TestComponent> getCurrentNodeAsTree() {
return Tree.getComponentAsTree(getComponentToExecute(), true);
return Tree.getComponentAsTree(getComponentToExecute(), true, true);
}
@Transactional
public GazelleTreeNodeImpl<TestComponent> getProjectAsTree() {
return Tree.getComponentAsTree(getCurrentProject().getGwtProject(), false);
return Tree.getComponentAsTree(getCurrentProject().getGwtProject(), false, true);
}
public void reset() {
......@@ -124,12 +128,13 @@ public class RunInstanceBean implements Serializable {
runInstanceAction.getAllInfo();
}
@Transactional
public void setCurrentNodeEventAndPrepareExecution(AjaxBehaviorEvent event) {
setComponentToExecute((TestComponent) event.getComponent().getAttributes().get("testComponent"));
runInstanceAction.createExecutionWithCustomProperties();
}
@Transactional
public void setCurrentNodeEventAndPrepareExecution2(TreeSelectionChangeEvent event) {
if (event.getNewSelection().size() == 1) {
setComponentToExecute((TestComponent) ((List) event.getNewSelection()).get(0));
......@@ -146,4 +151,12 @@ public class RunInstanceBean implements Serializable {
Execution execution = runInstanceAction.run();
return "/executionResult.seam?id=" + execution.getId();
}
public boolean isFileExist() {
if (getCurrentProject() != null) {
File file = new File(getCurrentProject().getXmlFilePath());
return file.exists();
}
return false;
}
}
......@@ -18,11 +18,17 @@ public class ExecutionDao {
return EntityManagerService.provideEntityManager().find(Execution.class, id);
}
public static List<Execution> getAllExecution() {
ExecutionQuery executionQuery = new ExecutionQuery();
return executionQuery.getListNullIfEmpty();
}
public static Execution mergeExecution(Execution execution) {
if (execution == null) {
ExecutionDao.LOG.error("The execution is null");
return null;
} else {
execution.updateGlobalStatus();
final EntityManager em = EntityManagerService.provideEntityManager();
Execution newExecution = em.merge(execution);
em.flush();
......
......@@ -10,6 +10,8 @@ import org.slf4j.LoggerFactory;
import javax.persistence.EntityManager;
import java.io.File;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
......@@ -57,6 +59,18 @@ public class SoapuiProjectDao {
public static List<SoapuiProject> getActiveSoapuiProjects() {
SoapuiProjectQuery query = new SoapuiProjectQuery();
query.active().eq(true);
return query.getListNullIfEmpty();
List<SoapuiProject> listNullIfEmpty = query.getListNullIfEmpty();
if (listNullIfEmpty != null) {
Collections.sort(listNullIfEmpty, new Comparator<SoapuiProject>() {
@Override
public int compare(SoapuiProject soapuiProject, SoapuiProject soapuiProject2) {
return soapuiProject.getLabel().compareToIgnoreCase(soapuiProject2.getLabel());
}
});
}
return listNullIfEmpty;
}
}
......@@ -6,22 +6,22 @@ import net.ihe.gazelle.common.pages.Page;
public enum Pages implements Page {
HOME("/home.seam", null, "Gazelle Webservice Tester", Authorizations.ALL),
PROJECT_LIST("/project/projectList.seam", null, "List of SoapUI project", Authorizations.ALL),
PROJECT_LIST("/project/projectList.seam", null, "Project List", Authorizations.ALL),
PROJECT_DETAIL("/project/projectDetail.seam", null, "SoapUI project detail ", Authorizations.ALL),
RUN_INSTANCE("/runInstance.seam", null, "Run a SoapUI project", Authorizations.LOGGED),
EXECUTION_LIST("/executionList.seam", null, "List of execution", Authorizations.LOGGED),
RUN_INSTANCE("/runInstance.seam", null, "Run", Authorizations.LOGGED),
EXECUTION_LIST("/executionList.seam", null, "Execution List", Authorizations.LOGGED),
EXECUTION_RESULT("/executionResult.seam", null, "Execution result", Authorizations.LOGGED),
UPLOAD_PROJECT("/uploadProject.seam", null, "Upload a SoapUI project", Authorizations.LOGGED),
LOGIN_REDIRECT("/login_redirect.seam", null, "User Not Logged In", Authorizations.ALL),
ADMINISTRATION("/administration/configure.seam", null, "Admin Configuration", Authorizations.ADMIN),
CALLING_TOOL("/administration/callingTools.seam", null, "Manager calling tools", Authorizations.ADMIN),
CONFIGURATION("/administration/configure.seam", null, "Admin Configuration", Authorizations.ADMIN),
CALLING_TOOL("/administration/callingTools.seam", null, "Calling tools", Authorizations.ADMIN),
ERROR("/error.seam", null, "Error", Authorizations.ALL),
ERROR_EXPIRED("/errorExpired.seam", null, "Error Expired", Authorizations.ALL),
KEYSTORE("/administration/keystore.seam", null, "Keystore Manager", Authorizations.ADMIN),
ACTOR_TYPE("/administration/conformanceTool/actorType.seam", null, "Actor Type", Authorizations.ADMIN),
OPTION("/administration/conformanceTool/option.seam", null, "Option", Authorizations.ADMIN),
PROFILE("/administration/conformanceTool/profile.seam", null, "Profile", Authorizations.ADMIN);
CONFORMANCE_TOOL("", null, "Conformance tool", Authorizations.ADMIN),
OPTION("/administration/conformanceTool/option.seam", null, "Manage option", Authorizations.ADMIN),
ACTOR_TYPE("/administration/conformanceTool/actorType.seam", null, "Manage actor type", Authorizations.ADMIN),
PROFILE("/administration/conformanceTool/profile.seam", null, "Manage profile", Authorizations.ADMIN);
private String link;
private String icon;
......
package net.ihe.gazelle.wstester.model;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.Type;
import javax.persistence.CascadeType;
......@@ -41,18 +39,17 @@ public class CustomProperty implements Serializable {
@Column(name = "to_modify")
private Boolean toModify;
@ManyToOne(fetch = FetchType.LAZY)
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "test_component_id")
private TestComponent testComponent;
@OneToMany(
fetch = FetchType.EAGER,
fetch = FetchType.LAZY,
targetEntity = CustomPropertyUsed.class,
mappedBy = "customProperty",
cascade = CascadeType.ALL,
orphanRemoval = true
)
@Fetch(value = FetchMode.SUBSELECT)
private List<CustomPropertyUsed> customPropertyUsedList;
public CustomProperty() {
......
......@@ -35,11 +35,11 @@ public class CustomPropertyUsed implements Serializable {
@JoinColumn(name = "execution_id")
private Execution execution;
@ManyToOne(fetch = FetchType.LAZY)
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "sut")
private SystemConfiguration systemConfiguration;
@ManyToOne(fetch = FetchType.LAZY)
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "custom_property_id")
private CustomProperty customProperty;
......
package net.ihe.gazelle.wstester.model;
import net.ihe.gazelle.wstester.action.RunInstanceAction;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import net.ihe.gazelle.wstester.dao.ExecutionDao;
import javax.persistence.CascadeType;
import javax.persistence.Column;
......@@ -42,6 +41,9 @@ public class Execution implements Serializable {
@Column(name = "company")
private String company;
@Column(name = "status")
private String status;
@Column(name = "launch_date", nullable = false)
@Temporal(TemporalType.TIMESTAMP)
private Date launchDate;
......@@ -50,29 +52,26 @@ public class Execution implements Serializable {
@JoinColumn(name = "soapui_project_id")
private SoapuiProject soapuiProject;
@ManyToOne(fetch = FetchType.EAGER)
@Fetch(value = FetchMode.SELECT)
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "test_component_id")
private TestComponent testComponent;
@OneToMany(
fetch = FetchType.EAGER,
fetch = FetchType.LAZY,
targetEntity = GwtTestStepResult.class,
mappedBy = "execution",
cascade = CascadeType.ALL,
orphanRemoval = true
)
@Fetch(value = FetchMode.SUBSELECT)
private List<GwtTestStepResult> testStepResults;
@OneToMany(
fetch = FetchType.EAGER,
fetch = FetchType.LAZY,
targetEntity = CustomPropertyUsed.class,
mappedBy = "execution",
cascade = CascadeType.ALL,
orphanRemoval = true
)
@Fetch(value = FetchMode.SUBSELECT)
private List<CustomPropertyUsed> customPropertiesUsed;
@OneToOne(fetch = FetchType.LAZY,
......@@ -178,22 +177,41 @@ public class Execution implements Serializable {
this.testComponentToString = testComponentToString;
}
public String getGlobalStatus() {
public String getStatus() {
if (status == null) {
ExecutionDao.mergeExecution(this); // this will update the status
}
return status;
}
public void setStatus(String status) {
this.status = status;
}
public void updateGlobalStatus() {
if (testStepResults == null || testStepResults.size() == 0) {
return "UNKNOWN";
setStatus("UNKNOWN");
}
boolean isPassed = true;
for (GwtTestStepResult testStepResult : testStepResults) {
if (testStepResult.getStatus().equals("FAILED")
|| (testStepResult.getResponseValidation() != null && testStepResult.getResponseValidation().getValidationStatus().equals("FAILED"))
|| (testStepResult.getRequestValidation() != null && testStepResult.getRequestValidation().getValidationStatus().equals("FAILED"))
|| (testStepResult.getXvalidationResult() != null && testStepResult.getXvalidationResult().getXvalidationStatus().equals("FAILED"))) {
return "FAILED";
setStatus("FAILED");
isPassed = false;
break;
}
if (testStepResult.getStatus().equals("UNKNOWN")) {
return testStepResult.getStatus();
setStatus(testStepResult.getStatus());
isPassed = false;
break;
}
}
return "PASSED";
if (isPassed) {
setStatus("PASSED");
}
}
public String getTestComponentToString() {
......@@ -215,33 +233,34 @@ public class Execution implements Serializable {
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Execution execution = (Execution) o;
if (!id.equals(execution.id)) {
if (!id.equals(execution.id)) return false;
if (!launchBy.equals(execution.launchBy)) return false;
if (!company.equals(execution.company)) return false;
if (!launchDate.equals(execution.launchDate)) return false;
if (!soapuiProject.equals(execution.soapuiProject)) return false;
if (!testComponent.equals(execution.testComponent)) return false;
if (testStepResults != null ? !testStepResults.equals(execution.testStepResults) : execution.testStepResults != null)
return false;
}
if (!launchBy.equals(execution.launchBy)) {
return false;
}
if (!launchDate.equals(execution.launchDate)) {
if (customPropertiesUsed != null ? !customPropertiesUsed.equals(execution.customPropertiesUsed) : execution.customPropertiesUsed != null)
return false;
}
return testStepResults.equals(execution.testStepResults);
return testInstanceResult != null ? testInstanceResult.equals(execution.testInstanceResult) : execution.testInstanceResult == null;
}
@Override
public int hashCode() {
int result = id.hashCode();
result = 31 * result + launchBy.hashCode();
result = 31 * result + company.hashCode();
result = 31 * result + launchDate.hashCode();
result = 31 * result + testStepResults.hashCode();
result = 31 * result + soapuiProject.hashCode();
result = 31 * result + testComponent.hashCode();
result = 31 * result + (testStepResults != null ? testStepResults.hashCode() : 0);
result = 31 * result + (customPropertiesUsed != null ? customPropertiesUsed.hashCode() : 0);
return result;
}
}
package net.ihe.gazelle.wstester.model;
import com.uwyn.jhighlight.renderer.XhtmlRendererFactory;
import net.ihe.gazelle.wstester.util.DownloadFile;
import net.ihe.gazelle.wstester.util.Xml;
import org.jboss.seam.Component;
import org.slf4j.Logger;
......@@ -15,6 +16,7 @@ import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.ws.rs.core.MediaType;
import java.io.IOException;
import java.io.Serializable;
import java.nio.charset.StandardCharsets;
......@@ -141,18 +143,26 @@ public class GwtAttachment implements Serializable {
public String getContentFormatted() {
try {
if (content != null) {
return XhtmlRendererFactory.getRenderer("xml").highlight(null, Xml.prettyFormat(new String(content,
StandardCharsets.UTF_8)
), "UTF-8", false).replaceAll("<h1>.*</h1>", "");
} else {
return null;
if (contentType.equals(MediaType.TEXT_HTML) || contentType.equals(MediaType.TEXT_PLAIN) || contentType.equals(MediaType.TEXT_XML)) {
return XhtmlRendererFactory.getRenderer("xml").highlight(null, Xml.prettyFormat(new String(content,
StandardCharsets.UTF_8)
), "UTF-8", false).replaceAll("<h1>.*</h1>", "");
}
}
} catch (IOException e) {
LOG.error(e.getMessage());
}