This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 80704
Collapse All | Expand All

(-)src/org/netbeans/modules/apisupport/project/universe/TestModuleDependency.java (+84 lines)
Added Link Here
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.apisupport.project.universe;
21
22
import java.util.Comparator;
23
24
/**
25
 * Test dependedency entry from project.xml
26
 * @author pzajac
27
 */
28
public class TestModuleDependency {
29
    public static final String UNIT = "unit"; // NOI18N
30
    public static final String QA_FUNCTIONAL = "qa-functional"; // NOI18N 
31
    private final ModuleEntry module;
32
    // dependendends also on tests of modules
33
    private boolean test;
34
    // depends on execution classpath of the modules
35
    private boolean recursive;
36
    // compilation dependency 
37
    private boolean compile;
38
39
    public static final Comparator CNB_COMPARATOR = new CndsComparator();
40
    
41
    private static final class CndsComparator implements Comparator {
42
        public int compare(Object tmd1,Object tmd2) {
43
            return ((TestModuleDependency)tmd1).module.getCodeNameBase().compareTo(((TestModuleDependency)tmd2).module.getCodeNameBase());
44
        }
45
    }
46
    /**
47
     * Creates a new instance of TestModuleDependency
48
     */
49
    public TestModuleDependency(ModuleEntry me,boolean test,boolean recursive,boolean compile) {
50
        this.module = me;
51
        this.setTest(test);
52
        this.setRecursive(recursive);
53
        this.setCompile(compile);
54
    }
55
56
    public ModuleEntry getModule() {
57
        return module;
58
    }
59
60
    public boolean isTest() {
61
        return test;
62
    }
63
64
    public void setTest(boolean test) {
65
        this.test = test;
66
    }
67
68
    public boolean isRecursive() {
69
        return recursive;
70
    }
71
72
    public void setRecursive(boolean recursive) {
73
        this.recursive = recursive;
74
    }
75
76
    public boolean isCompile() {
77
        return compile;
78
    }
79
80
    public void setCompile(boolean compile) {
81
        this.compile = compile;
82
    }
83
    
84
}
(-)test/unit/src/org/netbeans/modules/apisupport/project/queries/ClassPathProviderImplTest.java (-3 / +35 lines)
Lines 22-27 Link Here
22
import java.io.File;
22
import java.io.File;
23
import java.io.FileOutputStream;
23
import java.io.FileOutputStream;
24
import java.io.OutputStream;
24
import java.io.OutputStream;
25
import java.io.PrintStream;
25
import java.net.URL;
26
import java.net.URL;
26
import java.util.ArrayList;
27
import java.util.ArrayList;
27
import java.util.Arrays;
28
import java.util.Arrays;
Lines 108-113 Link Here
108
        "org-netbeans-modules-nbjunit.jar",
109
        "org-netbeans-modules-nbjunit.jar",
109
        "org-netbeans-modules-nbjunit-ide.jar",
110
        "org-netbeans-modules-nbjunit-ide.jar",
110
    }));
111
    }));
112
    
113
    private void assertSets(String message,Set set1, Set set2 ) {
114
        StringBuffer result = new StringBuffer();
115
        boolean pass = true;
116
        for (Iterator it = set1.iterator() ; it.hasNext() ; ) {
117
            Object obj = it.next();
118
            if (!set2.contains(obj)) {
119
                pass = false;
120
                result.append("- " + obj + "\n");
121
            }
122
        }
123
        for (Iterator it = set2.iterator() ; it.hasNext() ; ) {
124
            Object obj = it.next();
125
            if (!set1.contains(obj)) {
126
                pass = false;
127
                result.append("+ " + obj + "\n");
128
            }
129
        }
130
        assertTrue(message + "\n" + result,pass);
131
    }
132
 
111
    private Set/*<String>*/ urlsOfCp4Tests(ClassPath cp) {
133
    private Set/*<String>*/ urlsOfCp4Tests(ClassPath cp) {
112
        Set/*<String>*/ s = new TreeSet();
134
        Set/*<String>*/ s = new TreeSet();
113
        Iterator it = cp.entries().iterator();
135
        Iterator it = cp.entries().iterator();
Lines 295-307 Link Here
295
        expectedRoots.add("nbjunit.jar");
317
        expectedRoots.add("nbjunit.jar");
296
        expectedRoots.add("nbjunit-ide.jar");
318
        expectedRoots.add("nbjunit-ide.jar");
297
        expectedRoots.add("insanelib.jar");
319
        expectedRoots.add("insanelib.jar");
298
        assertEquals("right COMPILE classpath", expectedRoots.toString(), urlsOfCp4Tests(cp).toString());
320
        // recursive dependencies
321
        expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-netbeans-swing-plaf.jar"));
322
        expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-text.jar"));
323
        
324
//        assertEquals("right COMPILE classpath", expectedRoots.toString(), urlsOfCp4Tests(cp).toString());
325
        assertSets("right COMPILE classpath", expectedRoots, urlsOfCp4Tests(cp));
326
        
299
        cp = ClassPath.getClassPath(src, ClassPath.EXECUTE);
327
        cp = ClassPath.getClassPath(src, ClassPath.EXECUTE);
300
        assertNotNull("have an EXECUTE classpath", cp);
328
        assertNotNull("have an EXECUTE classpath", cp);
301
        expectedRoots.add(urlForDir("autoupdate/build/test/unit/classes"));
329
        expectedRoots.add(urlForDir("autoupdate/build/test/unit/classes"));
302
        // test.unit.run.cp.extra:
330
        // test.unit.run.cp.extra:
303
        expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/lib/boot.jar"));
331
        expectedRoots.add(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/lib/boot.jar"));
304
        assertEquals("right EXECUTE classpath (COMPILE plus classes)", expectedRoots.toString(), urlsOfCp4Tests(cp).toString());
332
//        assertEquals("right EXECUTE classpath (COMPILE plus classes)", expectedRoots.toString(), urlsOfCp4Tests(cp).toString());
333
        assertSets("right EXECUTE classpath (COMPILE plus classes)", expectedRoots, urlsOfCp4Tests(cp));
305
        cp = ClassPath.getClassPath(src, ClassPath.SOURCE);
334
        cp = ClassPath.getClassPath(src, ClassPath.SOURCE);
306
        assertNotNull("have a SOURCE classpath", cp);
335
        assertNotNull("have a SOURCE classpath", cp);
307
        assertEquals("right SOURCE classpath", Collections.singleton(src), new HashSet(Arrays.asList(cp.getRoots())));
336
        assertEquals("right SOURCE classpath", Collections.singleton(src), new HashSet(Arrays.asList(cp.getRoots())));
Lines 424-429 Link Here
424
        assertNull ("ClassPath.SOURCE for build/test must be null",ClassPath.getClassPath(testBuildClasses, ClassPath.SOURCE));
453
        assertNull ("ClassPath.SOURCE for build/test must be null",ClassPath.getClassPath(testBuildClasses, ClassPath.SOURCE));
425
        assertNull ("ClassPath.COMPILE for build/test must be null",ClassPath.getClassPath(testBuildClasses, ClassPath.COMPILE));
454
        assertNull ("ClassPath.COMPILE for build/test must be null",ClassPath.getClassPath(testBuildClasses, ClassPath.COMPILE));
426
        cp = ClassPath.getClassPath(testBuildClasses, ClassPath.EXECUTE);
455
        cp = ClassPath.getClassPath(testBuildClasses, ClassPath.EXECUTE);
456
        
427
        String path = ((NbModuleProject)prj).evaluator().getProperty("test.unit.run.cp.extra");     //NOI18N
457
        String path = ((NbModuleProject)prj).evaluator().getProperty("test.unit.run.cp.extra");     //NOI18N
428
        List trExtra = new ArrayList ();
458
        List trExtra = new ArrayList ();
429
        if (path != null) {
459
        if (path != null) {
Lines 448-453 Link Here
448
                ClassPathSupport.createClassPath(new FileObject[] {testBuildClasses}),
478
                ClassPathSupport.createClassPath(new FileObject[] {testBuildClasses}),
449
                tccp,
479
                tccp,
450
                ClassPathSupport.createClassPath(trExtra),
480
                ClassPathSupport.createClassPath(trExtra),
481
                ClassPathSupport.createClassPath(new URL[] {new URL(urlForJar("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-netbeans-modules-masterfs.jar"))})
451
        });
482
        });
452
        assertClassPathsHaveTheSameResources(cp, expectedCp);
483
        assertClassPathsHaveTheSameResources(cp, expectedCp);
453
484
Lines 594-600 Link Here
594
    }
625
    }
595
    
626
    
596
    private void assertClassPathsHaveTheSameResources(ClassPath actual, ClassPath expected) {
627
    private void assertClassPathsHaveTheSameResources(ClassPath actual, ClassPath expected) {
597
        assertEquals(urlsOfCp(expected).toString(), urlsOfCp(actual).toString());
628
//        assertEquals(urlsOfCp(expected).toString(), urlsOfCp(actual).toString());
629
        assertSets("cls: ",urlsOfCp(expected), urlsOfCp(actual));
598
    }
630
    }
599
    
631
    
600
    public void testTransitiveExecuteClasspath() throws Exception { // #70206
632
    public void testTransitiveExecuteClasspath() throws Exception { // #70206
(-)src/org/netbeans/modules/apisupport/project/Evaluator.java (-4 / +215 lines)
Lines 45-50 Link Here
45
import org.netbeans.api.java.platform.JavaPlatform;
45
import org.netbeans.api.java.platform.JavaPlatform;
46
import org.netbeans.api.java.platform.JavaPlatformManager;
46
import org.netbeans.api.java.platform.JavaPlatformManager;
47
import org.netbeans.api.project.ProjectManager;
47
import org.netbeans.api.project.ProjectManager;
48
import org.netbeans.modules.apisupport.project.universe.TestModuleDependency;
48
import org.netbeans.modules.apisupport.project.universe.ModuleEntry;
49
import org.netbeans.modules.apisupport.project.universe.ModuleEntry;
49
import org.netbeans.modules.apisupport.project.universe.ModuleList;
50
import org.netbeans.modules.apisupport.project.universe.ModuleList;
50
import org.netbeans.spi.project.support.ant.AntProjectEvent;
51
import org.netbeans.spi.project.support.ant.AntProjectEvent;
Lines 81-86 Link Here
81
    /** See issue #69440 for more details. */
82
    /** See issue #69440 for more details. */
82
    private boolean runInAtomicAction;
83
    private boolean runInAtomicAction;
83
    
84
    
85
     static class TestClasspath {
86
        String compile;
87
        String runtime;
88
        String testCompile;
89
        String testRuntime;
90
        public TestClasspath() {
91
            compile = "";
92
            runtime = "";
93
            testCompile = "";
94
            testRuntime = "";
95
        }
96
        public String getCompileClasspath() {
97
            return compile + ":" + testCompile;
98
        }
99
        public String getRuntimeClasspath() {
100
            return runtime + ":" + testRuntime;
101
        }
102
103
        private static TestClasspath getOrEmpty(Map testsCPs, String testtype) {
104
            TestClasspath tcp = (TestClasspath) testsCPs.get(testtype);
105
            if (tcp == null ) {
106
                tcp = new TestClasspath();
107
            }
108
            return tcp;
109
        }
110
    }
84
    public Evaluator(NbModuleProject project, NbModuleTypeProvider typeProvider) {
111
    public Evaluator(NbModuleProject project, NbModuleTypeProvider typeProvider) {
85
        this.project = project;
112
        this.project = project;
86
        this.typeProvider = typeProvider;
113
        this.typeProvider = typeProvider;
Lines 303-308 Link Here
303
            buildDefaults.put("cp.extra", ""); // NOI18N
330
            buildDefaults.put("cp.extra", ""); // NOI18N
304
            buildDefaults.put("cp", "${module.classpath}:${cp.extra}"); // NOI18N
331
            buildDefaults.put("cp", "${module.classpath}:${cp.extra}"); // NOI18N
305
            buildDefaults.put("run.cp", computeRuntimeModuleClasspath(ml) + ":${cp.extra}:${build.classes.dir}"); // NOI18N
332
            buildDefaults.put("run.cp", computeRuntimeModuleClasspath(ml) + ":${cp.extra}:${build.classes.dir}"); // NOI18N
333
            
306
            baseEval = PropertyUtils.sequentialPropertyEvaluator(predefs, (PropertyProvider[]) providers.toArray(new PropertyProvider[providers.size()]));
334
            baseEval = PropertyUtils.sequentialPropertyEvaluator(predefs, (PropertyProvider[]) providers.toArray(new PropertyProvider[providers.size()]));
307
            buildDefaults.put("test.unit.cp.extra", ""); // NOI18N
335
            buildDefaults.put("test.unit.cp.extra", ""); // NOI18N
308
            String testJars; // #68685 - follow Ant script
336
            String testJars; // #68685 - follow Ant script
Lines 339-347 Link Here
339
                        "${netbeans.user}/modules/org-netbeans-modules-nbjunit.jar:" + // NOI18N, new for 6.0
367
                        "${netbeans.user}/modules/org-netbeans-modules-nbjunit.jar:" + // NOI18N, new for 6.0
340
                        "${netbeans.user}/modules/org-netbeans-modules-nbjunit-ide.jar"; // NOI18N, new for 6.0
368
                        "${netbeans.user}/modules/org-netbeans-modules-nbjunit-ide.jar"; // NOI18N, new for 6.0
341
            }
369
            }
342
            buildDefaults.put("test.unit.cp", "${cp}:${cluster}/${module.jar}:" + testJars + ":${test.unit.cp.extra}"); // NOI18N
370
            Map/*<String,TestClassPath>*/ testsCPs = computeTestingClassPaths(ml,baseEval);
371
            TestClasspath tcp = TestClasspath.getOrEmpty(testsCPs,"unit");
372
            
373
            buildDefaults.put("test.unit.cp", "${cp}:${cluster}/${module.jar}:" + testJars + ":${test.unit.cp.extra}:" + tcp.getCompileClasspath()); // NOI18N
343
            buildDefaults.put("test.unit.run.cp.extra", ""); // NOI18N
374
            buildDefaults.put("test.unit.run.cp.extra", ""); // NOI18N
344
            buildDefaults.put("test.unit.run.cp", "${test.unit.cp}:${build.test.unit.classes.dir}:${test.unit.run.cp.extra}"); // NOI18N
375
            buildDefaults.put("test.unit.run.cp", "${test.unit.cp}:${build.test.unit.classes.dir}:${test.unit.run.cp.extra}:"+ tcp.getRuntimeClasspath()); // NOI18N
345
            // #61085: need to treat qa-functional tests the same way...
376
            // #61085: need to treat qa-functional tests the same way...
346
            buildDefaults.put("test.qa-functional.cp.extra", ""); // NOI18N
377
            buildDefaults.put("test.qa-functional.cp.extra", ""); // NOI18N
347
            // No idea how XTest finds these, some weird magic, so no Ant script to match up to:
378
            // No idea how XTest finds these, some weird magic, so no Ant script to match up to:
Lines 353-366 Link Here
353
            if (jelly2NbJar != null) {
384
            if (jelly2NbJar != null) {
354
                buildDefaults.put("jelly2-nb.jar", jelly2NbJar); // NOI18N
385
                buildDefaults.put("jelly2-nb.jar", jelly2NbJar); // NOI18N
355
            }
386
            }
387
            tcp = TestClasspath.getOrEmpty(testsCPs,"qa-functional");
356
            buildDefaults.put("test.qa-functional.cp", testJars + // NOI18N
388
            buildDefaults.put("test.qa-functional.cp", testJars + // NOI18N
357
                    ":${netbeans.home}/../testtools/modules/ext/nbjunit-ide.jar" + // NOI18N
389
                    ":${netbeans.home}/../testtools/modules/ext/nbjunit-ide.jar" + // NOI18N
358
                    ":${netbeans.user}/testtools/modules/ext/nbjunit.jar" + // NOI18N
390
                    ":${netbeans.user}/testtools/modules/ext/nbjunit.jar" + // NOI18N
359
                    ":${jemmy.jar}" + // NOI18N
391
                    ":${jemmy.jar}" + // NOI18N
360
                    ":${jelly2-nb.jar}" + // NOI18N
392
                    ":${jelly2-nb.jar}" + // NOI18N
361
                    ":${test.qa-functional.cp.extra}"); // NOI18N
393
                    ":${test.qa-functional.cp.extra}:" + 
394
                     tcp.compile + ":" + tcp.testCompile); // NOI18N
362
            buildDefaults.put("build.test.qa-functional.classes.dir", "build/test/qa-functional/classes"); // NOI18N
395
            buildDefaults.put("build.test.qa-functional.classes.dir", "build/test/qa-functional/classes"); // NOI18N
363
            buildDefaults.put("test.qa-functional.run.cp", "${test.qa-functional.cp}:${build.test.qa-functional.classes.dir}"); // NOI18N
396
            buildDefaults.put("test.qa-functional.run.cp", "${test.qa-functional.cp}:${build.test.qa-functional.classes.dir}" + ":" + tcp.runtime + ":" + tcp.testRuntime); // NOI18N
364
            providers.add(PropertyUtils.fixedPropertyProvider(buildDefaults));
397
            providers.add(PropertyUtils.fixedPropertyProvider(buildDefaults));
365
        }
398
        }
366
        // skip a bunch of properties irrelevant here - NBM stuff, etc.
399
        // skip a bunch of properties irrelevant here - NBM stuff, etc.
Lines 618-622 Link Here
618
        }
651
        }
619
        return cp.toString();
652
        return cp.toString();
620
    }
653
    }
654
655
    //
656
    /** parse classpath for tests from project.xml
657
     *  @retun Map String testtype -> TestClasspath
658
     */
659
    private Map computeTestingClassPaths(ModuleList ml,PropertyEvaluator evaluator) {
660
        
661
        
662
        Map /*<String,String>*/ classpaths = new HashMap();
663
        Map /*<String,Set<TestModuleDepency>>*/ testTypes = getTestDependencies(ml);
664
 
665
        String testDistDir =  evaluator.getProperty("test.dist.dir"); // NOI18N
666
        if (testDistDir == null) {
667
               NbModuleTypeProvider.NbModuleType type = typeProvider.getModuleType();
668
               if (type == NbModuleTypeProvider.NETBEANS_ORG) {
669
                   // test.dist.dir = ${nb_all}/nbbuild/build/testdist
670
                   String nball = evaluator.getProperty("nb_all"); // NOI18N
671
                   testDistDir = nball + File.separatorChar + "nbbuild" + File.separatorChar + "build" + File.separatorChar + "testdist"; // NOI18N 
672
               } else if ( type == NbModuleTypeProvider.SUITE_COMPONENT) {
673
                   // test.dist.dir = ${suite.dir}/build/testdist
674
                   String suiteDir = evaluator.getProperty("suite.dir"); // NOI18N
675
                   testDistDir = suiteDir + File.separatorChar + "build" + File.separatorChar + "testdist"; // NOI18N
676
               } else {
677
                   // standalone module 
678
                   // test.dist.dir = ${module.dir}/build/testdist
679
                   String moduleDir = evaluator.getProperty("module.dir"); // NOI18N
680
                   testDistDir = moduleDir + File.separatorChar + "build" + File.separatorChar + "testdist";
681
               }         
682
        }
683
        for (Iterator ttIt = testTypes.entrySet().iterator() ; ttIt.hasNext() ; ) {
684
           Map.Entry entry = (Map.Entry) ttIt.next(); 
685
           String ttName = (String)entry.getKey(); 
686
           Set ttModules = (Set)entry.getValue();
687
           computeTestType(ttName,new File(testDistDir),ttModules,classpaths,ml);
688
        }
689
        return classpaths;
690
    }
691
    private Map /*<String,Set<TestModuleDepency>>*/getTestDependencies(ModuleList ml) {
692
        Element data = project.getHelper().getPrimaryConfigurationData(true);
693
        Element pp = Util.findElement(data,
694
            "test-dependencies", NbModuleProjectType.NAMESPACE_SHARED); // NOI18N
621
    
695
    
696
        
697
        Map/*<String,SortedSet<TestModuleDepency>>*/ testDeps = new HashMap();
698
     
699
        if (pp != null) {
700
            for (Iterator depssIt = Util.findSubElements(pp).iterator(); depssIt.hasNext();) {
701
                Element depssEl = (Element) depssIt.next();
702
                Element testTypeEl = Util.findElement(depssEl,"name",NbModuleProjectType.NAMESPACE_SHARED); 
703
                String testType = null;
704
                if (testTypeEl != null) {
705
                    testType = Util.findText(testTypeEl);
706
                }
707
                if (testType == null) {
708
                    testType = TestModuleDependency.UNIT; // default variant
709
                }
710
                Set/*<TestModuleDependency>*/ directTestDeps = new HashSet();
711
                
712
                testDeps.put(testType,directTestDeps);
713
                for (Iterator depsIt = Util.findSubElements(depssEl).iterator() ; depsIt.hasNext();) {
714
                    Element el = (Element) depsIt.next();
715
                    if (el.getTagName().equals("test-dependency")) {
716
                        // parse test dep
717
                        boolean  test = Util.findElement(el,"test",NbModuleProjectType.NAMESPACE_SHARED) != null;
718
                        Element cnbEl = Util.findElement(el,"code-name-base",NbModuleProjectType.NAMESPACE_SHARED);
719
                        
720
                        String cnb =  null;
721
                        if (cnbEl != null) {
722
                            cnb = Util.findText(cnbEl); 
723
                        }
724
                        boolean  recursive = Util.findElement(el,"recursive",NbModuleProjectType.NAMESPACE_SHARED) != null;
725
                        boolean  compile = Util.findElement(el,"compile-dependency",NbModuleProjectType.NAMESPACE_SHARED) != null;
726
                        if (cnb != null) {
727
                            ModuleEntry me = ml.getEntry(cnb);
728
                            // [TOOD] show error module is 
729
                            if (me != null) {
730
                                directTestDeps.add(new TestModuleDependency(me,test,recursive,compile));
731
                            }
732
                        }
733
                    }
734
                 }
735
              }
736
         }
737
         return testDeps;
738
    }
739
740
   
741
    private void computeTestType(String ttName,File testDistDir, Set ttModules, Map/*<String,TestClasspath>*/ classpaths,ModuleList ml) {
742
  
743
        Set compileCnds = new HashSet();
744
        Set runtimeCnds = new HashSet();
745
        Set testCompileCnds = new HashSet();
746
        Set testRuntimeCnds = new HashSet();
747
        
748
        Set processedRecursive = new HashSet();
749
        for (Iterator it = ttModules.iterator() ; it.hasNext();) {
750
            TestModuleDependency td = (TestModuleDependency) it.next();
751
            String cnd = td.getModule().getCodeNameBase();
752
            if (td.isTest()) {
753
                if (td.isCompile()) {
754
                    testCompileCnds.add(cnd);
755
                } 
756
                testRuntimeCnds.add(cnd);
757
            }
758
            if (td.isRecursive()) {
759
                // scan cp recursively
760
                processTestEntryRecursive(td,compileCnds,runtimeCnds,processedRecursive,ml);         
761
            } else {
762
                runtimeCnds.add(cnd);
763
                if (td.isCompile()) {
764
                    compileCnds.add(cnd);
765
                }
766
            }
767
        }
768
        TestClasspath testClasspath = new TestClasspath();
769
        testClasspath.compile = mergePaths(compileCnds,false,ttName,testDistDir, ml);
770
        testClasspath.runtime = mergePaths(runtimeCnds,false,ttName,testDistDir,ml);
771
        testClasspath.testCompile = mergePaths(testCompileCnds,true,ttName,testDistDir,ml);
772
        testClasspath.testRuntime = mergePaths(testRuntimeCnds,true,ttName,testDistDir,ml);
773
774
        classpaths.put(ttName,testClasspath);
775
    }
776
  
777
  private void processTestEntryRecursive(TestModuleDependency td,
778
                                        Set compileCnds,
779
                                        Set runtimeCnds,
780
                                        Set processedRecursive,
781
                                        ModuleList ml) {
782
        Set/*<String>*/ unprocessed = new HashSet();
783
        
784
        unprocessed.add(td.getModule().getCodeNameBase()); 
785
        while (!unprocessed.isEmpty()) { // crude breadth-first search
786
            Iterator it = unprocessed.iterator();
787
            String cnb = (String) it.next();
788
            it.remove();
789
            if (processedRecursive.add(cnb)) {
790
                ModuleEntry module = ml.getEntry(cnb);
791
                if (module == null) {
792
                    Util.err.log(ErrorManager.WARNING, "Warning - could not find dependent module " + cnb + " for " + FileUtil.getFileDisplayName(project.getProjectDirectory()));
793
                    continue;
794
                }
795
                if (!cnb.equals(project.getCodeNameBase())) { // build/classes for this is special
796
                    runtimeCnds.add(cnb);
797
                    if (td.isCompile()) {
798
                        compileCnds.add(cnb);
799
                    }
800
                }
801
                String[] newDeps = module.getRunDependencies();
802
                unprocessed.addAll(Arrays.asList(newDeps));
803
            }
804
        }
805
    }
806
807
    private String mergePaths(Set cnbs, boolean test,String testtype,File testDistDir,ModuleList ml) {
808
        StringBuffer cps = new StringBuffer();
809
        for (Iterator it = cnbs.iterator() ; it.hasNext();) {
810
                String cnb = (String)it.next();
811
                ModuleEntry module = (ModuleEntry)ml.getEntry(cnb);
812
                if (cps.length() > 0) {
813
                    cps.append(":");
814
                }
815
                if (test) {
816
                    // we need to get cluster name
817
                    File clusterDir = module.getClusterDirectory();
818
                    if (clusterDir != null) {
819
                        String clusterName = clusterDir.getName();
820
                        char s = File.separatorChar;
821
                        File jarFile = new File(
822
                                          testDistDir, testtype + s + clusterName + s + cnb.replace('.','-') + s + "tests.jar");
823
                        cps.append(jarFile.getPath());
824
                    }
825
                     
826
                } else {
827
                    cps.append(module.getJarLocation().getPath());
828
                }
829
        }
830
        return cps.toString();
831
    }
832
   
622
}
833
}

Return to bug 80704