]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/SimpleTestRun.java
Make default execution ressources temp dir dependent of the JVM OS user, in order...
[gpl/argeo-slc.git] / runtime / org.argeo.slc.core / src / main / java / org / argeo / slc / core / test / SimpleTestRun.java
1 /*
2 * Copyright (C) 2007-2012 Mathieu Baudier
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.argeo.slc.core.test;
17
18 import java.util.UUID;
19
20 import org.argeo.slc.core.structure.tree.TreeSPath;
21 import org.argeo.slc.deploy.DeployedSystem;
22 import org.argeo.slc.process.SlcExecution;
23 import org.argeo.slc.process.SlcExecutionRelated;
24 import org.argeo.slc.process.SlcExecutionStep;
25 import org.argeo.slc.structure.StructureAware;
26 import org.argeo.slc.structure.StructureRegistry;
27 import org.argeo.slc.test.ExecutableTestRun;
28 import org.argeo.slc.test.TestData;
29 import org.argeo.slc.test.TestDefinition;
30 import org.argeo.slc.test.TestResult;
31 import org.argeo.slc.test.WritableTestRun;
32
33 /**
34 * A basic bean implementation of a <code>WritableTestRun</code>, holding
35 * references to the various parts of a test run.
36 */
37 @SuppressWarnings("deprecation")
38 public class SimpleTestRun implements WritableTestRun, ExecutableTestRun,
39 SlcExecutionRelated, StructureAware<TreeSPath> {
40 private String uuid;
41
42 private String slcExecutionUuid;
43 private String slcExecutionStepUuid;
44
45 private TreeSPath path;
46 private StructureRegistry<TreeSPath> registry;
47
48 private DeployedSystem deployedSystem;
49 private TestData testData;
50 private TestDefinition testDefinition;
51 private TestResult testResult;
52
53 /** Executes the underlying test definition. */
54 @SuppressWarnings("unchecked")
55 public void run() {
56 uuid = UUID.randomUUID().toString();
57 if (testResult != null)
58 testResult.notifyTestRun(this);
59
60 // Structure
61 if (testResult != null && path != null
62 && testResult instanceof StructureAware)
63 ((StructureAware<TreeSPath>) testResult).notifyCurrentPath(
64 registry, path);
65
66 if (path != null && testDefinition instanceof StructureAware)
67 ((StructureAware<TreeSPath>) testDefinition).notifyCurrentPath(
68 registry, path);
69
70 testDefinition.execute(this);
71 }
72
73 @SuppressWarnings("unchecked")
74 public <T extends DeployedSystem> T getDeployedSystem() {
75 return (T) deployedSystem;
76 }
77
78 public void setDeployedSystem(DeployedSystem deployedSystem) {
79 this.deployedSystem = deployedSystem;
80 }
81
82 @SuppressWarnings("unchecked")
83 public <T extends TestData> T getTestData() {
84 return (T) testData;
85 }
86
87 public void setTestData(TestData testData) {
88 this.testData = testData;
89 }
90
91 @SuppressWarnings("unchecked")
92 public <T extends TestDefinition> T getTestDefinition() {
93 return (T) testDefinition;
94 }
95
96 public void setTestDefinition(TestDefinition testDefinition) {
97 this.testDefinition = testDefinition;
98 }
99
100 @SuppressWarnings("unchecked")
101 public <T extends TestResult> T getTestResult() {
102 return (T) testResult;
103 }
104
105 public void setTestResult(TestResult testResult) {
106 this.testResult = testResult;
107 }
108
109 public String getUuid() {
110 return uuid;
111 }
112
113 public void setUuid(String uuid) {
114 this.uuid = uuid;
115 }
116
117 public String getSlcExecutionUuid() {
118 return slcExecutionUuid;
119 }
120
121 public void setSlcExecutionUuid(String slcExecutionUuid) {
122 this.slcExecutionUuid = slcExecutionUuid;
123 }
124
125 public String getSlcExecutionStepUuid() {
126 return slcExecutionStepUuid;
127 }
128
129 public void setSlcExecutionStepUuid(String slcExecutionStepUuid) {
130 this.slcExecutionStepUuid = slcExecutionStepUuid;
131 }
132
133 @Deprecated
134 public void notifySlcExecution(SlcExecution slcExecution) {
135 if (slcExecution != null) {
136 slcExecutionUuid = slcExecution.getUuid();
137 SlcExecutionStep step = slcExecution.currentStep();
138 if (step != null) {
139 slcExecutionStepUuid = step.getUuid();
140 }
141 }
142 }
143
144 public void notifyCurrentPath(StructureRegistry<TreeSPath> registry,
145 TreeSPath path) {
146 this.registry = registry;
147 this.path = path;
148 }
149
150 }