1 19 20 package org.netbeans.modules.projectimport.j2seimport; 21 import junit.framework.*; 22 import org.netbeans.junit.NbTestCase; 23 import org.openide.filesystems.FileObject; 24 import org.openide.filesystems.FileUtil; 25 26 27 31 public class DependencyValidatorTest extends NbTestCase { 32 33 static { 34 System.setProperty("projectimport.logging.level", "WARNING"); 35 } 36 37 public DependencyValidatorTest(String testName) { 38 super(testName); 39 } 40 41 protected void setUp() throws Exception { 42 } 43 44 protected void tearDown() throws Exception { 45 } 46 47 public static Test suite() { 48 TestSuite suite = new TestSuite(DependencyValidatorTest.class); 49 50 return suite; 51 } 52 53 56 public void testIsValid() throws Exception { 57 FileObject dir = FileUtil.toFileObject(getWorkDir()); 58 AbstractProject d = new AbstractProject("d", dir); 59 AbstractProject c = new AbstractProject("c", dir); 60 c.addDependency(d); 61 AbstractProject b = new AbstractProject("b", dir); 62 b.addDependency(c); 63 AbstractProject a = new AbstractProject("a", dir); 64 a.addDependency(b); 65 66 67 68 69 DependencyValidator dv = DependencyValidator.checkProject(a); 70 assertTrue(dv.isValid()); 71 72 dv = DependencyValidator.checkProject(b); 73 assertTrue(dv.isValid()); 74 75 dv = DependencyValidator.checkProject(c); 76 assertTrue(dv.isValid()); 77 78 dv = DependencyValidator.checkProject(d); 79 assertTrue(dv.isValid()); 80 81 82 d.addDependency(a); 83 dv = DependencyValidator.checkProject(a); 84 assertFalse(dv.isValid()); 85 86 dv = DependencyValidator.checkProject(b); 87 assertFalse(dv.isValid()); 88 89 dv = DependencyValidator.checkProject(c); 90 assertFalse(dv.isValid()); 91 92 dv = DependencyValidator.checkProject(d); 93 assertFalse(dv.isValid()); 94 } 95 96 } 97 | Popular Tags |