views:

13

answers:

1

I'm trying to write some unit tests for my NetBeans module, but i'm unable to get an instance of the FileObject class:


    @Before
    public void setup() throws URISyntaxException{
        URL url = this.getClass().getResource("/project-template/");
        file = new File(url.toURI());

    }

    @Test
    public void testIsProject() throws URISyntaxException {
        FileObject fo = FileUtil.toFileObject(file);

        MyProjectFactory instance = new MyProjectFactory();
        assertTrue( instance.isProject(fo));

    }

The "project-template" folder, under the resources directory contains a valid project,
and altouhg the file is correct, FileObject fo is always null.

A: 

Answering my own question, the MasterFS module is needed for the toFileObject method to work. Just add this to the pom.xml:

<dependency>
        <groupId>org.netbeans.modules</groupId>
        <artifactId>org-netbeans-modules-masterfs</artifactId>
        <version>RELEASE69</version>
        <scope>test</scope>
</dependency>
marcos