01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.wicket;
18:
19: import junit.framework.TestCase;
20:
21: /**
22: * Some tests for meta data.
23: */
24: public class MetaDataTest extends TestCase {
25: private static final MetaDataKey KEY1 = new MetaDataKey(
26: String.class) {
27: private static final long serialVersionUID = 1L;
28: };
29:
30: private static final MetaDataKey KEY2 = new MetaDataKey(
31: String.class) {
32: private static final long serialVersionUID = 1L;
33: };
34:
35: private static final MetaDataKey KEY3 = new MetaDataKey(
36: String.class) {
37: private static final long serialVersionUID = 1L;
38: };
39:
40: private static final MetaDataKey KEY4 = new MetaDataKey(
41: String.class) {
42: private static final long serialVersionUID = 1L;
43: };
44:
45: /**
46: * Construct.
47: */
48: public MetaDataTest() {
49: }
50:
51: /**
52: * Construct.
53: *
54: * @param name
55: */
56: public MetaDataTest(String name) {
57: super (name);
58: }
59:
60: /**
61: * Test bounds and basic operations.
62: */
63: public void testMetaDataKey() {
64: MetaDataEntry[] md = KEY1.set(null, "1");
65: assertNotNull(md);
66: assertEquals(1, md.length);
67: md = KEY1.set(md, null);
68: assertNull(md);
69: md = KEY1.set(md, "1");
70: md = KEY2.set(md, "2");
71: md = KEY3.set(md, "3");
72: md = KEY4.set(md, "4");
73: assertEquals(4, md.length);
74: md = KEY3.set(md, null);
75: assertEquals(3, md.length);
76: assertEquals("1", KEY1.get(md));
77: assertEquals("2", KEY2.get(md));
78: assertEquals(null, KEY3.get(md));
79: assertEquals("4", KEY4.get(md));
80: md = KEY4.set(md, null);
81: assertEquals(2, md.length);
82: assertEquals("1", KEY1.get(md));
83: assertEquals("2", KEY2.get(md));
84: assertEquals(null, KEY3.get(md));
85: assertEquals(null, KEY4.get(md));
86: md = KEY1.set(md, null);
87: assertEquals(1, md.length);
88: assertEquals(null, KEY1.get(md));
89: assertEquals("2", KEY2.get(md));
90: assertEquals(null, KEY3.get(md));
91: assertEquals(null, KEY4.get(md));
92: md = KEY2.set(md, null);
93: assertNull(md);
94: }
95: }
|