KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > projectimport > j2seimport > DependencyValidatorTest


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

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 /**
28  *
29  * @author Radek Matous
30  */

31 public class DependencyValidatorTest extends NbTestCase {
32
33     static {
34         System.setProperty("projectimport.logging.level", "WARNING");
35     }
36
37     public DependencyValidatorTest(String JavaDoc testName) {
38         super(testName);
39     }
40
41     protected void setUp() throws Exception JavaDoc {
42     }
43
44     protected void tearDown() throws Exception JavaDoc {
45     }
46
47     public static Test suite() {
48         TestSuite suite = new TestSuite(DependencyValidatorTest.class);
49         
50         return suite;
51     }
52
53     /**
54      * Test of isValid method, of class org.netbeans.modules.projectimport.jbuilder.elementary.utilities.DependencyValidator.
55      */

56     public void testIsValid() throws Exception JavaDoc {
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