01: // Copyright 2006 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // Unless required by applicable law or agreed to in writing, software
10: // distributed under the License is distributed on an "AS IS" BASIS,
11: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: // See the License for the specific language governing permissions and
13: // limitations under the License.
14:
15: package org.apache.tapestry.internal.services;
16:
17: import java.util.Arrays;
18: import java.util.Collection;
19:
20: import org.apache.tapestry.internal.test.InternalBaseTestCase;
21: import org.apache.tapestry.services.PersistentFieldBundle;
22: import org.apache.tapestry.services.PersistentFieldChange;
23: import org.testng.annotations.Test;
24:
25: public class PersistentFieldBundleImplTest extends InternalBaseTestCase {
26: @Test
27: public void get_root_component_value() {
28: String value = "FIELD-VALUE";
29:
30: PersistentFieldChange change = new PersistentFieldChangeImpl(
31: "", "field", value);
32: Collection<PersistentFieldChange> changes = Arrays
33: .asList(change);
34:
35: PersistentFieldBundle bundle = new PersistentFieldBundleImpl(
36: changes);
37:
38: assertTrue(bundle.containsValue("", "field"));
39: assertTrue(bundle.containsValue(null, "field"));
40:
41: assertSame(bundle.getValue("", "field"), value);
42: assertSame(bundle.getValue(null, "field"), value);
43:
44: assertFalse(bundle.containsValue("", "other"));
45: assertFalse(bundle.containsValue(null, "other"));
46: }
47:
48: @Test
49: public void get_nested_component_value() {
50: String value = "FIELD-VALUE";
51:
52: PersistentFieldChange change = new PersistentFieldChangeImpl(
53: "foo.bar", "field", value);
54: Collection<PersistentFieldChange> changes = Arrays
55: .asList(change);
56:
57: PersistentFieldBundle bundle = new PersistentFieldBundleImpl(
58: changes);
59:
60: assertTrue(bundle.containsValue("foo.bar", "field"));
61:
62: assertSame(bundle.getValue("foo.bar", "field"), value);
63:
64: assertFalse(bundle.containsValue("foo.bar", "other"));
65: }
66: }
|