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
.context
;
19 import java
.util
.TreeMap
;
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
;
26 public class SimpleContextAware
implements ContextAware
, InitializingBean
{
27 private ParentContextAware parentContext
;
29 private Map
<String
, Object
> values
= new TreeMap
<String
, Object
>();
30 private Map
<String
, Object
> expectedValues
= new TreeMap
<String
, Object
>();
32 private String contextSkipFlag
= DEFAULT_SKIP_FLAG
;
33 private String contextAnyFlag
= DEFAULT_ANY_FLAG
;
35 public Map
<String
, Object
> getValues() {
39 public void setValues(Map
<String
, Object
> values
) {
43 public Map
<String
, Object
> getExpectedValues() {
44 return expectedValues
;
47 public void setExpectedValues(Map
<String
, Object
> expectedValues
) {
48 this.expectedValues
= expectedValues
;
51 /** Used to add this context as a child by setting a property. */
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);
59 protected ParentContextAware
getParentContext() {
63 public void afterPropertiesSet() throws Exception
{
64 if (parentContext
!= null) {
65 ContextUtils
.synchronize(parentContext
);
69 public String
getContextSkipFlag() {
70 return contextSkipFlag
;
73 public void setContextSkipFlag(String contextSkipFlag
) {
74 this.contextSkipFlag
= contextSkipFlag
;
77 public String
getContextAnyFlag() {
78 return contextAnyFlag
;
81 public void setContextAnyFlag(String contextAnyFlag
) {
82 this.contextAnyFlag
= contextAnyFlag
;