01: /*
02: * Copyright 2006-2007 Dan Shellman
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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.
15: */
16: package org.iscreen.impl;
17:
18: import org.iscreen.DocumentationIterator;
19: import org.iscreen.ognl.OgnlMessage;
20:
21: /**
22: *
23: * @author Shellman, Dan
24: */
25: public class MockValidatorWrapper implements ValidatorWrapper {
26: private boolean reportFailure;
27: private boolean failFast;
28: private boolean validateCalled = false;
29:
30: /**
31: * Default constructor.
32: */
33: public MockValidatorWrapper(boolean failFlag, boolean failFastFlag) {
34: reportFailure = failFlag;
35: failFast = failFastFlag;
36: } //end MockValidatorWrapper()
37:
38: public boolean validate(InternalValidatorContext context,
39: ContextBean root, Object obj) {
40: validateCalled = true;
41:
42: if (reportFailure) {
43: context
44: .reportFailure(new OgnlMessage(
45: "A failure occurred!"));
46: }
47:
48: return !failFast;
49: } //end validate()
50:
51: public boolean wasValidateCalled() {
52: return validateCalled;
53: } //end wasValidateCalled()
54:
55: public String getName() {
56: return "mock name";
57: } //end getName()
58:
59: public DocumentationIterator getDoc() {
60: return null;
61: } //end getDoc()
62: } //end MockValidatorWrapper
|