10ac77ac8e915bff1a863e371f9b363033f9cf759Elliott Hughes/* 20ac77ac8e915bff1a863e371f9b363033f9cf759Elliott Hughes * Copyright (C) 2011 The Android Open Source Project 30ac77ac8e915bff1a863e371f9b363033f9cf759Elliott Hughes * 40ac77ac8e915bff1a863e371f9b363033f9cf759Elliott Hughes * Licensed under the Apache License, Version 2.0 (the "License"); 50ac77ac8e915bff1a863e371f9b363033f9cf759Elliott Hughes * you may not use this file except in compliance with the License. 60ac77ac8e915bff1a863e371f9b363033f9cf759Elliott Hughes * You may obtain a copy of the License at 70ac77ac8e915bff1a863e371f9b363033f9cf759Elliott Hughes * 80ac77ac8e915bff1a863e371f9b363033f9cf759Elliott Hughes * http://www.apache.org/licenses/LICENSE-2.0 90ac77ac8e915bff1a863e371f9b363033f9cf759Elliott Hughes * 100ac77ac8e915bff1a863e371f9b363033f9cf759Elliott Hughes * Unless required by applicable law or agreed to in writing, software 110ac77ac8e915bff1a863e371f9b363033f9cf759Elliott Hughes * distributed under the License is distributed on an "AS IS" BASIS, 120ac77ac8e915bff1a863e371f9b363033f9cf759Elliott Hughes * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 130ac77ac8e915bff1a863e371f9b363033f9cf759Elliott Hughes * See the License for the specific language governing permissions and 140ac77ac8e915bff1a863e371f9b363033f9cf759Elliott Hughes * limitations under the License. 150ac77ac8e915bff1a863e371f9b363033f9cf759Elliott Hughes */ 160ac77ac8e915bff1a863e371f9b363033f9cf759Elliott Hughes 170ac77ac8e915bff1a863e371f9b363033f9cf759Elliott Hughespackage libcore.java.io; 180ac77ac8e915bff1a863e371f9b363033f9cf759Elliott Hughes 190ac77ac8e915bff1a863e371f9b363033f9cf759Elliott Hughesimport java.io.File; 204f263fdfcc0c9e3ebadeaa6717e93a130c09320cElliott Hughesimport java.io.FileInputStream; 210ac77ac8e915bff1a863e371f9b363033f9cf759Elliott Hughesimport java.io.FileNotFoundException; 220ac77ac8e915bff1a863e371f9b363033f9cf759Elliott Hughesimport java.io.IOException; 230ac77ac8e915bff1a863e371f9b363033f9cf759Elliott Hughesimport java.io.RandomAccessFile; 244f263fdfcc0c9e3ebadeaa6717e93a130c09320cElliott Hughesimport java.net.ServerSocket; 250ac77ac8e915bff1a863e371f9b363033f9cf759Elliott Hughesimport junit.framework.TestCase; 260ac77ac8e915bff1a863e371f9b363033f9cf759Elliott Hughes 270ac77ac8e915bff1a863e371f9b363033f9cf759Elliott Hughespublic class FileDescriptorTest extends TestCase { 284f263fdfcc0c9e3ebadeaa6717e93a130c09320cElliott Hughes public void testReadOnlyFileDescriptorSync() throws Exception { 294f263fdfcc0c9e3ebadeaa6717e93a130c09320cElliott Hughes File f= File.createTempFile("FileDescriptorTest", "tmp"); 304f263fdfcc0c9e3ebadeaa6717e93a130c09320cElliott Hughes new RandomAccessFile(f, "r").getFD().sync(); 314f263fdfcc0c9e3ebadeaa6717e93a130c09320cElliott Hughes } 324f263fdfcc0c9e3ebadeaa6717e93a130c09320cElliott Hughes 333a1658cb79ccc96e81eca64966de4ada725a2e54Elliott Hughes public void test_isSocket() throws Exception { 344f263fdfcc0c9e3ebadeaa6717e93a130c09320cElliott Hughes File f = new File("/dev/null"); 354f263fdfcc0c9e3ebadeaa6717e93a130c09320cElliott Hughes FileInputStream fis = new FileInputStream(f); 36160fad7d429f32c4a6b9f1ac6bb028f59e736f46Elliott Hughes assertFalse(fis.getFD().isSocket$()); 374f263fdfcc0c9e3ebadeaa6717e93a130c09320cElliott Hughes fis.close(); 384f263fdfcc0c9e3ebadeaa6717e93a130c09320cElliott Hughes 394f263fdfcc0c9e3ebadeaa6717e93a130c09320cElliott Hughes ServerSocket s = new ServerSocket(); 40035c578a39be09822a0402c850ed3e793956c913Przemyslaw Szczepaniak assertTrue(s.getImpl().getFD$().isSocket$()); 414f263fdfcc0c9e3ebadeaa6717e93a130c09320cElliott Hughes s.close(); 424f263fdfcc0c9e3ebadeaa6717e93a130c09320cElliott Hughes } 430ac77ac8e915bff1a863e371f9b363033f9cf759Elliott Hughes} 44