1 Upload of attachments to a test result
3 This allows to attach ANY Spring resource (for example the one created above but not only, since it can also be classpath: or osgibundle: Resources or ANY file on the file system where the agent is running (e.g. Mx *.mxres files on a server...))
7 [[1]] First reference an attachment uploader service via OSGi (it is provided by the standard agent):
9 +-------------------------------+
10 <reference id="attachmentUploader" interface="org.argeo.slc.core.attachment.AttachmentUploader" />
11 +-------------------------------+
13 [[1]] Then use an UploadAttachment task:
15 +-------------------------------+
16 <bean parent="task.uploadAttachments">
17 <property name="attachmentUploader" ref="attachmentUploader" />
18 <property name="attachment">
19 <bean parent="taskArg.attachment">
20 <property name="name" value="myAttachment.txt" />
23 <property name="resource" ref="basic.writeTo" />
24 <property name="attachTo">
26 <ref bean="basic.testResult" />
30 +-------------------------------+
32 You have to specify an Attachment object with at least a 'name', you can also specify a 'contentType', but the server will recognize common extension of the name.
33 You have to specify a (Spring) Resource, for example the one that you created before (the name of the attachment doesn't have to be the name of the file).
34 Just doing this will already upload a file to the server, but if you want to access it you need to bind it to some object, typically a TreeTestResult. You can provide a list of AttachmentEnabled objects (only TreeTestResult implements it so far).
36 You could use directly Spring Resource URL, e.g.:
38 +-------------------------------+
39 <property name="resource" value="osgibundle:/conf/main.xml" />
40 +-------------------------------+
42 You can also upload and attach many attachments in one shot. In that case provide a Map with the keys being Attachment objects and the values Resource objects. E.g.:
44 +-------------------------------+
45 <bean parent="task.uploadAttachments">
46 <property name="attachmentUploader" ref="attachmentUploader" />
47 <property name="attachments">
51 <bean parent="taskArg.attachment">
52 <property name="name" value="Reached.csv" />
55 <bean factory-bean="fileDiff.testData" factory-method="getReached"
62 <bean parent="taskArg.attachment">
63 <property name="name" value="Expected.csv" />
66 <bean factory-bean="fileDiff.testData" factory-method="getExpected"
73 <property name="attachTo">
75 <ref bean="fileDiff.testResult" />
79 +-------------------------------+
81 Retrieving the resources from this bean:
83 +-------------------------------+
84 <bean id="fileDiff.testData" parent="testData.reachedExpected"
87 <property name="expected" value="osgibundle:/inputs/csvdiff/@{fileName}.csv" />
88 <property name="reached"
89 value="osgibundle:/inputs/csvdiff/@{fileName}_mod.csv" />
91 +-------------------------------+
93 [[1]] You can access the attachments from the Web UI by selecting a result in the list in the results perspective.
94 You will see that a new button 'Attachment' in the toolbar get activated (if there are any attachments).