1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.argeo.slc.core.test.context;
17
18 import java.util.Map;
19 import java.util.TreeMap;
20
21 import org.argeo.slc.SlcException;
22 import org.argeo.slc.test.context.ContextAware;
23 import org.argeo.slc.test.context.ParentContextAware;
24 import org.springframework.beans.factory.InitializingBean;
25
26 public class SimpleContextAware implements ContextAware, InitializingBean {
27 private ParentContextAware parentContext;
28
29 private Map<String, Object> values = new TreeMap<String, Object>();
30 private Map<String, Object> expectedValues = new TreeMap<String, Object>();
31
32 private String contextSkipFlag = DEFAULT_SKIP_FLAG;
33 private String contextAnyFlag = DEFAULT_ANY_FLAG;
34
35 public Map<String, Object> getValues() {
36 return values;
37 }
38
39 public void setValues(Map<String, Object> values) {
40 this.values = values;
41 }
42
43 public Map<String, Object> getExpectedValues() {
44 return expectedValues;
45 }
46
47 public void setExpectedValues(Map<String, Object> expectedValues) {
48 this.expectedValues = expectedValues;
49 }
50
51
52 public void setParentContext(ParentContextAware parentContextAware) {
53 if (parentContext != null)
54 throw new SlcException("Parent context already set");
55 this.parentContext = parentContextAware;
56 this.parentContext.addChildContext(this);
57 }
58
59 protected ParentContextAware getParentContext() {
60 return parentContext;
61 }
62
63 public void afterPropertiesSet() throws Exception {
64 if (parentContext != null) {
65 ContextUtils.synchronize(parentContext);
66 }
67 }
68
69 public String getContextSkipFlag() {
70 return contextSkipFlag;
71 }
72
73 public void setContextSkipFlag(String contextSkipFlag) {
74 this.contextSkipFlag = contextSkipFlag;
75 }
76
77 public String getContextAnyFlag() {
78 return contextAnyFlag;
79 }
80
81 public void setContextAnyFlag(String contextAnyFlag) {
82 this.contextAnyFlag = contextAnyFlag;
83 }
84
85 }