1 Management of writable files within tests
3 This provides an abstraction for files generated by the test.
5 The files are stored in the standard osgi instance area (argument -data <my data area> to an OSGi launch, default is a ./data directory in the execution directory) under a ${osgi.instance.area}/executionResources directory.
7 A subdirectory is created for each execution, thus avoiding that the files override each other.
9 The format of this directory is yyyyMMdd_HHmmss_<execution context uuid>
13 [[1]] First declare a ResourcesManager in your application context. It has to reference the SLC Execution Context (always available):
15 +-------------------------------+
16 <bean id="basic.resourcesManager" parent="slcTemplate.fileResources">
17 <property name="executionContext" ref="executionContext" />
19 +-------------------------------+
21 [[1]] Then you can retrieve Spring Resources via a call to this manager. For example (it could also be an inner bean):
23 +-------------------------------+
24 <bean id="basic.writeTo" factory-bean="basic.resourcesManager"
25 factory-method="getWritableResource" scope="execution">
26 <constructor-arg value="subdir/writeTo" />
29 +-------------------------------+
31 The "constructor argument" (just a Spring notation in this case) is a relative path that you want to give to this file.
32 Within a given execution, repeated calls on the manager with the same relative path will always point to the same file.
34 [[1]] Then simply use this standard Spring Resource where required:
36 +-------------------------------+
37 <bean parent="task.echo">
38 <property name="message" value="DATA" />
39 <property name="writeTo" ref="basic.writeTo" />
41 +-------------------------------+
43 Underlying calls to the getFile() method of this resource won't fail (since they are writable).
45 Factory bean for execution resources
47 Here is an enhancement to declare execution resources:
49 +-------------------------------+
50 <bean id="executionResources.placeholderPass" parent="slcTemplate.simpleFlow">
51 <constructor-arg ref="executionResources.spec" />
52 <property name="executables">
54 <bean parent="task.echo">
55 <property name="message" value="DATA" />
56 <property name="writeTo">
57 <bean parent="slcTemplate.resourcesFactoryBean" scope="execution">
58 <property name="executionResources" ref="executionResources" />
59 <property name="relativePath" value="subdir/@{var}" />
67 +-------------------------------+
69 This allows to pass @{} execution parameters.
71 The other form WON'T WORK if you try to passe @{} in the constructor-arg tag (but still works if the relative path does not contain a @{}):
73 +-------------------------------+
74 <bean id="executionResources.placeholderFail" parent="slcTemplate.simpleFlow">
75 <constructor-arg ref="executionResources.spec" />
76 <property name="executables">
78 <bean parent="task.echo">
79 <property name="message" value="DATA" />
80 <property name="writeTo">
81 <bean factory-bean="executionResources" factory-method="getWritableResource"
83 <constructor-arg value="subdir/@{var}" />
91 +-------------------------------+