Commit 0511f27c authored by Nicolas Bailliet's avatar Nicolas Bailliet
Browse files
parent c473b42c
......@@ -5,13 +5,13 @@
<parent>
<groupId>net.ihe.gazelle</groupId>
<artifactId>gazelle-webservice-tester</artifactId>
<version>1.3.0-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>net.ihe.gazelle</groupId>
<artifactId>gazelle-webservice-tester-ear</artifactId>
<version>1.3.0-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<packaging>ear</packaging>
<name>gazelle-webservice-tester - EAR</name>
......
......@@ -4,7 +4,7 @@
<parent>
<artifactId>gazelle-webservice-tester</artifactId>
<groupId>net.ihe.gazelle</groupId>
<version>1.3.0-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
......@@ -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>
......@@ -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
......@@ -99,7 +99,7 @@ public class ExecutionResult {
return new String(Files.readAllBytes(Paths.get(PreferenceService.getString("logs_directory") + this.execution.getId() + "/soapui.log"))
, StandardCharsets.UTF_8);
} catch (IOException e) {
LOG.error(e.getMessage());
//LOG.error(e.getMessage());
}
return null;
}
......@@ -109,7 +109,7 @@ public class ExecutionResult {
return new String(Files.readAllBytes(Paths.get(PreferenceService.getString("logs_directory") + this.execution.getId() + "/soapui-errors" +
".log")), StandardCharsets.UTF_8);
} catch (IOException e) {
LOG.error(e.getMessage());
//LOG.error(e.getMessage());
}
return null;
}
......@@ -119,7 +119,7 @@ public class ExecutionResult {
return new String(Files.readAllBytes(Paths.get(PreferenceService.getString("logs_directory") + this.execution.getId() + "/global-groovy" +
".log")), StandardCharsets.UTF_8);
} catch (IOException e) {
LOG.error(e.getMessage());
//LOG.error(e.getMessage());
}
return null;
}
......
......@@ -38,7 +38,7 @@ public class GwtTestStepValidation extends GwtValidation implements EVSClientVal
//Validation
public GwtTestStepValidation(String gwtTestStepResultId, byte[] selectedMessage) {
this.gwtTestStepResultId = gwtTestStepResultId;
this.selectedMessage = selectedMessage;
this.selectedMessage = selectedMessage.clone();
}
......@@ -47,7 +47,7 @@ public class GwtTestStepValidation extends GwtValidation implements EVSClientVal
}
public void setSelectedMessage(byte[] selectedMessage) {
this.selectedMessage = selectedMessage;
this.selectedMessage = selectedMessage.clone();
}
public String getGwtTestStepResultId() {
......@@ -77,22 +77,27 @@ public class GwtTestStepValidation extends GwtValidation implements EVSClientVal
parts = externalId.split("_");
EntityManager entityManager = EntityManagerService.provideEntityManager();
gwtTestStepResultSelected = entityManager.find(GwtTestStepResult.class, Integer.parseInt(parts[0]));
int testStepResultId = Integer.parseInt(parts[0]);
gwtTestStepResultSelected = entityManager.find(GwtTestStepResult.class, testStepResultId);
if (gwtTestStepResultSelected == null) {
FacesMessages.instance().add(StatusMessage.Severity.ERROR, "The given id does not match any test step result in the database");
}
} else {
String validationOid = EVSClientResults.getResultOidFromUrl(urlParams);
if (validationOid != null && parts != null && parts[1] != null) {
String validationOid = EVSClientResults.getResultOidFromUrl(urlParams);
String resultType = parts[1];
if (validationOid != null && parts != null && resultType != null) {
ValidationResult result = new ValidationResult(gwtTestStepResultSelected, validationOid, parts[1]);
if (result.isRequest()) {
gwtTestStepResultSelected.setRequestValidation(result);
} else if (result.isResponse()) {
gwtTestStepResultSelected.setResponseValidation(result);
ValidationResult result = new ValidationResult(gwtTestStepResultSelected, validationOid, resultType);
if (result.isRequest()) {
gwtTestStepResultSelected.setRequestValidation(result);
} else if (result.isResponse()) {
gwtTestStepResultSelected.setResponseValidation(result);
}
getResultDetails(result);
gwtTestStepResultSelected.save();
}
getResultDetails(result);
}
}
......@@ -131,7 +136,6 @@ public class GwtTestStepValidation extends GwtValidation implements EVSClientVal
@Override
public PartSource getPartSource() {
if (selectedMessage != null) {
//return new ByteArrayPartSource(getType(), selectedMessage);
return PartSourceUtils.buildEncoded64PartSource(selectedMessage, getType());
} else {
return null;
......
......@@ -49,58 +49,6 @@ public class ProjectDetail implements Serializable {
}
public void 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();
*/
SoapuiProjectDao.mergeSoapuiProject(soapuiProject);
}
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++;
}
}
}
......@@ -125,7 +125,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");
}
......@@ -200,7 +200,6 @@ public class UploadProject implements Serializable {
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);
......
......@@ -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,19 +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);
KEYSTORE("/administration/keystore.seam", null, "Keystore Manager", 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 org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.ihe.gazelle.wstester.util.HibernateUtil;
import javax.persistence.CascadeType;
import javax.persistence.CollectionTable;
......@@ -24,9 +23,6 @@ import java.util.Map;
@DiscriminatorValue("project")
public class GwtProject extends TestComponent implements Serializable {
private static final Logger LOG = LoggerFactory.getLogger(GwtProject.class);
@OneToOne(fetch = FetchType.EAGER,
cascade = CascadeType.ALL)
@JoinColumn(name = "soapui_project")
......@@ -122,6 +118,7 @@ public class GwtProject extends TestComponent implements Serializable {
public List<GwtTestSuite> getTestSuitesWithCustomPropertiesToModify(TestComponent testComponent) {
List<GwtTestSuite> gwtTestSuites = new ArrayList<>();
testComponent = HibernateUtil.initializeAndUnproxy(testComponent);
for (GwtTestSuite gwtTestSuite : getTestSuites()) {
boolean isAlreadyAdded = false;
if (testComponent.equals(gwtTestSuite) || ((testComponent instanceof GwtTestCase) && ((GwtTestCase) testComponent).getTestSuite()
......
......@@ -23,7 +23,7 @@ public class GwtTestSuite extends TestComponent implements Serializable {
private GwtProject gwtProject;
@OneToMany(
fetch = FetchType.EAGER,
fetch = FetchType.LAZY,
targetEntity = GwtTestCase.class,
mappedBy = "testSuite",
cascade = CascadeType.ALL,
......@@ -80,6 +80,7 @@ public class GwtTestSuite extends TestComponent implements Serializable {
for (CustomProperty customProperty : gwtTestCase.getCustomProperties()) {
if (customProperty.isToModify()) {
gwtTestCases.add(gwtTestCase);
break;
}
}
}
......
......@@ -47,7 +47,7 @@ public abstract class TestComponent implements Serializable {
@OneToMany(
targetEntity = CustomProperty.class,
fetch = FetchType.EAGER,
fetch = FetchType.LAZY,
mappedBy = "testComponent",
cascade = CascadeType.ALL,
orphanRemoval = true
......@@ -163,4 +163,26 @@ public abstract class TestComponent implements Serializable {
return 0;
}
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
TestComponent that = (TestComponent) o;
if (executable != that.executable) return false;
if (disable != that.disable) return false;
if (!id.equals(that.id)) return false;
return label.equals(that.label);
}
@Override
public int hashCode() {
int result = id.hashCode();
result = 31 * result + label.hashCode();
result = 31 * result + (executable ? 1 : 0);
result = 31 * result + (disable ? 1 : 0);
return result;
}
}
package net.ihe.gazelle.wstester.model;
import net.ihe.gazelle.hql.providers.EntityManagerService;
import net.ihe.gazelle.wstester.dao.ExecutionDao;
import javax.persistence.Column;
import javax.persistence.Entity;
......@@ -57,6 +58,7 @@ public class ValidationResult implements Serializable {
EntityManager entityManager = EntityManagerService.provideEntityManager();
ValidationResult result = entityManager.merge(this);
entityManager.flush();
ExecutionDao.mergeExecution(gwtTestStepResult.getExecution());
return result;
}
......
package net.ihe.gazelle.wstester.util;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.ArrayUtils;
import org.jboss.seam.faces.FacesMessages;
import org.jboss.seam.international.StatusMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.activation.FileTypeMap;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
public class DownloadFile {
private static final Logger LOG = LoggerFactory.getLogger(DownloadFile.class);
public static void exportToFile(String content, String fileNameDestination) {
exportToFile((String) null, (String) content, fileNameDestination);
}
public static void exportToFile(String contentType, String content, String fileNameDestination) {
if (content != null) {
exportToFile(contentType, content.getBytes(), fileNameDestination);
}
}
public static void exportToFile(String contentType, byte[] bytes, String fileNameDestination) {