1/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
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
17package libcore.java.io;
18
19import java.io.File;
20import java.io.FileInputStream;
21import java.io.FileNotFoundException;
22import java.io.IOException;
23import java.io.RandomAccessFile;
24import java.net.ServerSocket;
25import junit.framework.TestCase;
26
27public class FileDescriptorTest extends TestCase {
28  public void testReadOnlyFileDescriptorSync() throws Exception {
29    File f= File.createTempFile("FileDescriptorTest", "tmp");
30    new RandomAccessFile(f, "r").getFD().sync();
31  }
32
33  public void test_isSocket$() throws Exception {
34    File f = new File("/dev/null");
35    FileInputStream fis = new FileInputStream(f);
36    assertFalse(fis.getFD().isSocket$());
37    fis.close();
38
39    ServerSocket s = new ServerSocket();
40    assertTrue(s.getImpl$().getFD$().isSocket$());
41    s.close();
42  }
43}
44