2 * Copyright (C) 2007-2012 Argeo GmbH
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.
16 package org
.argeo
.slc
.core
.test
;
18 import java
.util
.Date
;
19 import java
.util
.List
;
21 import java
.util
.TreeMap
;
22 import java
.util
.UUID
;
23 import java
.util
.Vector
;
25 import org
.apache
.commons
.logging
.Log
;
26 import org
.apache
.commons
.logging
.LogFactory
;
28 import org
.argeo
.slc
.SlcException
;
29 import org
.argeo
.slc
.test
.TestResult
;
30 import org
.argeo
.slc
.test
.TestResultPart
;
31 import org
.argeo
.slc
.test
.TestRun
;
34 * Basic implementation of a test result containing only a list of result parts.
36 public class SimpleTestResult
implements TestResult
{
37 private static Log log
= LogFactory
.getLog(SimpleTestResult
.class);
40 private String currentTestRunUuid
;
42 private Boolean throwError
= true;
44 private Date closeDate
;
45 private List
<TestResultPart
> parts
= new Vector
<TestResultPart
>();
47 private Map
<String
, String
> attributes
= new TreeMap
<String
, String
>();
49 public void addResultPart(TestResultPart part
) {
50 if (throwError
&& part
.getStatus() == ERROR
) {
51 throw new SlcException(
52 "There was an error in the underlying test: "
53 + part
.getExceptionMessage());
56 if (log
.isDebugEnabled())
62 closeDate
= new Date();
65 public List
<TestResultPart
> getParts() {
69 public Date
getCloseDate() {
73 public void setThrowError(Boolean throwError
) {
74 this.throwError
= throwError
;
77 public void notifyTestRun(TestRun testRun
) {
78 currentTestRunUuid
= testRun
.getUuid();
81 public String
getUuid() {
83 uuid
= UUID
.randomUUID().toString();
88 public void setUuid(String uuid
) {
92 public String
getCurrentTestRunUuid() {
93 return currentTestRunUuid
;
96 public Map
<String
, String
> getAttributes() {
100 public void setAttributes(Map
<String
, String
> attributes
) {
101 this.attributes
= attributes
;