1 /* WriteMethods.java -- Test File write methods of classpath 1.6 |
|
2 Copyright (C) 2007 Mario Torre <neugens@limasoftware.net> |
|
3 This file is part of Mauve. |
|
4 |
|
5 Mauve is free software; you can redistribute it and/or modify |
|
6 it under the terms of the GNU General Public License as published by |
|
7 the Free Software Foundation; either version 2, or (at your option) |
|
8 any later version. |
|
9 |
|
10 Mauve is distributed in the hope that it will be useful, but |
|
11 WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 General Public License for more details. |
|
14 |
|
15 You should have received a copy of the GNU General Public License |
|
16 along with Mauve; see the file COPYING. If not, write to the |
|
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 02110-1301 USA. |
|
19 |
|
20 */ |
|
21 |
|
22 //Tags: JDK1.6 |
|
23 |
|
24 package gnu.testlet.java.io.File; |
|
25 |
|
26 import java.io.File; |
|
27 import java.io.IOException; |
|
28 |
|
29 import gnu.testlet.TestHarness; |
|
30 import gnu.testlet.Testlet; |
|
31 |
|
32 /** |
|
33 * Test File write methods of classpath 1.6 |
|
34 * |
|
35 * @author Mario Torre <neugens@limasoftware.net> |
|
36 */ |
|
37 public class WriteMethods |
|
38 implements Testlet |
|
39 { |
|
40 /* |
|
41 * (non-Javadoc) |
|
42 * |
|
43 * @see gnu.testlet.Testlet#test(gnu.testlet.TestHarness) |
|
44 */ |
|
45 public void test(TestHarness harness) |
|
46 { |
|
47 String tmp = harness.getTempDirectory(); |
|
48 File tmpfile = new File(tmp, "mauve-testfile"); |
|
49 |
|
50 try |
|
51 { |
|
52 tmpfile.createNewFile(); |
|
53 } |
|
54 catch (IOException e) |
|
55 { |
|
56 harness.fail("cannot create file for test."); |
|
57 return; |
|
58 } |
|
59 |
|
60 boolean write = tmpfile.canWrite(); |
|
61 |
|
62 harness.check(write); |
|
63 |
|
64 write = tmpfile.setWritable(false); |
|
65 harness.check(write == true); |
|
66 |
|
67 write = tmpfile.canWrite(); |
|
68 harness.check(write == false); |
|
69 |
|
70 tmpfile.delete(); |
|
71 } |
|
72 } |
|