1 19 20 package org.netbeans.modules.apisupport.project.queries; 21 22 import java.net.URI ; 23 import java.io.File ; 24 import java.net.URL ; 25 import java.util.Arrays ; 26 import java.util.Collections ; 27 import org.netbeans.api.java.queries.UnitTestForSourceQuery; 28 import org.netbeans.modules.apisupport.project.TestBase; 29 import org.openide.filesystems.FileObject; 30 import org.openide.filesystems.URLMapper; 31 32 36 public class UnitTestForSourceQueryImplTest extends TestBase { 37 38 public UnitTestForSourceQueryImplTest(String testName) { 39 super(testName); 40 } 41 42 public void testFindUnitTest() throws Exception { 43 URL [] testRoots = UnitTestForSourceQuery.findUnitTests(nbCVSRoot()); 44 assertEquals("Test root for non project folder should be null", Collections.EMPTY_LIST, Arrays.asList(testRoots)); 45 FileObject srcRoot = nbCVSRoot().getFileObject("apisupport/project"); 46 testRoots = UnitTestForSourceQuery.findUnitTests(srcRoot); 47 assertEquals("Test root for project should be null", Collections.EMPTY_LIST, Arrays.asList(testRoots)); 48 srcRoot = nbCVSRoot().getFileObject("apisupport/project/test/unit/src"); 49 testRoots = UnitTestForSourceQuery.findUnitTests(srcRoot); 50 assertEquals("Test root for tests should be null", Collections.EMPTY_LIST, Arrays.asList(testRoots)); 51 srcRoot = nbCVSRoot().getFileObject("apisupport/project/src"); 52 testRoots = UnitTestForSourceQuery.findUnitTests(srcRoot); 53 assertEquals("Test root defined", 1, testRoots.length); 54 assertTrue("Test root exists", new File (URI.create(testRoots[0].toExternalForm())).exists()); 55 assertEquals("Test root", URLMapper.findFileObject(testRoots[0]), nbCVSRoot().getFileObject("apisupport/project/test/unit/src")); 56 assertEquals("One test for this project", 1, UnitTestForSourceQuery.findUnitTests(nbCVSRoot().getFileObject("openide/windows/src")).length); 57 } 58 59 public void testFindSource() { 60 URL [] srcRoots = UnitTestForSourceQuery.findSources(nbCVSRoot()); 61 assertEquals("Source root for non project folder should be null", Collections.EMPTY_LIST, Arrays.asList(srcRoots)); 62 FileObject testRoot = nbCVSRoot().getFileObject("apisupport/project"); 63 srcRoots = UnitTestForSourceQuery.findSources(testRoot); 64 assertEquals("Source root for project should be null", Collections.EMPTY_LIST, Arrays.asList(srcRoots)); 65 testRoot = nbCVSRoot().getFileObject("apisupport/project/src"); 66 srcRoots = UnitTestForSourceQuery.findSources(testRoot); 67 assertEquals("Source root for sources should be null", Collections.EMPTY_LIST, Arrays.asList(srcRoots)); 68 assertEquals("No sources for this project's sources", Collections.EMPTY_LIST, Arrays.asList(UnitTestForSourceQuery.findSources(nbCVSRoot().getFileObject("openide/windows/src")))); 69 testRoot = nbCVSRoot().getFileObject("apisupport/project/test/unit/src"); 70 srcRoots = UnitTestForSourceQuery.findSources(testRoot); 71 assertEquals("Source root defined", 1, srcRoots.length); 72 assertTrue("Source root exists", new File (URI.create(srcRoots[0].toExternalForm())).exists()); 73 assertEquals("Source root", URLMapper.findFileObject(srcRoots[0]), nbCVSRoot().getFileObject("apisupport/project/src")); 74 } 75 76 } 77 | Popular Tags |