01: /* Licensed to the Apache Software Foundation (ASF) under one or more
02: * contributor license agreements. See the NOTICE file distributed with
03: * this work for additional information regarding copyright ownership.
04: * The ASF licenses this file to You under the Apache License, Version 2.0
05: * (the "License"); you may not use this file except in compliance with
06: * the License. You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.apache.harmony.luni.tests.java.io;
18:
19: import java.io.File;
20: import java.io.FileOutputStream;
21: import java.io.IOException;
22: import java.io.RandomAccessFile;
23:
24: import junit.framework.TestCase;
25:
26: public class OpenRandomFileTest extends TestCase {
27:
28: public static void main(String[] args) throws IOException {
29: new OpenRandomFileTest().testOpenEmptyFile();
30: }
31:
32: public OpenRandomFileTest() {
33: super ();
34: }
35:
36: public void testOpenNonEmptyFile() throws IOException {
37: File file = File.createTempFile("test", "tmp");
38: assertTrue(file.exists());
39: file.deleteOnExit();
40: FileOutputStream fos = new FileOutputStream(file);
41: fos.write(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
42: fos.close();
43:
44: String fileName = file.getCanonicalPath();
45: RandomAccessFile raf = new RandomAccessFile(fileName, "rw");
46: raf.close();
47: }
48:
49: public void testOpenEmptyFile() throws IOException {
50: File file = File.createTempFile("test", "tmp");
51: assertTrue(file.exists());
52: file.deleteOnExit();
53:
54: String fileName = file.getCanonicalPath();
55: RandomAccessFile raf = new RandomAccessFile(fileName, "rw");
56: raf.close();
57: }
58: }
|