代码之家  ›  专栏  ›  技术社区  ›  marcosbeirigo

NetBeans模块-如何获取要测试的FileObject实例

  •  0
  • marcosbeirigo  · 技术社区  · 14 年前

    
        @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));
    
        }
    
    

    资源目录下的“项目模板”文件夹包含有效的项目,
    而阿尔图赫 file 是正确的, FileObject fo

    1 回复  |  直到 14 年前
        1
  •  0
  •   marcosbeirigo    14 年前

    回答我自己的问题,MasterFS模块是 toFileObject 工作方法。只需将其添加到pom.xml中:

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