]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/SimpleTestRun.java
Finalize JMS serialization
[gpl/argeo-slc.git] / runtime / org.argeo.slc.core / src / main / java / org / argeo / slc / core / test / SimpleTestRun.java
1 /*
2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
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
17 package org.argeo.slc.core.test;
18
19 import java.util.UUID;
20
21 import org.argeo.slc.core.structure.tree.TreeSPath;
22 import org.argeo.slc.deploy.DeployedSystem;
23 import org.argeo.slc.process.SlcExecution;
24 import org.argeo.slc.process.SlcExecutionRelated;
25 import org.argeo.slc.process.SlcExecutionStep;
26 import org.argeo.slc.structure.StructureAware;
27 import org.argeo.slc.structure.StructureRegistry;
28 import org.argeo.slc.test.ExecutableTestRun;
29 import org.argeo.slc.test.TestData;
30 import org.argeo.slc.test.TestDefinition;
31 import org.argeo.slc.test.TestResult;
32 import org.argeo.slc.test.WritableTestRun;
33
34 /**
35 * A basic bean implementation of a <code>WritableTestRun</code>, holding
36 * references to the various parts of a test run.
37 */
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 public void notifySlcExecution(SlcExecution slcExecution) {
134 if (slcExecution != null) {
135 slcExecutionUuid = slcExecution.getUuid();
136 SlcExecutionStep step = slcExecution.currentStep();
137 if (step != null) {
138 slcExecutionStepUuid = step.getUuid();
139 }
140 }
141 }
142
143 public void notifyCurrentPath(StructureRegistry<TreeSPath> registry,
144 TreeSPath path) {
145 this.registry = registry;
146 this.path = path;
147 }
148
149 }