aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/com/jogamp/gluegen/jcpp/JavaFileSystemTest.java
blob: 3477d972caedad3ca095ff5918d8b6cae66a53ec (plain)
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
36
37
38
39
40
41
42
43
44
45
46
package com.jogamp.gluegen.jcpp;

import java.io.FileNotFoundException;

import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;

import com.jogamp.junit.util.SingletonJunitCase;

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

@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class JavaFileSystemTest extends SingletonJunitCase {

    @Test
    public void testJavaFileSystem() throws Exception {
        final JavaFileSystem fs = new JavaFileSystem();
        VirtualFile f;

        /* Anyone who has this file on their Unix box is messed up. */
        f = fs.getFile("/foo/bar baz");
        try {
            f.getSource();	/* drop on floor */

            assertTrue("Got a source for a non-file", f.isFile());
        } catch (final FileNotFoundException e) {
            assertFalse("Got no source for a file", f.isFile());
        }

        /* We hope we have this. */
        f = fs.getFile("/usr/include/stdio.h");
        try {
            f.getSource();	/* drop on floor */

            System.out.println("Opened stdio.h");
            assertTrue("Got a source for a non-file", f.isFile());
        } catch (final FileNotFoundException e) {
            System.out.println("Failed to open stdio.h");
            assertFalse("Got no source for a file", f.isFile());
        }

    }

}