2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org
.argeo
.slc
.core
.test
;
19 import java
.util
.UUID
;
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
;
35 * A basic bean implementation of a <code>WritableTestRun</code>, holding
36 * references to the various parts of a test run.
38 public class SimpleTestRun
implements WritableTestRun
, ExecutableTestRun
,
39 SlcExecutionRelated
, StructureAware
<TreeSPath
> {
42 private String slcExecutionUuid
;
43 private String slcExecutionStepUuid
;
45 private TreeSPath path
;
46 private StructureRegistry
<TreeSPath
> registry
;
48 private DeployedSystem deployedSystem
;
49 private TestData testData
;
50 private TestDefinition testDefinition
;
51 private TestResult testResult
;
53 /** Executes the underlying test definition. */
54 @SuppressWarnings("unchecked")
56 uuid
= UUID
.randomUUID().toString();
57 if (testResult
!= null)
58 testResult
.notifyTestRun(this);
61 if (testResult
!= null && path
!= null
62 && testResult
instanceof StructureAware
)
63 ((StructureAware
<TreeSPath
>) testResult
).notifyCurrentPath(
66 if (path
!= null && testDefinition
instanceof StructureAware
)
67 ((StructureAware
<TreeSPath
>) testDefinition
).notifyCurrentPath(
70 testDefinition
.execute(this);
73 @SuppressWarnings("unchecked")
74 public <T
extends DeployedSystem
> T
getDeployedSystem() {
75 return (T
) deployedSystem
;
78 public void setDeployedSystem(DeployedSystem deployedSystem
) {
79 this.deployedSystem
= deployedSystem
;
82 @SuppressWarnings("unchecked")
83 public <T
extends TestData
> T
getTestData() {
87 public void setTestData(TestData testData
) {
88 this.testData
= testData
;
91 @SuppressWarnings("unchecked")
92 public <T
extends TestDefinition
> T
getTestDefinition() {
93 return (T
) testDefinition
;
96 public void setTestDefinition(TestDefinition testDefinition
) {
97 this.testDefinition
= testDefinition
;
100 @SuppressWarnings("unchecked")
101 public <T
extends TestResult
> T
getTestResult() {
102 return (T
) testResult
;
105 public void setTestResult(TestResult testResult
) {
106 this.testResult
= testResult
;
109 public String
getUuid() {
113 public void setUuid(String uuid
) {
117 public String
getSlcExecutionUuid() {
118 return slcExecutionUuid
;
121 public void setSlcExecutionUuid(String slcExecutionUuid
) {
122 this.slcExecutionUuid
= slcExecutionUuid
;
125 public String
getSlcExecutionStepUuid() {
126 return slcExecutionStepUuid
;
129 public void setSlcExecutionStepUuid(String slcExecutionStepUuid
) {
130 this.slcExecutionStepUuid
= slcExecutionStepUuid
;
133 public void notifySlcExecution(SlcExecution slcExecution
) {
134 if (slcExecution
!= null) {
135 slcExecutionUuid
= slcExecution
.getUuid();
136 SlcExecutionStep step
= slcExecution
.currentStep();
138 slcExecutionStepUuid
= step
.getUuid();
143 public void notifyCurrentPath(StructureRegistry
<TreeSPath
> registry
,
145 this.registry
= registry
;