aboutsummaryrefslogtreecommitdiffstats
path: root/vespajlib/src/test/java/com/yahoo/io/NativeIOTestCase.java
blob: 91144d5999f1a37ad99d1899d0b21aa66b4b08fb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.yahoo.io;

import com.sun.jna.Platform;
import org.junit.Test;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;


public class NativeIOTestCase {

    @Test
    public void requireThatDropFileFromCacheDoesNotThrow() throws IOException {
        File testFile = new File("testfile");
        FileOutputStream output = new FileOutputStream(testFile);
        output.write('t');
        output.flush();
        output.close();
        try {
            NativeIO nativeIO = new NativeIO();
            nativeIO.dropFileFromCache(output.getFD());
            nativeIO.dropFileFromCache(testFile);
        } catch (Throwable e) {
            if (Platform.isLinux()) {
                assertTrue(false);
            } else {
                assertEquals("Platform is unsúpported. Only supported on linux.", e.getMessage());
            }
        }
    }
}