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

Separate bean and action from RunSoapui.java, create page permission, unit testing

git-svn-id: https://scm.gforge.inria.fr/authscm/ycadoret/svn/gazelle/Maven/simulators/gazelle-webservice-tester/trunk@60552 356b4b1a-1d2b-0410-8bf1-ffa24008f01e
parent 612f96c5
......@@ -20,4 +20,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'), '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-webservice-tester/projects/');
INSERT INTO app_configuration (id, variable, value) VALUES (nextval('app_configuration_id_seq'), 'tm_domain', 'https://ehealthsuisse.ihe-europe.net/');
INSERT INTO app_configuration (id, variable, value) VALUES (nextval('app_configuration_id_seq'), 'keystore_directory', '/opt/gazelle-webservice-tester/keystores/');
\ No newline at end of file
INSERT INTO app_configuration (id, variable, value) VALUES (nextval('app_configuration_id_seq'), 'keystore_directory', '/opt/gazelle-webservice-tester/keystores/');
INSERT INTO app_configuration (id, variable, value)
VALUES (nextval('app_configuration_id_seq'), 'logs_directory', '/opt/gazelle-webservice-tester/logs/');
\ No newline at end of file
......@@ -229,5 +229,10 @@
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.kohsuke.metainf-services</groupId>
<artifactId>metainf-services</artifactId>
<version>1.7</version>
</dependency>
</dependencies>
</project>
......@@ -57,7 +57,7 @@ public class ExecutionList implements Serializable {
}
public String reRun(Execution execution) {
RunSoapui runner = new RunSoapui();
RunInstanceAction runner = new RunInstanceAction();
runner.reRunTestInstance(execution);
return "/executionResult.seam?id=" + runner.getExecution().getId();
}
......
package net.ihe.gazelle.wstester.action;
import net.ihe.gazelle.preferences.PreferenceService;
import net.ihe.gazelle.wstester.dao.ExecutionDao;
import net.ihe.gazelle.wstester.model.Execution;
import org.jboss.seam.ScopeType;
......@@ -10,6 +11,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.faces.context.FacesContext;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Map;
@Name("executionResult")
......@@ -71,4 +75,30 @@ public class ExecutionResult {
return treeRoot;
}*/
public String getSoapuiLog() {
try {
return new String(Files.readAllBytes(Paths.get(PreferenceService.getString("logs_directory") + this.execution.getId() + "/soapui.log")));
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
public String getSoapuiErrorLog() {
try {
return new String(Files.readAllBytes(Paths.get(PreferenceService.getString("logs_directory") + this.execution.getId() + "/soapui-errors.log")));
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
public String getGroovyLog() {
try {
return new String(Files.readAllBytes(Paths.get(PreferenceService.getString("logs_directory") + this.execution.getId() + "/global-groovy.log")));
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
}
......@@ -4,8 +4,10 @@ public class StepInfo {
private String transaction;
private int testRoleResponderId;
private int testRoleInitiatorId;
private int participantRoleInTestId;
private String systemKeyword;
private String responderSystemKeyword;
private String initiatorSystemKeyword;
private String endpoint;
private String roleInTest;
private String transactionUsage;
......@@ -39,12 +41,28 @@ public class StepInfo {
this.participantRoleInTestId = participantRoleInTestId;
}
public String getSystemKeyword() {
return systemKeyword;
public int getTestRoleInitiatorId() {
return testRoleInitiatorId;
}
public void setSystemKeyword(String systemKeyword) {
this.systemKeyword = systemKeyword;
public void setTestRoleInitiatorId(int testRoleInitiatorId) {
this.testRoleInitiatorId = testRoleInitiatorId;
}
public String getResponderSystemKeyword() {
return responderSystemKeyword;
}
public void setResponderSystemKeyword(String responderSystemKeyword) {
this.responderSystemKeyword = responderSystemKeyword;
}
public String getInitiatorSystemKeyword() {
return initiatorSystemKeyword;
}
public void setInitiatorSystemKeyword(String initiatorSystemKeyword) {
this.initiatorSystemKeyword = initiatorSystemKeyword;
}
public String getEndpoint() {
......
package net.ihe.gazelle.wstester.bean;
import net.ihe.gazelle.common.tree.GazelleTreeNodeImpl;
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.GwtTestSuite;
import net.ihe.gazelle.wstester.model.SoapuiProject;
import net.ihe.gazelle.wstester.model.TestParameter;
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.Serializable;
import java.util.List;
@Name("runSoapui")
@Scope(ScopeType.PAGE)
public class RunInstanceBean implements Serializable {
private static final Logger LOG = LoggerFactory.getLogger(RunInstanceBean.class);
private RunInstanceAction runInstanceAction = new RunInstanceAction();
public SoapuiProject getCurrentProject() {
return runInstanceAction.getCurrentProject();
}
public void setCurrentProject(SoapuiProject currentProject) {
runInstanceAction.setCurrentProject(currentProject);
}
public Execution getExecution() {
return runInstanceAction.getExecution();
}
public void setExecution(Execution execution) {
runInstanceAction.setExecution(execution);
}
public int getTestInstanceId() {
return runInstanceAction.getTestInstanceId();
}
public void setTestInstanceId(int testInstanceId) {
runInstanceAction.setTestInstanceId(testInstanceId);
}
public List<SoapuiProject> getSoapuiProjects() {
return SoapuiProjectDao.getAllSoapuiProject();
}
public GazelleTreeNodeImpl<TestParameter> getProjectAsTree() {
GazelleTreeNodeImpl<TestParameter> treeRoot = new GazelleTreeNodeImpl<>();
GazelleTreeNodeImpl<TestParameter> nodeProject = new GazelleTreeNodeImpl<>();
int index = 0;
SoapuiProject currentProject = runInstanceAction.getCurrentProject();
nodeProject.setData(currentProject);
treeRoot.addChild(index, nodeProject);
index++;
for (GwtTestSuite testSuite : currentProject.getTestSuites()) {
GazelleTreeNodeImpl<TestParameter> nodeSuite = new GazelleTreeNodeImpl<>();
nodeSuite.setData(testSuite);
nodeProject.addChild(index, nodeSuite);
index++;
}
return treeRoot;
}
public void resetSimple() {
runInstanceAction.resetSimple();
}
public void getAllInfo() {
runInstanceAction.getAllInfo();
}
public String redirectToResult() {
Execution execution = runInstanceAction.runTestInstance();
return "/executionResult.seam?id=" + execution.getId();
}
}
package net.ihe.gazelle.wstester.menu;
import net.ihe.gazelle.common.pages.Authorization;
import org.jboss.seam.security.Identity;
public enum Authorizations implements Authorization {
ALL,
LOGGED,
ADMIN,
MONITOR;
@Override
public boolean isGranted(Object... context) {
switch (this) {
case ALL:
return true;
case LOGGED:
return Identity.instance().isLoggedIn();
case ADMIN:
return Identity.instance().hasRole("admin_role");
case MONITOR:
return Identity.instance().hasRole("monitor_role");
default:
return false;
}
}
}
package net.ihe.gazelle.wstester.menu;
import net.ihe.gazelle.common.pages.Page;
import net.ihe.gazelle.common.pages.PageLister;
import org.kohsuke.MetaInfServices;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@MetaInfServices(PageLister.class)
public class GWTPageLister implements PageLister {
@Override
public Collection<Page> getPages() {
Collection<Page> pages = new ArrayList<>();
pages.addAll(Arrays.asList(Pages.values()));
return pages;
}
}
package net.ihe.gazelle.wstester.menu;
import net.ihe.gazelle.common.pages.Authorization;
import net.ihe.gazelle.common.pages.Page;
public enum Pages implements Page {
HOME("/home.seam", null, "Gazelle Webservice Tester", Authorizations.ALL),
PROJECT_LIST("/projectList.seam", null, "List of SoapUI project", Authorizations.ALL),
PROJECT_DETAIL("/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),
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);
private String link;
private String icon;
private String label;
private Authorization[] authorizations;
Pages(String link, String icon, String label, Authorization... authorizations) {
this.link = link;
this.icon = icon;
this.label = label;
this.authorizations = authorizations;
}
@Override
public String getId() {
return name();
}
@Override
public String getLabel() {
return label;
}
/**
* with .xhtml extension
*
* @return
*/
@Override
public String getLink() {
return link.replace(".seam", ".xhtml");
}
@Override
public String getIcon() {
return icon;
}
@Override
public Authorization[] getAuthorizations() {
return authorizations;
}
@Override
public String getMenuLink() {
return link;
}
}
......@@ -21,6 +21,9 @@ public class Execution implements Serializable {
@Column(name = "launch_by", nullable = false)
private String launchBy;
@Column(name = "company")
private String company;
@Column(name = "launch_date", nullable = false)
@Temporal(TemporalType.TIMESTAMP)
private Date launchDate;
......@@ -104,6 +107,23 @@ public class Execution implements Serializable {
this.testInstanceResult = testInstanceResult;
}
public String getCompany() {
return company;
}
public void setCompany(String company) {
this.company = company;
}
public String getGlobalStatus() {
for (GwtTestStepResult testStepResult : testStepResults) {
if (testStepResult.getStatus().equals("FAILED")) {
return testStepResult.getStatus();
}
}
return "PASSED";
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
......
......@@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory;
import javax.persistence.*;
import java.io.IOException;
import java.io.Serializable;
import java.text.SimpleDateFormat;
@Entity
@Name("testStepResult")
......@@ -30,6 +31,9 @@ public class GwtTestStepResult implements Serializable {
@Column(name = "time_taken", nullable = false)
private long timeTaken;
@Column(name = "endpoint")
private String endpoint;
@OneToOne(fetch = FetchType.LAZY,
cascade = CascadeType.ALL)
@JoinColumn(name = "messages")
......@@ -47,12 +51,13 @@ public class GwtTestStepResult implements Serializable {
super();
}
public GwtTestStepResult(String status, long timeTaken, TransactionInstance messages, GwtTestStep testStep, Execution execution) {
public GwtTestStepResult(String status, long timeTaken, TransactionInstance messages, GwtTestStep testStep, Execution execution, String endpoint) {
this.status = status;
this.timeTaken = timeTaken;
this.messages = messages;
this.testStep = testStep;
this.execution = execution;
this.endpoint = endpoint;
}
public Integer getId() {
......@@ -79,6 +84,14 @@ public class GwtTestStepResult implements Serializable {
this.timeTaken = timeTaken;
}
public String getEndpoint() {
return endpoint;
}
public void setEndpoint(String endpoint) {
this.endpoint = endpoint;
}
public TransactionInstance getTransaction() {
return messages;
}
......@@ -111,6 +124,12 @@ public class GwtTestStepResult implements Serializable {
this.execution = execution;
}
public String getTimestamp() {
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/YY hh:mm:ss");
return formatter.format(this.messages.getTimestamp());
}
public String getRequestContent() {
try {
if (this.messages.getRequest().getContent() != null) {
......@@ -140,10 +159,14 @@ public class GwtTestStepResult implements Serializable {
}
public String getStatusForCss() {
if (getStatus().equals("OK")) {
return "PASSED";
if (getStatus() != null) {
if (getStatus().equals("OK")) {
return "PASSED";
} else {
return getStatus();
}
} else {
return getStatus();
return "unknown";
}
}
}
......@@ -57,6 +57,14 @@ public class GwtTestSuite extends TestComponent implements Serializable {
this.testCases = testCases;
}
public List<TestInstanceResult> getTestInstanceResults() {
return testInstanceResults;
}
public void setTestInstanceResults(List<TestInstanceResult> testInstanceResults) {
this.testInstanceResults = testInstanceResults;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
......
......@@ -50,6 +50,15 @@ public class TestInstanceResult implements Serializable {
this.testSuite = testSuite;
}
public TestInstanceResult(int testInstance, String lastStatus, String testKeyword, String testName, GwtTestSuite testSuite, Execution execution) {
this.testInstance = testInstance;
this.lastStatus = lastStatus;
this.testKeyword = testKeyword;
this.testName = testName;
this.testSuite = testSuite;
this.execution = execution;
}
public int getTestInstance() {
return testInstance;
}
......
package net.ihe.gazelle.wstester.util;
import net.ihe.gazelle.simulator.users.model.SSOIdentity;
import org.jboss.seam.security.Identity;
public class Application {
public static String getUser() {
String user = null;
String user;
if (Identity.instance().isLoggedIn()) {
user = Identity.instance().getCredentials().getUsername();
} else {
......@@ -13,4 +14,8 @@ public class Application {
}
return user;
}
public static String getCompanyKeyword() {
return new SSOIdentity().getCompanyKeyword();
}
}
@startuml
class testSuite{
String label
}
class testSuiteResult{
int testInstance
String test
Date date
byte[] log
class Execution{
String launchBy
Date launchDate
}
class testCase{
class GwtTestCase{
String label
}
class testStep{
class GwtTestStep{
String transactionLabel
}
class testStepResult{
class GwtTestStepResult{
String status
String timeTaken
String encoding
TransactionInstance transaction
}
class execution{
String launchBy
Date launchDate
class GwtTestSuite{
String label
}
class endpoint{
class Parameter{
String label
String url
String defaultValue
}
class ParameterUsed{
String value
}
class soapuiProject{
class SoapuiProject{
String label
String xmlFilePath
String version
......@@ -46,37 +42,45 @@ String owner
Date creationDate
}
class keystore{
String path
class TestComponent{
String label
}
class parameter{
String label
String defaultValue
class TestInstanceResult{
int testInstance;
String lastStatus;