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:
18: package java.beans;
19:
20: import java.beans.ArrayPersistenceDelegate;
21: import java.beans.Encoder;
22: import java.beans.Expression;
23: import java.lang.reflect.Array;
24:
25: import junit.framework.TestCase;
26:
27: /**
28: * Test the internal class java.beans.ArrayPersistenceDelegate.
29: */
30: public class ArrayPersistenceDelegateTest extends TestCase {
31:
32: private ArrayPersistenceDelegate pd = null;
33:
34: @Override
35: protected void setUp() throws Exception {
36: super .setUp();
37: pd = new ArrayPersistenceDelegate();
38: }
39:
40: public void testMutates() {
41: assertFalse(pd.mutatesTo(new int[] { 1 }, null));
42: assertFalse(pd.mutatesTo(null, null));
43: assertFalse(pd.mutatesTo(new int[1], new int[2]));
44: assertTrue(pd.mutatesTo(new int[] { 1, 3 }, new int[] { 1, 2 }));
45: }
46:
47: public void testInitialize() {
48: // TBD
49: }
50:
51: public void testInstantiate_Normal() throws Exception {
52: Object obj = new int[] { 1, 2, 3 };
53: Expression exp = pd.instantiate(obj, new Encoder());
54: assertSame(obj, exp.getValue());
55: assertSame(Array.class, exp.getTarget());
56: assertEquals("newInstance", exp.getMethodName());
57: assertEquals(2, exp.getArguments().length);
58: assertSame(Integer.TYPE, exp.getArguments()[0]);
59: assertEquals(new Integer(3), exp.getArguments()[1]);
60: }
61:
62: }
|