1 19 20 package org.netbeans.modules.queries; 21 22 import java.io.File ; 23 import org.netbeans.junit.NbTestCase; 24 25 30 public class ParentChildCollocationQueryTest extends NbTestCase { 31 32 public ParentChildCollocationQueryTest(String testName) { 33 super(testName); 34 } 35 36 public void testAreCollocated() throws Exception { 37 clearWorkDir(); 38 File base = getWorkDir(); 39 File proj1 = new File (base, "proj1"); 40 proj1.mkdirs(); 41 File proj3 = new File (proj1, "proj3"); 42 proj3.mkdirs(); 43 File proj2 = new File (base, "proj2"); 44 proj2.mkdirs(); 45 46 ParentChildCollocationQuery query = new ParentChildCollocationQuery(); 47 assertTrue("Must be collocated", query.areCollocated(proj1, proj3)); 48 assertTrue("Must be collocated", query.areCollocated(proj3, proj1)); 49 assertFalse("Cannot be collocated", query.areCollocated(proj1, proj2)); 50 assertFalse("Cannot be collocated", query.areCollocated(proj2, proj1)); 51 52 File proj4 = new File (base, "proj"); 54 assertFalse("Cannot be collocated", query.areCollocated(proj1, proj4)); 55 assertFalse("Cannot be collocated", query.areCollocated(proj4, proj1)); 56 proj4.mkdirs(); 57 assertFalse("Cannot be collocated", query.areCollocated(proj1, proj4)); 58 assertFalse("Cannot be collocated", query.areCollocated(proj4, proj1)); 59 60 File file1 = new File (base, "file1.txt"); 62 File file2 = new File (base, "file1"); 63 assertFalse("Cannot be collocated", query.areCollocated(file1, file2)); 64 assertFalse("Cannot be collocated", query.areCollocated(file2, file1)); 65 66 assertTrue("A file must be collocated with itself", query.areCollocated(proj1, proj1)); 68 } 69 70 } 71 | Popular Tags |