Commit c086e9e3 authored by Nicolas Bailliet's avatar Nicolas Bailliet
Browse files

commit for Anne Gaelle

git-svn-id: https://scm.gforge.inria.fr/authscm/ycadoret/svn/gazelle/Maven/simulators/gazelle-webservice-tester/trunk@63142 356b4b1a-1d2b-0410-8bf1-ffa24008f01e
parent 4a83be76
......@@ -45,7 +45,7 @@
<dependency>
<groupId>net.ihe.gazelle</groupId>
<artifactId>gazelle-evsclient-connector</artifactId>
<version>1.1.17</version>
<version>1.1.18-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.ihe.gazelle.simulators</groupId>
......
......@@ -32,17 +32,34 @@ public class GwtTestStepValidation implements EVSClientValidatedObject {
String gwtTestStepResultId;
byte[] selectedMessage;
byte[] xvalRequest;
byte[] xvalResponse;
GwtTestStepResult gwtTestStepResultSelected;
String gwtTestStepXValOid;
ValidationResult validationResult;
public GwtTestStepValidation() {
}
//Validation
public GwtTestStepValidation(String gwtTestStepResultId, byte[] selectedMessage) {
this.gwtTestStepResultId = gwtTestStepResultId;
this.selectedMessage = selectedMessage;
}
//XValidation
public GwtTestStepValidation(String gwtTestStepResultId, byte[] request, byte[] response, String gwtTestStepXValOid) {
this.gwtTestStepResultId = gwtTestStepResultId;
this.xvalRequest = request;
this.xvalResponse = response;
this.gwtTestStepXValOid = gwtTestStepXValOid;
}
public byte[] getSelectedMessage() {
return selectedMessage;
}
......@@ -51,6 +68,22 @@ public class GwtTestStepValidation implements EVSClientValidatedObject {
this.selectedMessage = selectedMessage;
}
public byte[] getXvalRequest() {
return xvalRequest;
}
public void setXvalRequest(byte[] xvalRequest) {
this.xvalRequest = xvalRequest;
}
public byte[] getXvalResponse() {
return xvalResponse;
}
public void setXvalResponse(byte[] xvalResponse) {
this.xvalResponse = xvalResponse;
}
public String getGwtTestStepResultId() {
return gwtTestStepResultId;
}
......@@ -67,6 +100,14 @@ public class GwtTestStepValidation implements EVSClientValidatedObject {
this.gwtTestStepResultSelected = gwtTestStepResultSelected;
}
public String getGwtTestStepXValOid() {
return gwtTestStepXValOid;
}
public void setGwtTestStepXValOid(String gwtTestStepXValOid) {
this.gwtTestStepXValOid = gwtTestStepXValOid;
}
public ValidationResult getValidationResult() {
return validationResult;
}
......@@ -129,6 +170,24 @@ public class GwtTestStepValidation implements EVSClientValidatedObject {
}
}
@Override
public PartSource getXValRequestPartSource() {
if (xvalRequest != null) {
return PartSourceUtils.buildEncoded64PartSource(xvalRequest, getType());
} else {
return null;
}
}
@Override
public PartSource getXValResponsePartSource() {
if (xvalResponse != null) {
return PartSourceUtils.buildEncoded64PartSource(xvalResponse, getType());
} else {
return null;
}
}
@Override
public String getType() {
return "xml";
......@@ -147,4 +206,22 @@ public class GwtTestStepValidation implements EVSClientValidatedObject {
}
}
public void xvalidate() throws IOException {
String evsClientUrl = ApplicationConfiguration.getValueOfVariable("evs_client_url");
String toolOid = ApplicationConfiguration.getValueOfVariable("tool_instance_oid");
LOG.debug("OID_XVAL = ",gwtTestStepXValOid);
if (evsClientUrl == null) {
LOG.error("evs_client_url is missing in app_configuration table");
} else if (toolOid == null) {
LOG.error("tool_instance_oid is missing in app_configuration table");
} else {
ExternalContext extContext = FacesContext.getCurrentInstance().getExternalContext();
EVSClientServletConnector.sendToXValidation(this, extContext, evsClientUrl, toolOid, gwtTestStepXValOid);
}
}
}
......@@ -326,7 +326,10 @@ public class RunInstanceAction {
transactionInstance.setTimestamp(new Date(result.getTimeStamp()));
return new GwtTestStepResult(result.getStatus().toString(), result.getTimeTaken(), transactionInstance, GwtTestStepDao.getGwtTestStep(result, this.currentProject.getLabel()), execution, messageExchange.getEndpoint(), Arrays.asList(result.getMessages()));
String root = PreferenceService.getString("gwt_root_oid");
String oid_teststep = root + transactionInstance.getId();
return new GwtTestStepResult(result.getStatus().toString(), result.getTimeTaken(), oid_teststep,transactionInstance, GwtTestStepDao.getGwtTestStep(result, this.currentProject.getLabel()), execution, messageExchange.getEndpoint(), Arrays.asList(result.getMessages()));
}
public void prepareExecution() {
......
......@@ -213,6 +213,8 @@ public class UploadProject implements Serializable {
gwtTestStep.setLabel(testStep.getName());
gwtTestStep.setTestCase(gwtTestCase);
gwtTestStep.setDisable(testStep.isDisabled());
//TODO temporary definition of x val oid, need to be declared through properties for ex
gwtTestStep.setOid_xval("1.3.6.1.4.1.12559.11.1.2.0.5");
gwtTestSteps.add(gwtTestStep);
}
......
package net.ihe.gazelle.wstester.model;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.*;
import java.io.Serializable;
import java.util.List;
......@@ -18,6 +12,9 @@ public class GwtTestStep extends TestComponent implements Serializable {
@JoinColumn(name = "test_case_id")
private GwtTestCase testCase;
@Column(name = "oid_xval")
private String oid_xval;
@OneToMany(
targetEntity = GwtTestStepResult.class,
mappedBy = "testStep",
......@@ -35,10 +32,11 @@ public class GwtTestStep extends TestComponent implements Serializable {
return GwtTestStep.class.getSimpleName();
}
public GwtTestStep(String label, List<CustomProperty> customProperties, GwtTestCase testCase, List<GwtTestStepResult> gwtTestStepResults) {
public GwtTestStep(String label, List<CustomProperty> customProperties, GwtTestCase testCase, List<GwtTestStepResult> gwtTestStepResults, String oid_xval) {
super(label, customProperties);
this.testCase = testCase;
this.gwtTestStepResults = gwtTestStepResults;
this.oid_xval=oid_xval;
}
public GwtTestCase getTestCase() {
......@@ -57,6 +55,15 @@ public class GwtTestStep extends TestComponent implements Serializable {
this.gwtTestStepResults = gwtTestStepResults;
}
public String getOid_xval() {
return oid_xval;
}
public void setOid_xval(String oid_xval) {
this.oid_xval = oid_xval;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
......
package net.ihe.gazelle.wstester.model;
import com.uwyn.jhighlight.renderer.XhtmlRendererFactory;
import jxl.biff.ByteArray;
import net.ihe.gazelle.simulator.message.model.TransactionInstance;
import net.ihe.gazelle.wstester.action.GwtTestStepValidation;
import net.ihe.gazelle.wstester.util.DateUtil;
......@@ -25,6 +26,7 @@ import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.Serializable;
import java.nio.charset.StandardCharsets;
......@@ -48,6 +50,9 @@ public class GwtTestStepResult implements Serializable {
@Column(name = "time_taken", nullable = false)
private long timeTaken;
@Column(name = "oid_teststep")
private String oid_teststep;
@Column(name = "endpoint")
private String endpoint;
......@@ -75,18 +80,20 @@ public class GwtTestStepResult implements Serializable {
super();
}
public GwtTestStepResult(String status, long timeTaken, TransactionInstance messages, GwtTestStep testStep, Execution execution, String endpoint) {
public GwtTestStepResult(String status, long timeTaken, String oid_teststep, TransactionInstance messages, GwtTestStep testStep, Execution execution, String endpoint) {
this.status = status;
this.timeTaken = timeTaken;
this.oid_teststep = oid_teststep;
this.messages = messages;
this.testStep = testStep;
this.execution = execution;
this.endpoint = endpoint;
}
public GwtTestStepResult(String status, long timeTaken, TransactionInstance messages, GwtTestStep testStep, Execution execution, String endpoint, List<String> soapUIMessages) {
public GwtTestStepResult(String status, long timeTaken, String oid_teststep, TransactionInstance messages, GwtTestStep testStep, Execution execution, String endpoint, List<String> soapUIMessages) {
this.status = status;
this.timeTaken = timeTaken;
this.oid_teststep = oid_teststep;
this.endpoint = endpoint;
this.messages = messages;
this.testStep = testStep;
......@@ -118,6 +125,14 @@ public class GwtTestStepResult implements Serializable {
this.timeTaken = timeTaken;
}
public String getOid_teststep() {
return oid_teststep;
}
public void setOid_teststep(String oid_teststep) {
this.oid_teststep = oid_teststep;
}
public String getEndpoint() {
return endpoint;
}
......@@ -126,9 +141,7 @@ public class GwtTestStepResult implements Serializable {
this.endpoint = endpoint;
}
public TransactionInstance getTransaction() {
return messages;
}
public TransactionInstance getTransaction() { return messages; }
public void setTransaction(TransactionInstance messages) {
this.messages = messages;
......@@ -202,6 +215,30 @@ public class GwtTestStepResult implements Serializable {
return null;
}
public String getXValContent() {
try {
if (this.messages.getRequest().getContent() != null) {
return XhtmlRendererFactory.getRenderer("xml").highlight("Request", Xml.prettyFormat(new String(this.messages.getRequest().getContent(), StandardCharsets.UTF_8)
), "UTF-8", false).replaceAll("<h1>.*</h1>", "");
} else {
return null;
}
} catch (IOException e) {
LOG.error("getXValRequestContent() : " + e.getMessage());
}
try {
if (this.messages.getResponse().getContent() != null) {
return XhtmlRendererFactory.getRenderer("xml").highlight("Response", Xml.prettyFormat(new String(this.messages.getResponse()
.getContent(), StandardCharsets.UTF_8)), "UTF-8", false).replaceAll("<h1>.*</h1>", "");
} else {
return null;
}
} catch (IOException e) {
LOG.error("getXValResponseContent() : " + e.getMessage());
}
return null;
}
public String getStatusForCss() {
if (getStatus() != null) {
if (getStatus().equals("OK")) {
......@@ -224,6 +261,19 @@ public class GwtTestStepResult implements Serializable {
gwtTestStepValidation.validate();
}
public void xvalidate() {
String xvalOid = testStep.getOid_xval();
GwtTestStepValidation gwtTestStepValidation = new GwtTestStepValidation(id + "xval", messages.getRequest().getContent(), messages.getResponse().getContent(), xvalOid);
try {
gwtTestStepValidation.xvalidate();
} catch (IOException e) {
e.printStackTrace();
}
}
public ValidationResult getResponseValidation() {
ValidationResultQuery query = new ValidationResultQuery();
query.gwtTestStepResult().eq(this);
......@@ -238,6 +288,12 @@ public class GwtTestStepResult implements Serializable {
return query.getUniqueResult();
}
public XValidationResult getXValidation() {
XValidationResultQuery query = new XValidationResultQuery();
query.gwtTestStepResult().eq(this);
return query.getUniqueResult();
}
public void downloadRequest() {
final String content = this.getMessages().getRequest().getContentAsString();
final String fileName = this.testStep.getLabel() + "_request.xml";
......
......@@ -138,7 +138,10 @@
</g:column>
<g:column>
<ui:define name="header">Cross-Validation</ui:define>
<h:outputText value="Not yet implemented"/>
<h:commandLink actionListener="#{testStepResult.xvalidate()}"
target="_blank">
<s:span title="X Validate" styleClass="gzl-icon-play-blue"/>
</h:commandLink>
</g:column>
</rich:dataTable>
</ui:decorate>
......@@ -266,7 +269,35 @@
<rich:togglePanelItem name="#{testStepResult.id}" switchType="ajax">
<gri:panel>
<f:facet name="header">
<h:outputText value="#{testStepResult.getFullLabel()}"/>
<div class="row">
<div class="col-md-10">
<h:outputText value="#{testStepResult.getFullLabel()}"/>
</div>
<div class="col-md-2" style="text-align:right">
<h:outputText value="Cross Validation : "></h:outputText>
<h:outputLink
value="#{testStepResult.getXValidation().permanentLink}"
target="_blank">
<h:outputText
value="#{testStepResult.getXValidation().permanentLink}"/>
</h:outputLink>
<h:outputText
value="#{testStepResult.getXValidation().validationStatus}"
styleClass="gzl-label #{testStepResult.getXValidation().validationStatus}"
rendered="#{testStepResult.getXValidation() != null}"/>
<h:commandLink actionListener="#{testStepResult.xvalidate()}"
rendered="#{testStepResult.getXValidation() == null}"
target="_blank">
<s:span title="X Validate"
styleClass="gzl-icon-play-blue"/>
</h:commandLink>
<h:commandLink actionListener="#{testStepResult.xvalidate()}"
target="_blank"
rendered="#{testStepResult.getXValidation() != null}">
<s:span title="Re-X-validate" styleClass="gzl-icon-repeat"/>
</h:commandLink>
</div>
</div>
</f:facet>
<s:decorate template="/layout/display/_display.xhtml">
<ui:define name="label">SoapUI Validation</ui:define>
......@@ -284,10 +315,20 @@
<h:outputText value="#{testStepResult.getTimestamp()}"/>
</s:decorate>
<s:decorate template="/layout/display/_display.xhtml">
<ui:define name="label">Time Taken</ui:define>
<h:outputText value="#{testStepResult.timeTaken} ms"/>
</s:decorate>
<s:decorate template="/layout/display/_display.xhtml">
<ui:define name="label">Time Taken</ui:define>
<h:outputText value="#{testStepResult.timeTaken} ms"/>
</s:decorate>
<s:decorate template="/layout/display/_display.xhtml">
<ui:define name="label">OID TestStep</ui:define>
<h:outputText value="#{testStepResult.oid_teststep}"/>
</s:decorate>
<s:decorate template="/layout/display/_display.xhtml">
<ui:define name="label">OID XVAL</ui:define>
<h:outputText value="#{testStepResult.getTestStep().oid_xval}"/>
</s:decorate>
<gri:panel
rendered="#{testStepResult.soapUIMessages != null and testStepResult.soapUIMessages.size() != 0}">
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment