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: * @author Alexander T. Simbirtsev
19: * @version $Revision$
20: * Created on 16.12.2004
21:
22: */package javax.swing;
23:
24: import java.awt.event.ActionEvent;
25: import java.io.IOException;
26: import java.io.ObjectInputStream;
27: import java.io.ObjectOutputStream;
28:
29: public class AbstractActionRTest extends SwingTestCase {
30: protected AbstractAction action;
31:
32: @Override
33: protected void setUp() throws Exception {
34: super .setUp();
35: action = new AbstractAction() {
36: private static final long serialVersionUID = 1L;
37:
38: public void actionPerformed(final ActionEvent event) {
39: }
40:
41: private void writeObject(final ObjectOutputStream outStream)
42: throws IOException {
43: }
44:
45: private void readObject(final ObjectInputStream inStream)
46: throws IOException, ClassNotFoundException {
47: }
48:
49: @Override
50: public Object clone() throws CloneNotSupportedException {
51: return super .clone();
52: }
53: };
54: }
55:
56: public void testClone() throws CloneNotSupportedException {
57: class MyAbstractAction extends AbstractAction {
58: private static final long serialVersionUID = 1L;
59:
60: public void actionPerformed(final ActionEvent e) {
61: }
62:
63: @Override
64: public Object clone() throws CloneNotSupportedException {
65: return super .clone();
66: }
67: }
68: ;
69: MyAbstractAction instance = new MyAbstractAction();
70: Object value1 = new Object();
71: instance.putValue("Value1", value1);
72: MyAbstractAction anotherInstance = (MyAbstractAction) instance
73: .clone();
74: Object value2 = new Object();
75: instance.putValue("Value1", value2);
76: assertEquals("cloned object's values list isn't shared",
77: value1, anotherInstance.getValue("Value1"));
78: }
79: }
|