author | yan |
Tue, 23 Jun 2015 11:59:27 +0300 | |
changeset 31448 | 1066345d2a8a |
parent 25197 | 533f45be322f |
permissions | -rw-r--r-- |
25197 | 1 |
/* |
31448
1066345d2a8a
8076468: Add @modules to tests in jdk_desktop test group
yan
parents:
25197
diff
changeset
|
2 |
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. |
25197 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
24 |
/* |
|
25 |
@test |
|
26 |
@bug 4260874 |
|
27 |
@summary Tests that DataFlavor.getReaderForText do not throw NPE when transferObject is null |
|
28 |
@author tdv@sparc.spb.su: area= |
|
31448
1066345d2a8a
8076468: Add @modules to tests in jdk_desktop test group
yan
parents:
25197
diff
changeset
|
29 |
@modules java.datatransfer |
25197 | 30 |
@run main GetReaderForTextIAEForStringSelectionTest |
31 |
*/ |
|
32 |
||
33 |
import java.awt.datatransfer.DataFlavor; |
|
34 |
import java.awt.datatransfer.StringSelection; |
|
35 |
import java.awt.datatransfer.Transferable; |
|
36 |
import java.awt.datatransfer.UnsupportedFlavorException; |
|
37 |
import java.io.IOException; |
|
38 |
import java.io.Reader; |
|
39 |
||
40 |
public class GetReaderForTextIAEForStringSelectionTest { |
|
41 |
||
42 |
public static void main(String[] args) throws Exception { |
|
43 |
DataFlavor pt ; |
|
44 |
||
45 |
try { |
|
46 |
pt = DataFlavor.plainTextFlavor; |
|
47 |
StringSelection ss = new StringSelection("ReaderExample"); |
|
48 |
Reader re = pt.getReaderForText(ss); |
|
49 |
if(re == null) { |
|
50 |
throw new RuntimeException("Test FAILED! reader==null"); |
|
51 |
} |
|
52 |
} catch (Exception e) { |
|
53 |
throw new RuntimeException("Test FAILED because of the exception: " + e); |
|
54 |
} |
|
55 |
} |
|
56 |
||
57 |
} |
|
58 |
||
59 |
class FakeTransferable implements Transferable { |
|
60 |
public DataFlavor[] getTransferDataFlavors() { |
|
61 |
return null; |
|
62 |
} |
|
63 |
public boolean isDataFlavorSupported(DataFlavor flavor) { |
|
64 |
return false; |
|
65 |
} |
|
66 |
public Object getTransferData(DataFlavor flavor) throws |
|
67 |
UnsupportedFlavorException, IOException { |
|
68 |
return null; |
|
69 |
} |
|
70 |
} |
|
71 |