1 package org
.argeo
.slc
.jms
;
3 import javax
.jms
.Destination
;
5 import org
.apache
.commons
.logging
.Log
;
6 import org
.apache
.commons
.logging
.LogFactory
;
7 import org
.argeo
.slc
.SlcException
;
8 import org
.argeo
.slc
.core
.attachment
.Attachment
;
9 import org
.argeo
.slc
.core
.attachment
.SimpleAttachment
;
10 import org
.argeo
.slc
.core
.test
.tree
.TreeTestResult
;
11 import org
.argeo
.slc
.core
.test
.tree
.TreeTestResultListener
;
12 import org
.argeo
.slc
.msg
.test
.tree
.AddTreeTestResultAttachmentRequest
;
13 import org
.argeo
.slc
.msg
.test
.tree
.CloseTreeTestResultRequest
;
14 import org
.argeo
.slc
.msg
.test
.tree
.CreateTreeTestResultRequest
;
15 import org
.argeo
.slc
.msg
.test
.tree
.ResultPartRequest
;
16 import org
.argeo
.slc
.test
.TestResultListener
;
17 import org
.argeo
.slc
.test
.TestResultPart
;
18 import org
.springframework
.jms
.core
.JmsTemplate
;
20 public class JmsTreeTestResultListener
implements TreeTestResultListener
{
21 private final Log log
= LogFactory
.getLog(getClass());
23 private Boolean onlyOnClose
= false;
24 private JmsTemplate jmsTemplate
;
26 private Destination executionEventDestination
;
28 // private Destination createDestination;
29 // private Destination addResultPartDestination;
30 // private Destination closeDestination;
32 public void resultPartAdded(TreeTestResult testResult
,
33 TestResultPart testResultPart
) {
38 if (testResult
.getResultParts().size() == 1
39 && testResult
.getResultParts().values().iterator().next()
40 .getParts().size() == 1) {
41 CreateTreeTestResultRequest req
= new CreateTreeTestResultRequest(
44 if (log
.isDebugEnabled())
45 log
.debug("Send create result request for result "
46 + testResult
.getUuid());
48 jmsTemplate
.convertAndSend(executionEventDestination
, req
);
50 ResultPartRequest req
= new ResultPartRequest(testResult
);
52 if (log
.isDebugEnabled())
53 log
.debug("Send result parts for result "
54 + testResult
.getUuid());
56 jmsTemplate
.convertAndSend(executionEventDestination
, req
);
58 } catch (Exception e
) {
59 throw new SlcException("Could not notify to JMS", e
);
63 public void close(TreeTestResult testResult
) {
66 CreateTreeTestResultRequest req
= new CreateTreeTestResultRequest(
69 if (log
.isDebugEnabled())
70 log
.debug("Send create result request for result "
71 + testResult
.getUuid());
73 jmsTemplate
.convertAndSend(executionEventDestination
, req
);
75 CloseTreeTestResultRequest req
= new CloseTreeTestResultRequest(
78 if (log
.isDebugEnabled())
79 log
.debug("Send close result request for result "
80 + testResult
.getUuid());
82 jmsTemplate
.convertAndSend(executionEventDestination
, req
);
85 } catch (Exception e
) {
86 throw new SlcException("Could not notify to JMS", e
);
90 public void addAttachment(TreeTestResult testResult
, Attachment attachment
) {
92 AddTreeTestResultAttachmentRequest req
= new AddTreeTestResultAttachmentRequest();
93 req
.setResultUuid(testResult
.getUuid());
94 req
.setAttachment((SimpleAttachment
) attachment
);
95 jmsTemplate
.convertAndSend(executionEventDestination
, req
);
97 } catch (Exception e
) {
98 throw new SlcException("Could not notify to JMS", e
);
103 public void setOnlyOnClose(Boolean onlyOnClose
) {
104 this.onlyOnClose
= onlyOnClose
;
107 public void setJmsTemplate(JmsTemplate jmsTemplate
) {
108 this.jmsTemplate
= jmsTemplate
;
111 public void setExecutionEventDestination(
112 Destination executionEventDestination
) {
113 this.executionEventDestination
= executionEventDestination
;