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
.springframework
.beans
.factory
.InitializingBean
;
23 import org
.argeo
.slc
.SlcException
;
24 import org
.argeo
.slc
.test
.context
.ContextAware
;
25 import org
.argeo
.slc
.test
.context
.ParentContextAware
;
27 public class SimpleContextAware
implements ContextAware
, InitializingBean
{
28 private ParentContextAware parentContext
;
30 private Map
<String
, Object
> values
= new TreeMap
<String
, Object
>();
31 private Map
<String
, Object
> expectedValues
= new TreeMap
<String
, Object
>();
33 private String contextSkipFlag
= DEFAULT_SKIP_FLAG
;
34 private String contextAnyFlag
= DEFAULT_ANY_FLAG
;
36 public Map
<String
, Object
> getValues() {
40 public void setValues(Map
<String
, Object
> values
) {
44 public Map
<String
, Object
> getExpectedValues() {
45 return expectedValues
;
48 public void setExpectedValues(Map
<String
, Object
> expectedValues
) {
49 this.expectedValues
= expectedValues
;
52 /** Used to add this context as a child by setting a property. */
53 public void setParentContext(ParentContextAware parentContextAware
) {
54 if (parentContext
!= null)
55 throw new SlcException("Parent context already set");
56 this.parentContext
= parentContextAware
;
57 this.parentContext
.addChildContext(this);
60 protected ParentContextAware
getParentContext() {
64 public void afterPropertiesSet() throws Exception
{
65 if (parentContext
!= null) {
66 ContextUtils
.synchronize(parentContext
);
70 public String
getContextSkipFlag() {
71 return contextSkipFlag
;
74 public void setContextSkipFlag(String contextSkipFlag
) {
75 this.contextSkipFlag
= contextSkipFlag
;
78 public String
getContextAnyFlag() {
79 return contextAnyFlag
;
82 public void setContextAnyFlag(String contextAnyFlag
) {
83 this.contextAnyFlag
= contextAnyFlag
;