author | mfang |
Wed, 17 Aug 2011 14:18:26 -0700 | |
changeset 10294 | 8fcdae2a7ec7 |
parent 9652 | d7ab9742e1cf |
permissions | -rw-r--r-- |
9652
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
1 |
/* |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
2 |
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
4 |
* |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
8 |
* |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
13 |
* accompanied this code). |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
14 |
* |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
18 |
* |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
21 |
* questions. |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
22 |
*/ |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
23 |
|
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
24 |
/** |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
25 |
* @test |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
26 |
* @bug 7040717 6522514 |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
27 |
* @summary Verifies that subclasses of Arc2D can be serialized. |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
28 |
* @run main SerializationTest |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
29 |
*/ |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
30 |
|
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
31 |
import java.awt.geom.Rectangle2D; |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
32 |
import java.awt.geom.Arc2D; |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
33 |
import java.io.Serializable; |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
34 |
import java.io.File; |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
35 |
import java.io.FileInputStream; |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
36 |
import java.io.FileOutputStream; |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
37 |
import java.io.ObjectInputStream; |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
38 |
import java.io.ObjectOutputStream; |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
39 |
|
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
40 |
public class SerializationTest { |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
41 |
static boolean failed; |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
42 |
public static void main(String args[]) { |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
43 |
test(new Arc()); |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
44 |
test(new ArcF()); |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
45 |
test(new ArcD()); |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
46 |
if (failed) throw new RuntimeException("some tests failed"); |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
47 |
} |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
48 |
|
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
49 |
public static void test(Object a) { |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
50 |
try { |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
51 |
File objectbin = new File("object.bin"); |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
52 |
FileOutputStream fos = new FileOutputStream(objectbin); |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
53 |
ObjectOutputStream out = new ObjectOutputStream(fos); |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
54 |
out.writeObject(a); |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
55 |
fos.close(); |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
56 |
FileInputStream fis = new FileInputStream(objectbin); |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
57 |
ObjectInputStream in = new ObjectInputStream(fis); |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
58 |
Object o = in.readObject(); |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
59 |
fis.close(); |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
60 |
System.err.println(o); |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
61 |
} catch (Throwable ex) { |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
62 |
ex.printStackTrace(); |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
63 |
failed = true; |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
64 |
} |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
65 |
} |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
66 |
|
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
67 |
static class Arc extends Arc2D implements Serializable { |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
68 |
public Arc() { |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
69 |
super(Arc2D.OPEN); |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
70 |
} |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
71 |
|
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
72 |
public Rectangle2D makeBounds(double x, double y, double w, double h) { |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
73 |
return new Rectangle2D.Double(x, y, w, h); |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
74 |
} |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
75 |
public double getX() { return 0; } |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
76 |
public double getY() { return 0; } |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
77 |
public double getWidth() { return 0; } |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
78 |
public double getHeight() { return 0; } |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
79 |
public double getAngleExtent() { return 0; } |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
80 |
public double getAngleStart() { return 0; } |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
81 |
public void setAngleExtent(double angExt) { } |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
82 |
public void setAngleStart(double angExt) { } |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
83 |
public void setFrame(double x, double y, double w, double h) {} |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
84 |
public void setArc(double x, double y, double w, double h, |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
85 |
double s, double e, int c) |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
86 |
{ |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
87 |
} |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
88 |
public boolean isEmpty() { return false; }; |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
89 |
} |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
90 |
|
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
91 |
static class ArcF extends Arc2D.Float implements Serializable { |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
92 |
public ArcF() { |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
93 |
} |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
94 |
} |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
95 |
|
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
96 |
static class ArcD extends Arc2D.Double implements Serializable { |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
97 |
public ArcD() { |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
98 |
} |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
99 |
} |
d7ab9742e1cf
7040717: Test case for 6522514 was not included in bug fix
flar
parents:
diff
changeset
|
100 |
} |