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 138191
Collapse All | Expand All

(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/Bundle.properties (-4 / +1 lines)
Lines 48-57 Link Here
48
# NbModuleProject
48
# NbModuleProject
49
LBL_source_packages=Source Packages
49
LBL_source_packages=Source Packages
50
LBL_unit_test_packages=Unit Test Packages
50
LBL_unit_test_packages=Unit Test Packages
51
LBL_functional_test_packages=Functional Test Packages
51
LBL_qa-functional_test_packages=Functional Test Packages
52
LBL_performance_test_packages=Performance Test Packages
53
# {0} - folder name
54
LBL_unknown_test_packages={0} Test Packages
55
LBL_javahelp_packages=JavaHelp
52
LBL_javahelp_packages=JavaHelp
56
# {0} - project directory
53
# {0} - project directory
57
NbModuleProject.too_new=This version of the IDE is too old to read metadata in {0}.
54
NbModuleProject.too_new=This version of the IDE is too old to read metadata in {0}.
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/Evaluator.java (-120 / +117 lines)
Lines 58-63 Link Here
58
import java.util.Map;
58
import java.util.Map;
59
import java.util.Set;
59
import java.util.Set;
60
import java.util.TreeMap;
60
import java.util.TreeMap;
61
import java.util.logging.Logger;
61
import java.util.regex.Matcher;
62
import java.util.regex.Matcher;
62
import java.util.regex.Pattern;
63
import java.util.regex.Pattern;
63
import javax.swing.event.ChangeListener;
64
import javax.swing.event.ChangeListener;
Lines 77-83 Link Here
77
import org.openide.ErrorManager;
78
import org.openide.ErrorManager;
78
import org.openide.filesystems.FileObject;
79
import org.openide.filesystems.FileObject;
79
import org.openide.filesystems.FileUtil;
80
import org.openide.filesystems.FileUtil;
80
import org.openide.modules.InstalledFileLocator;
81
import org.openide.util.ChangeSupport;
81
import org.openide.util.ChangeSupport;
82
import org.openide.util.Mutex;
82
import org.openide.util.Mutex;
83
import org.openide.util.RequestProcessor;
83
import org.openide.util.RequestProcessor;
Lines 367-378 Link Here
367
        defaults.put("manifest.mf", "manifest.mf"); // NOI18N
367
        defaults.put("manifest.mf", "manifest.mf"); // NOI18N
368
        defaults.put("src.dir", "src"); // NOI18N
368
        defaults.put("src.dir", "src"); // NOI18N
369
        defaults.put("build.classes.dir", "build/classes"); // NOI18N
369
        defaults.put("build.classes.dir", "build/classes"); // NOI18N
370
        defaults.put("test.unit.src.dir", "test/unit/src"); // NOI18N
371
        defaults.put("test.qa-functional.src.dir", "test/qa-functional/src"); // NOI18N
372
        defaults.put("test.qa-performance.src.dir", "test/qa-performance/src"); // NOI18N
373
        defaults.put("build.test.unit.classes.dir", "build/test/unit/classes"); // NOI18N
374
        defaults.put("javac.source", "1.4"); // NOI18N
370
        defaults.put("javac.source", "1.4"); // NOI18N
375
        defaults.put("test.user.dir", new File(dir, "build/testuserdir").getAbsolutePath()); // NOI18N
371
        defaults.put("test.user.dir", new File(dir, "build/testuserdir").getAbsolutePath()); // NOI18N
372
        Set<String> testTypes = new HashSet<String>(Arrays.asList(NbModuleProject.COMMON_TEST_TYPES));
373
        // XXX would be good to add in any other types defined in project.xml
374
        for (String testType : testTypes) {
375
            defaults.put("test." + testType + ".src.dir", "test/" + testType + "/src"); // NOI18N
376
            defaults.put("test." + testType + ".data.dir", "test/" + testType + "/data"); // NOI18N
377
            defaults.put("build.test." + testType + ".classes.dir", "build/test/" + testType + "/classes"); // NOI18N
378
        }
376
        providers.add(PropertyUtils.fixedPropertyProvider(defaults));
379
        providers.add(PropertyUtils.fixedPropertyProvider(defaults));
377
        if (ml != null) {
380
        if (ml != null) {
378
            providers.add(PropertyUtils.fixedPropertyProvider(Collections.singletonMap("module.classpath", computeModuleClasspath(ml)))); // NOI18N
381
            providers.add(PropertyUtils.fixedPropertyProvider(Collections.singletonMap("module.classpath", computeModuleClasspath(ml)))); // NOI18N
Lines 382-451 Link Here
382
            buildDefaults.put("run.cp", computeRuntimeModuleClasspath(ml) + ":${cp.extra}:${build.classes.dir}"); // NOI18N
385
            buildDefaults.put("run.cp", computeRuntimeModuleClasspath(ml) + ":${cp.extra}:${build.classes.dir}"); // NOI18N
383
            
386
            
384
            baseEval = PropertyUtils.sequentialPropertyEvaluator(predefs, providers.toArray(new PropertyProvider[providers.size()]));
387
            baseEval = PropertyUtils.sequentialPropertyEvaluator(predefs, providers.toArray(new PropertyProvider[providers.size()]));
385
            buildDefaults.put("test.unit.cp.extra", ""); // NOI18N
388
386
            String testJars; // #68685 - follow Ant script
389
            Map<String,TestClasspath> testsCPs = computeTestingClassPaths(ml, baseEval, testTypes);
387
            if (type == NbModuleProvider.NETBEANS_ORG) {
390
            testTypes.addAll(testsCPs.keySet());
388
                // Cf. nbbuild/templates/projectized.xml#test-lib-init
391
            for (String testType : testTypes) {
389
                buildDefaults.put("xtest.home", "${nb_all}/xtest"); // NOI18N
392
                buildDefaults.put("test." + testType + ".cp.extra", ""); // NOI18N
390
                testJars =
393
                TestClasspath tcp = TestClasspath.getOrEmpty(testsCPs, testType);
391
                        "${xtest.home}/lib/junit.jar:" + // NOI18N
394
                buildDefaults.put("test." + testType + ".cp", "${cp}:${cluster}/${module.jar}:${test." + testType + ".cp.extra}:" + tcp.getCompileClasspath()); // NOI18N
392
                        "${xtest.home}/lib/nbjunit.jar:" + // NOI18N
395
                buildDefaults.put("test." + testType + ".run.cp.extra", ""); // NOI18N
393
                        "${xtest.home}/lib/nbjunit-ide.jar:" + // NOI18N
396
                buildDefaults.put("test." + testType + ".run.cp", "${test." + testType + ".cp}:${build.test." + testType + ".classes.dir}:${test." + testType + ".run.cp.extra}:" + tcp.getRuntimeClasspath()); // NOI18N
394
                        "${xtest.home}/lib/insanelib.jar"; // NOI18N
395
            } else {
396
                // Cf. apisupport/harness/release/build.xml#test-lib-init
397
                testJars =
398
                        "${test.unit.lib.cp}:" + // NOI18N
399
                        // XXX this is ugly, try to look for the JAR using wildcards instead
400
                        "${netbeans.dest.dir}/ide6/modules/ext/junit-3.8.1.jar:" + // NOI18N
401
                        "${netbeans.dest.dir}/java2/modules/ext/junit-3.8.2.jar:" + // NOI18N
402
                        "${netbeans.dest.dir}/java2/modules/ext/junit-4.1.jar:" + // NOI18N
403
                        "${netbeans.dest.dir}/testtools/modules/ext/nbjunit.jar:" + // NOI18N
404
                        "${netbeans.dest.dir}/testtools/modules/ext/insanelib.jar:" + // NOI18N
405
                        "${netbeans.dest.dir}/testtools/modules/org-netbeans-modules-nbjunit.jar:" + // NOI18N, new for 6.0
406
                        "${netbeans.dest.dir}/testtools/modules/org-netbeans-modules-nbjunit-ide.jar:" + // NOI18N, new for 6.0
407
                        "${netbeans.home}/../ide6/modules/ext/junit-3.8.1.jar:" + // NOI18N
408
                        "${netbeans.home}/../java2/modules/ext/junit-3.8.2.jar:" + // NOI18N
409
                        "${netbeans.home}/../java2/modules/ext/junit-4.1.jar:" + // NOI18N
410
                        "${netbeans.home}/../testtools/modules/ext/nbjunit.jar:" + // NOI18N
411
                        "${netbeans.home}/../testtools/modules/ext/insanelib.jar:" + // NOI18N
412
                        "${netbeans.home}/../testtools/modules/org-netbeans-modules-nbjunit.jar:" + // NOI18N, new for 6.0
413
                        "${netbeans.home}/../testtools/modules/org-netbeans-modules-nbjunit-ide.jar:" + // NOI18N, new for 6.0
414
                        "${netbeans.user}/modules/ext/nbjunit.jar:" + // NOI18N
415
                        "${netbeans.user}/modules/ext/insanelib.jar:" + // NOI18N
416
                        "${netbeans.dest.dir}/../../xtest/lib/junit.jar:" + // NOI18N
417
                        "${netbeans.dest.dir}/../../xtest/lib/nbjunit.jar:" + // NOI18N
418
                        "${netbeans.dest.dir}/../../xtest/lib/insanelib.jar:" + // NOI18N
419
                        "${netbeans.user}/modules/org-netbeans-modules-nbjunit.jar:" + // NOI18N, new for 6.0
420
                        "${netbeans.user}/modules/org-netbeans-modules-nbjunit-ide.jar"; // NOI18N, new for 6.0
421
            }
397
            }
422
            Map<String,TestClasspath> testsCPs = computeTestingClassPaths(ml,baseEval);
398
423
            TestClasspath tcp = TestClasspath.getOrEmpty(testsCPs, "unit"); // NOI18N
424
            
425
            buildDefaults.put("test.unit.cp", "${cp}:${cluster}/${module.jar}:" + testJars + ":${test.unit.cp.extra}:" + tcp.getCompileClasspath()); // NOI18N
426
            buildDefaults.put("test.unit.run.cp.extra", ""); // NOI18N
427
            buildDefaults.put("test.unit.run.cp", "${test.unit.cp}:${build.test.unit.classes.dir}:${test.unit.run.cp.extra}:"+ tcp.getRuntimeClasspath()); // NOI18N
428
            // #61085: need to treat qa-functional tests the same way...
429
            buildDefaults.put("test.qa-functional.cp.extra", ""); // NOI18N
430
            // No idea how XTest finds these, some weird magic, so no Ant script to match up to:
431
            String jemmyJar = findJemmyJar(baseEval);
432
            if (jemmyJar != null) {
433
                buildDefaults.put("jemmy.jar", jemmyJar); // NOI18N
434
            }
435
            String jelly2NbJar = findJelly2NbJar(baseEval);
436
            if (jelly2NbJar != null) {
437
                buildDefaults.put("jelly2-nb.jar", jelly2NbJar); // NOI18N
438
            }
439
            tcp = TestClasspath.getOrEmpty(testsCPs, "qa-functional"); // NOI18N
440
            buildDefaults.put("test.qa-functional.cp", testJars + // NOI18N
441
                    ":${netbeans.home}/../testtools/modules/ext/nbjunit-ide.jar" + // NOI18N
442
                    ":${netbeans.user}/testtools/modules/ext/nbjunit.jar" + // NOI18N
443
                    ":${jemmy.jar}" + // NOI18N
444
                    ":${jelly2-nb.jar}" + // NOI18N
445
                    ":${test.qa-functional.cp.extra}:" + // NOI18N
446
                     tcp.compile + ':' + tcp.testCompile);
447
            buildDefaults.put("build.test.qa-functional.classes.dir", "build/test/qa-functional/classes"); // NOI18N
448
            buildDefaults.put("test.qa-functional.run.cp", "${test.qa-functional.cp}:${build.test.qa-functional.classes.dir}" + ':' + tcp.runtime + ':' + tcp.testRuntime); // NOI18N
449
            providers.add(PropertyUtils.fixedPropertyProvider(buildDefaults));
399
            providers.add(PropertyUtils.fixedPropertyProvider(buildDefaults));
450
        }
400
        }
451
        // skip a bunch of properties irrelevant here - NBM stuff, etc.
401
        // skip a bunch of properties irrelevant here - NBM stuff, etc.
Lines 572-611 Link Here
572
    }
522
    }
573
    
523
    
574
    /**
524
    /**
575
     * Get an Ant location for the root of jemmy.jar.
576
     */
577
    private String findJemmyJar(PropertyEvaluator eval) {
578
        File f = project.getNbrootFile("jemmy/builds/jemmy.jar", eval); // NOI18N
579
        if(f == null) {
580
            // try to find jemmy.jar installed by Jemmy module
581
            f = InstalledFileLocator.getDefault().locate(
582
                    "modules/ext/jemmy.jar", "org.netbeans.modules.jemmy", false);  // NOI18N
583
        }
584
        if (f != null) {
585
            return f.getAbsolutePath();
586
        } else {
587
            return null;
588
        }
589
    }
590
    
591
    /**
592
     * Get an Ant location for the root of jemmy.jar.
593
     */
594
    private String findJelly2NbJar(PropertyEvaluator eval) {
595
        File f = project.getNbrootFile("jellytools/builds/jelly2-nb.jar", eval); // NOI18N
596
        if(f == null) {
597
            // try to find jelly2-nb.jar installed by Jellytools module
598
            f = InstalledFileLocator.getDefault().locate(
599
                    "modules/ext/jelly2-nb.jar", "org.netbeans.modules.jellytools", false);  // NOI18N
600
        }
601
        if (f != null) {
602
            return f.getAbsolutePath();
603
        } else {
604
            return null;
605
        }
606
    }
607
    
608
    /**
609
     * Should be similar to impl in ParseProjectXml.
525
     * Should be similar to impl in ParseProjectXml.
610
     */
526
     */
611
    private String computeModuleClasspath(ModuleList ml) {
527
    private String computeModuleClasspath(ModuleList ml) {
Lines 686-695 Link Here
686
     * to the {@link TestClasspath test classpath} according to the content in
602
     * to the {@link TestClasspath test classpath} according to the content in
687
     * the project's metadata (<em>project.xml<em>).
603
     * the project's metadata (<em>project.xml<em>).
688
     */
604
     */
689
    private Map<String,TestClasspath> computeTestingClassPaths(ModuleList ml, PropertyEvaluator evaluator) {
605
    private Map<String,TestClasspath> computeTestingClassPaths(ModuleList ml, PropertyEvaluator evaluator, Set<String> extraTestTypes) {
690
        Map<String, TestClasspath> classpaths = new HashMap<String,TestClasspath>();
606
        Map<String, TestClasspath> classpaths = new HashMap<String,TestClasspath>();
691
        ProjectXMLManager pxm = new ProjectXMLManager(project);
607
        ProjectXMLManager pxm = new ProjectXMLManager(project);
692
        Map<String, Set<TestModuleDependency>> testTypes = pxm.getTestDependencies(ml);
608
        Map<String, Set<TestModuleDependency>> testDependencies = pxm.getTestDependencies(ml);
693
        
609
        
694
        String testDistDir =  evaluator.getProperty("test.dist.dir"); // NOI18N
610
        String testDistDir =  evaluator.getProperty("test.dist.dir"); // NOI18N
695
        if (testDistDir == null) {
611
        if (testDistDir == null) {
Lines 709-750 Link Here
709
                testDistDir = moduleDir + File.separatorChar + "build" + File.separatorChar + "testdist"; // NOI18N
625
                testDistDir = moduleDir + File.separatorChar + "build" + File.separatorChar + "testdist"; // NOI18N
710
            }
626
            }
711
        }
627
        }
712
        for (Map.Entry<String,Set<TestModuleDependency>> entry : testTypes.entrySet()) {
628
        for (Map.Entry<String,Set<TestModuleDependency>> entry : testDependencies.entrySet()) {
713
            computeTestType(entry.getKey(), new File(testDistDir), entry.getValue(), classpaths, ml);
629
            computeTestType(entry.getKey(), new File(testDistDir), entry.getValue(), classpaths, ml);
630
        }
631
        for (String testType : extraTestTypes) {
632
            if (!testDependencies.containsKey(testType)) {
633
                // No declared dependencies of this type, so will definitely need to add in compatibility libraries.
634
                computeTestType(testType, new File(testDistDir), Collections.<TestModuleDependency>emptySet(), classpaths, ml);
635
            }
714
        }
636
        }
715
        return classpaths;
637
        return classpaths;
716
    }
638
    }
717
    
639
    
718
    private void computeTestType(String ttName, File testDistDir, Set<TestModuleDependency> ttModules, Map<String,TestClasspath> classpaths, ModuleList ml) {
640
    private void computeTestType(String ttName, File testDistDir, Set<TestModuleDependency> ttModules, Map<String,TestClasspath> classpaths, ModuleList ml) {
719
  
641
        Set<String> compileCnbs = new HashSet<String>();
720
        Set<String> compileCnds = new HashSet<String>();
642
        Set<String> runtimeCnbs = new HashSet<String>();
721
        Set<String> runtimeCnds = new HashSet<String>();
643
        Set<String> testCompileCnbs = new HashSet<String>();
722
        Set<String> testCompileCnds = new HashSet<String>();
644
        Set<String> testRuntimeCnbs = new HashSet<String>();
723
        Set<String> testRuntimeCnds = new HashSet<String>();
724
        
645
        
725
        Set<String> processedRecursive = new HashSet<String>();
646
        Set<String> processedRecursive = new HashSet<String>();
647
        boolean fullySpecified = false;
726
        for (TestModuleDependency td : ttModules) {
648
        for (TestModuleDependency td : ttModules) {
727
            String cnd = td.getModule().getCodeNameBase();
649
            String cnb = td.getModule().getCodeNameBase();
650
            fullySpecified |= cnb.equals("org.netbeans.libs.junit4");
728
            if (td.isTest()) {
651
            if (td.isTest()) {
729
                if (td.isCompile()) {
652
                if (td.isCompile()) {
730
                    testCompileCnds.add(cnd);
653
                    testCompileCnbs.add(cnb);
731
                } 
654
                } 
732
                testRuntimeCnds.add(cnd);
655
                testRuntimeCnbs.add(cnb);
733
            }
656
            }
734
            if (td.isRecursive()) {
657
            if (td.isRecursive()) {
735
                // scan cp recursively
658
                // scan cp recursively
736
                processTestEntryRecursive(td,compileCnds,runtimeCnds,processedRecursive,ml);         
659
                processTestEntryRecursive(td,compileCnbs,runtimeCnbs,processedRecursive,ml);         
737
            } else {
660
            } else {
738
                runtimeCnds.add(cnd);
661
                runtimeCnbs.add(cnb);
739
                if (td.isCompile()) {
662
                if (td.isCompile()) {
740
                    compileCnds.add(cnd);
663
                    compileCnbs.add(cnb);
741
                }
664
                }
742
            }
665
            }
743
        }
666
        }
744
        TestClasspath testClasspath = new TestClasspath(mergePaths(compileCnds,false,ttName,testDistDir, ml),
667
745
                mergePaths(runtimeCnds,false,ttName,testDistDir,ml),
668
        StringBuilder extra = new StringBuilder();
746
                mergePaths(testCompileCnds,true,ttName,testDistDir,ml),
669
        if (!fullySpecified) {
747
                mergePaths(testRuntimeCnds,true,ttName,testDistDir,ml));
670
            // Old module which failed to specify all its test dependencies.
671
            if (ml.getEntry("org.netbeans.libs.junit4") == null) {
672
                // Old platform. For compatibility, compute a basic unit test lib classpath.
673
                String[] testLibJars = {
674
                    "${nb_all}/xtest/lib/insanelib.jar", // NOI18N
675
                    "${nb_all}/xtest/lib/junit.jar", // NOI18N
676
                    "${nb_all}/xtest/lib/nbjunit-ide.jar", // NOI18N
677
                    "${nb_all}/xtest/lib/nbjunit.jar", // NOI18N
678
                    "${netbeans.dest.dir}/../../xtest/lib/insanelib.jar", // NOI18N
679
                    "${netbeans.dest.dir}/../../xtest/lib/junit.jar", // NOI18N
680
                    "${netbeans.dest.dir}/../../xtest/lib/nbjunit.jar", // NOI18N
681
                    "${netbeans.dest.dir}/ide6/modules/ext/junit-3.8.1.jar", // NOI18N
682
                    "${netbeans.dest.dir}/java2/modules/ext/junit-3.8.2.jar", // NOI18N
683
                    "${netbeans.dest.dir}/java2/modules/ext/junit-4.1.jar", // NOI18N
684
                    "${netbeans.dest.dir}/testtools/modules/ext/insanelib.jar", // NOI18N
685
                    "${netbeans.dest.dir}/testtools/modules/ext/nbjunit.jar", // NOI18N
686
                    "${netbeans.dest.dir}/testtools/modules/org-netbeans-modules-nbjunit-ide.jar", // NOI18N
687
                    "${netbeans.dest.dir}/testtools/modules/org-netbeans-modules-nbjunit.jar", // NOI18N
688
                    "${netbeans.home}/../ide6/modules/ext/junit-3.8.1.jar", // NOI18N
689
                    "${netbeans.home}/../java2/modules/ext/junit-3.8.2.jar", // NOI18N
690
                    "${netbeans.home}/../java2/modules/ext/junit-4.1.jar", // NOI18N
691
                    "${netbeans.home}/../testtools/modules/ext/insanelib.jar", // NOI18N
692
                    "${netbeans.home}/../testtools/modules/ext/nbjunit.jar", // NOI18N
693
                    "${netbeans.home}/../testtools/modules/org-netbeans-modules-nbjunit-ide.jar", // NOI18N
694
                    "${netbeans.home}/../testtools/modules/org-netbeans-modules-nbjunit.jar", // NOI18N
695
                    "${netbeans.user}/modules/ext/insanelib.jar", // NOI18N
696
                    "${netbeans.user}/modules/ext/nbjunit.jar", // NOI18N
697
                    "${netbeans.user}/modules/org-netbeans-modules-nbjunit-ide.jar", // NOI18N
698
                    "${netbeans.user}/modules/org-netbeans-modules-nbjunit.jar", // NOI18N
699
                };
700
                for (String jar : testLibJars) {
701
                    extra.append(":");
702
                    extra.append(jar);
703
                }
704
                if (ttName.startsWith("qa-")) {
705
                    extra.append(":${nb_all}/jemmy/builds/jemmy.jar:${nb_all}/jellytools/builds/jelly2-nb.jar");
706
                }
707
            } else {
708
                // Basic dependencies many tests use:
709
                for (String library : new String[] {"org.netbeans.libs.junit4", "org.netbeans.modules.nbjunit", "org.netbeans.insane"}) {
710
                    compileCnbs.add(library);
711
                    runtimeCnbs.add(library);
712
                }
713
                if (ttName.startsWith("qa-")) {
714
                    // ProjectSupport moved from the old nbjunit.ide:
715
                    testCompileCnbs.add("org.netbeans.modules.java.j2seproject");
716
                    testRuntimeCnbs.add("org.netbeans.modules.java.j2seproject");
717
                    // Common GUI testing tools:
718
                    for (String library : new String[] {"org.netbeans.modules.jemmy", "org.netbeans.modules.jellytools"}) {
719
                        compileCnbs.add(library);
720
                        runtimeCnbs.add(library);
721
                    }
722
                }
723
            }
724
        }
725
726
        TestClasspath testClasspath = new TestClasspath(
727
                mergePaths(compileCnbs,false,ttName,testDistDir, ml) + extra,
728
                mergePaths(runtimeCnbs,false,ttName,testDistDir,ml) + extra,
729
                mergePaths(testCompileCnbs,true,ttName,testDistDir,ml),
730
                mergePaths(testRuntimeCnbs,true,ttName,testDistDir,ml));
748
731
749
        classpaths.put(ttName,testClasspath);
732
        classpaths.put(ttName,testClasspath);
750
    }
733
    }
Lines 779-788 Link Here
779
        }
762
        }
780
    }
763
    }
781
764
765
   private static final Set<String> warnedModules = Collections.synchronizedSet(new HashSet<String>());
782
    private String mergePaths(Set<String> cnbs, boolean test,String testtype,File testDistDir,ModuleList ml) {
766
    private String mergePaths(Set<String> cnbs, boolean test,String testtype,File testDistDir,ModuleList ml) {
783
        StringBuffer cps = new StringBuffer();
767
        StringBuffer cps = new StringBuffer();
784
        for (String cnb : cnbs) {
768
        for (String cnb : cnbs) {
785
                ModuleEntry module = ml.getEntry(cnb);
769
                ModuleEntry module = ml.getEntry(cnb);
770
                if (module == null) {
771
                    if (warnedModules.add(cnb)) {
772
                        Logger.getLogger(Evaluator.class.getName()).warning("Cannot find test module dependency: " + cnb);
773
                    }
774
                    continue;
775
                }
786
                if (cps.length() > 0) {
776
                if (cps.length() > 0) {
787
                    cps.append(':');
777
                    cps.append(':');
788
                }
778
                }
Lines 795-804 Link Here
795
                        File jarFile = new File(
785
                        File jarFile = new File(
796
                                          testDistDir, testtype + s + clusterName + s + cnb.replace('.','-') + s + "tests.jar"); // NOI18N
786
                                          testDistDir, testtype + s + clusterName + s + cnb.replace('.','-') + s + "tests.jar"); // NOI18N
797
                        cps.append(jarFile.getPath());
787
                        cps.append(jarFile.getPath());
788
                        // See ParseProjectXml:
789
                        if (!testtype.equals("unit")) {
790
                            cps.append(':');
791
                            jarFile = new File(testDistDir, "unit" + s + clusterName + s + cnb.replace('.', '-') + s + "tests.jar"); // NOI18N
792
                            cps.append(jarFile.getPath());
793
                        }
798
                    }
794
                    }
799
                     
795
                     
800
                } else {
796
                } else {
801
                    cps.append(module.getJarLocation().getPath());
797
                    cps.append(module.getJarLocation().getPath());
798
                    cps.append(module.getClassPathExtensions()); // #105621
802
                }
799
                }
803
        }
800
        }
804
        return cps.toString();
801
        return cps.toString();
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/NbModuleProject.java (-53 / +30 lines)
Lines 48-57 Link Here
48
import java.io.IOException;
48
import java.io.IOException;
49
import java.net.URI;
49
import java.net.URI;
50
import java.net.URL;
50
import java.net.URL;
51
import java.util.ArrayList;
51
import java.util.Arrays;
52
import java.util.Arrays;
52
import java.util.Enumeration;
53
import java.util.HashMap;
53
import java.util.HashMap;
54
import java.util.Iterator;
54
import java.util.Iterator;
55
import java.util.List;
55
import java.util.Map;
56
import java.util.Map;
56
import java.util.WeakHashMap;
57
import java.util.WeakHashMap;
57
import java.util.jar.Manifest;
58
import java.util.jar.Manifest;
Lines 131-136 Link Here
131
            Utilities.loadImage(NB_PROJECT_ICON_PATH));
132
            Utilities.loadImage(NB_PROJECT_ICON_PATH));
132
    
133
    
133
    public static final String SOURCES_TYPE_JAVAHELP = "javahelp"; // NOI18N
134
    public static final String SOURCES_TYPE_JAVAHELP = "javahelp"; // NOI18N
135
    static final String[] COMMON_TEST_TYPES = {"unit", "qa-functional"}; // NOI18N
134
    
136
    
135
    private final AntProjectHelper helper;
137
    private final AntProjectHelper helper;
136
    private final Evaluator eval;
138
    private final Evaluator eval;
Lines 159-212 Link Here
159
            throw new IOException("netbeans.org-type module not in a complete netbeans.org source root: " + this); // NOI18N
161
            throw new IOException("netbeans.org-type module not in a complete netbeans.org source root: " + this); // NOI18N
160
        }
162
        }
161
        eval = new Evaluator(this, typeProvider);
163
        eval = new Evaluator(this, typeProvider);
162
        FileBuiltQueryImplementation fileBuilt;
163
        // XXX could add globs for other package roots too
164
        // XXX could add globs for other package roots too
164
        if (supportsUnitTests()) {
165
        List<String> from = new ArrayList<String>();
165
            fileBuilt = helper.createGlobFileBuiltQuery(eval, new String[] {
166
        List<String> to = new ArrayList<String>();
166
                "${src.dir}/*.java", // NOI18N
167
        from.add("${src.dir}/*.java"); // NOI18N
167
                "${test.unit.src.dir}/*.java", // NOI18N
168
        to.add("${build.classes.dir}/*.class"); // NOI18N
168
            }, new String[] {
169
        for (String type : supportedTestTypes()) {
169
                "${build.classes.dir}/*.class", // NOI18N
170
            from.add("${test." + type + ".src.dir}/*.java"); // NOI18N
170
                "${build.test.unit.classes.dir}/*.class", // NOI18N
171
            to.add("${build.test." + type + ".classes.dir}/*.class"); // NOI18N
171
            });
172
        } else {
173
            fileBuilt = helper.createGlobFileBuiltQuery(eval, new String[] {
174
                "${src.dir}/*.java", // NOI18N
175
            }, new String[] {
176
                "${build.classes.dir}/*.class", // NOI18N
177
            });
178
        }
172
        }
173
        FileBuiltQueryImplementation fileBuilt = helper.createGlobFileBuiltQuery(
174
                eval,from.toArray(new String[0]), to.toArray(new String[0]));
179
        final SourcesHelper sourcesHelper = new SourcesHelper(helper, eval);
175
        final SourcesHelper sourcesHelper = new SourcesHelper(helper, eval);
180
        // Temp build dir is always internal; NBM build products go elsewhere, but
176
        // Temp build dir is always internal; NBM build products go elsewhere, but
181
        // difficult to predict statically exactly what they are!
177
        // difficult to predict statically exactly what they are!
182
        // XXX would be good to mark at least the module JAR as owned by this project
178
        // XXX would be good to mark at least the module JAR as owned by this project
183
        // (currently FOQ/SH do not support that)
179
        // (currently FOQ/SH do not support that)
184
        sourcesHelper.addPrincipalSourceRoot("${src.dir}", NbBundle.getMessage(NbModuleProject.class, "LBL_source_packages"), null, null); // #56457
180
        sourcesHelper.addPrincipalSourceRoot("${src.dir}", NbBundle.getMessage(NbModuleProject.class, "LBL_source_packages"), null, null); // #56457
185
        sourcesHelper.addPrincipalSourceRoot("${test.unit.src.dir}", NbBundle.getMessage(NbModuleProject.class, "LBL_unit_test_packages"), null, null); // #68727
181
        for (String type : supportedTestTypes()) {
182
            sourcesHelper.addPrincipalSourceRoot("${test." + type + ".src.dir}", NbBundle.getMessage(NbModuleProject.class, "LBL_" + type + "_test_packages"), null, null); // #68727
183
        }
186
        sourcesHelper.addTypedSourceRoot("${src.dir}", JavaProjectConstants.SOURCES_TYPE_JAVA, NbBundle.getMessage(NbModuleProject.class, "LBL_source_packages"), null, null);
184
        sourcesHelper.addTypedSourceRoot("${src.dir}", JavaProjectConstants.SOURCES_TYPE_JAVA, NbBundle.getMessage(NbModuleProject.class, "LBL_source_packages"), null, null);
187
        // XXX other principal source roots, as needed...
185
        // XXX other principal source roots, as needed...
188
        sourcesHelper.addTypedSourceRoot("${test.unit.src.dir}", JavaProjectConstants.SOURCES_TYPE_JAVA, NbBundle.getMessage(NbModuleProject.class, "LBL_unit_test_packages"), null, null);
186
        for (String type : supportedTestTypes()) {
189
        sourcesHelper.addTypedSourceRoot("${test.qa-functional.src.dir}", JavaProjectConstants.SOURCES_TYPE_JAVA, NbBundle.getMessage(NbModuleProject.class, "LBL_functional_test_packages"), null, null);
187
            sourcesHelper.addTypedSourceRoot("${test." + type + ".src.dir}", JavaProjectConstants.SOURCES_TYPE_JAVA, NbBundle.getMessage(NbModuleProject.class, "LBL_" + type + "_test_packages"), null, null);
190
        sourcesHelper.addTypedSourceRoot("${test.qa-performance.src.dir}", JavaProjectConstants.SOURCES_TYPE_JAVA, NbBundle.getMessage(NbModuleProject.class, "LBL_performance_test_packages"), null, null);
191
        // #42332: also any other misc. test dirs (just add source roots, no CP etc. for now)
192
        FileObject testDir = helper.getProjectDirectory().getFileObject("test"); // NOI18N
193
        if (testDir != null) {
194
            Enumeration<? extends FileObject> kids = testDir.getChildren(false);
195
            while (kids.hasMoreElements()) {
196
                FileObject testSubdir = (FileObject) kids.nextElement();
197
                if (!testSubdir.isFolder()) {
198
                    continue;
199
                }
200
                String name = testSubdir.getNameExt();
201
                if (testDir.getFileObject("build-" + name + ".xml") == null) { // NOI18N
202
                    continue;
203
                }
204
                if (name.equals("unit") || name.equals("qa-functional") || name.equals("qa-performance")) { // NOI18N
205
                    // Already handled specially.
206
                    continue;
207
                }
208
                sourcesHelper.addTypedSourceRoot("test/" + name + "/src", JavaProjectConstants.SOURCES_TYPE_JAVA, NbBundle.getMessage(NbModuleProject.class, "LBL_unknown_test_packages", name), null, null);
209
            }
210
        }
188
        }
211
        if (helper.resolveFileObject("javahelp/manifest.mf") == null) { // NOI18N
189
        if (helper.resolveFileObject("javahelp/manifest.mf") == null) { // NOI18N
212
            // Special hack for core - ignore core/javahelp
190
            // Special hack for core - ignore core/javahelp
Lines 380-395 Link Here
380
        return getDir("src.dir"); // NOI18N
358
        return getDir("src.dir"); // NOI18N
381
    }
359
    }
382
    
360
    
383
    public FileObject getTestSourceDirectory() {
361
    public FileObject getTestSourceDirectory(String type) {
384
        return getDir("test.unit.src.dir"); // NOI18N
362
        return getDir("test." + type + ".src.dir"); // NOI18N
385
    }
386
    
387
    public FileObject getFunctionalTestSourceDirectory() {
388
        return getDir("test.qa-functional.src.dir"); // NOI18N
389
    }
390
    
391
    public FileObject getPerformanceTestSourceDirectory() {
392
        return getDir("test.qa-performance.src.dir"); // NOI18N
393
    }
363
    }
394
    
364
    
395
    public File getClassesDirectory() {
365
    public File getClassesDirectory() {
Lines 397-404 Link Here
397
        return helper.resolveFile(classesDir);
367
        return helper.resolveFile(classesDir);
398
    }
368
    }
399
    
369
    
400
    public File getTestClassesDirectory() {
370
    public File getTestClassesDirectory(String type) {
401
        String testClassesDir = evaluator().getProperty("build.test.unit.classes.dir"); // NOI18N
371
        String testClassesDir = evaluator().getProperty("build.test." + type + ".classes.dir"); // NOI18N
402
        return helper.resolveFile(testClassesDir);
372
        return helper.resolveFile(testClassesDir);
403
    }
373
    }
404
    
374
    
Lines 619-626 Link Here
619
        return pubPkgs != null && !Util.findSubElements(pubPkgs).isEmpty();
589
        return pubPkgs != null && !Util.findSubElements(pubPkgs).isEmpty();
620
    }
590
    }
621
    
591
    
622
    public boolean supportsUnitTests() {
592
    public List<String> supportedTestTypes() {
623
        return getTestSourceDirectory() != null;
593
        List<String> types = new ArrayList<String>();
594
        for (String type : COMMON_TEST_TYPES) {
595
            if (getTestSourceDirectory(type) != null && !Boolean.parseBoolean(evaluator().getProperty("disable." + type + ".tests"))) {
596
                types.add(type);
597
            }
598
        }
599
        // XXX could look for others in project.xml, in which case fix Evaluator to use that
600
        return types;
624
    }
601
    }
625
    
602
    
626
    /**
603
    /**
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/ClassPathProviderImpl.java (-26 / +20 lines)
Lines 103-113 Link Here
103
            return boot;
103
            return boot;
104
        }
104
        }
105
        FileObject srcDir = project.getSourceDirectory();
105
        FileObject srcDir = project.getSourceDirectory();
106
        FileObject testSrcDir = project.getTestSourceDirectory();
106
        FileObject testSrcDir = project.getTestSourceDirectory("unit");
107
        FileObject funcTestSrcDir = project.getFunctionalTestSourceDirectory();        
107
        FileObject funcTestSrcDir = project.getTestSourceDirectory("qa-functional");
108
        File dir = project.getClassesDirectory();
108
        File dir = project.getClassesDirectory();
109
        FileObject classesDir = dir == null ? null : FileUtil.toFileObject(FileUtil.normalizeFile(dir));
109
        FileObject classesDir = dir == null ? null : FileUtil.toFileObject(FileUtil.normalizeFile(dir));
110
        dir = project.getTestClassesDirectory();
110
        dir = project.getTestClassesDirectory("unit");
111
        FileObject testClassesDir = dir == null ? null : FileUtil.toFileObject(FileUtil.normalizeFile(dir));
111
        FileObject testClassesDir = dir == null ? null : FileUtil.toFileObject(FileUtil.normalizeFile(dir));
112
        File moduleJar = project.getModuleJarLocation();
112
        File moduleJar = project.getModuleJarLocation();
113
        if (srcDir != null && (FileUtil.isParentOf(srcDir, file) || file == srcDir)) {
113
        if (srcDir != null && (FileUtil.isParentOf(srcDir, file) || file == srcDir)) {
Lines 131-145 Link Here
131
            }
131
            }
132
        } else if (testSrcDir != null && (FileUtil.isParentOf(testSrcDir, file) || file == testSrcDir)) {
132
        } else if (testSrcDir != null && (FileUtil.isParentOf(testSrcDir, file) || file == testSrcDir)) {
133
            // Unit tests.
133
            // Unit tests.
134
            // XXX refactor to use project.supportedTestTypes
134
            if (type.equals(ClassPath.COMPILE)) {
135
            if (type.equals(ClassPath.COMPILE)) {
135
                if (testCompile == null) {
136
                if (testCompile == null) {
136
                    testCompile = ClassPathFactory.createClassPath(createTestCompileClasspath());
137
                    testCompile = ClassPathFactory.createClassPath(createTestCompileClasspath("unit"));
137
                    Util.err.log("compile-time classpath for tests in " + project + ": " + testCompile);
138
                    Util.err.log("compile-time classpath for tests in " + project + ": " + testCompile);
138
                }
139
                }
139
                return testCompile;
140
                return testCompile;
140
            } else if (type.equals(ClassPath.EXECUTE)) {
141
            } else if (type.equals(ClassPath.EXECUTE)) {
141
                if (testExecute == null) {
142
                if (testExecute == null) {
142
                    testExecute = ClassPathFactory.createClassPath(createTestExecuteClasspath());
143
                    testExecute = ClassPathFactory.createClassPath(createTestExecuteClasspath("unit"));
143
                    Util.err.log("runtime classpath for tests in " + project + ": " + testExecute);
144
                    Util.err.log("runtime classpath for tests in " + project + ": " + testExecute);
144
                }
145
                }
145
                return testExecute;
146
                return testExecute;
Lines 159-171 Link Here
159
            } else if (type.equals(ClassPath.COMPILE)) {
160
            } else if (type.equals(ClassPath.COMPILE)) {
160
                // See #42331.
161
                // See #42331.
161
                if (funcTestCompile == null) {
162
                if (funcTestCompile == null) {
162
                    funcTestCompile = ClassPathFactory.createClassPath(createFuncTestCompileClasspath());
163
                    funcTestCompile = ClassPathFactory.createClassPath(createTestCompileClasspath("qa-functional"));
163
                    Util.err.log("compile-time classpath for func tests in " + project + ": " + funcTestCompile);
164
                    Util.err.log("compile-time classpath for func tests in " + project + ": " + funcTestCompile);
164
                }
165
                }
165
                return funcTestCompile;
166
                return funcTestCompile;
166
            } else if (type.equals(ClassPath.EXECUTE)) {
167
            } else if (type.equals(ClassPath.EXECUTE)) {
167
                if (funcTestExecute == null) {
168
                if (funcTestExecute == null) {
168
                    funcTestExecute = ClassPathFactory.createClassPath(createFuncTestExecuteClasspath());
169
                    funcTestExecute = ClassPathFactory.createClassPath(createTestExecuteClasspath("qa-functional"));
169
                }
170
                }
170
                return funcTestExecute;
171
                return funcTestExecute;
171
            }
172
            }
Lines 184-190 Link Here
184
        } else if (testClassesDir != null && (testClassesDir.equals(file) || FileUtil.isParentOf(testClassesDir,file))) {
185
        } else if (testClassesDir != null && (testClassesDir.equals(file) || FileUtil.isParentOf(testClassesDir,file))) {
185
            if (ClassPath.EXECUTE.equals(type)) {
186
            if (ClassPath.EXECUTE.equals(type)) {
186
                if (testExecute == null) {
187
                if (testExecute == null) {
187
                    testExecute = ClassPathFactory.createClassPath(createTestExecuteClasspath());
188
                    testExecute = ClassPathFactory.createClassPath(createTestExecuteClasspath("unit"));
188
                    Util.err.log("runtime classpath for tests in " + project + ": " + testExecute);
189
                    Util.err.log("runtime classpath for tests in " + project + ": " + testExecute);
189
                }
190
                }
190
                return testExecute;
191
                return testExecute;
Lines 240-259 Link Here
240
        }
241
        }
241
    }
242
    }
242
    
243
    
243
    private ClassPathImplementation createTestCompileClasspath() {
244
    private ClassPathImplementation createTestCompileClasspath(String testType) {
244
        return createPathFromProperty("test.unit.cp"); // NOI18N
245
        return createPathFromProperty("test." + testType + ".cp"); // NOI18N
245
    }
246
    }
246
    
247
    
247
    private ClassPathImplementation createTestExecuteClasspath() {
248
    private ClassPathImplementation createTestExecuteClasspath(String testType) {
248
        return createPathFromProperty("test.unit.run.cp"); // NOI18N
249
        return createPathFromProperty("test." + testType + ".run.cp"); // NOI18N
249
    }
250
    
251
    private ClassPathImplementation createFuncTestCompileClasspath() {
252
        return createPathFromProperty("test.qa-functional.cp"); // NOI18N
253
    }
254
    
255
    private ClassPathImplementation createFuncTestExecuteClasspath() {
256
        return createPathFromProperty("test.qa-functional.run.cp"); // NOI18N
257
    }
250
    }
258
    
251
    
259
    private ClassPathImplementation createExecuteClasspath() {
252
    private ClassPathImplementation createExecuteClasspath() {
Lines 352-362 Link Here
352
            if (srcDir != null) {
345
            if (srcDir != null) {
353
                paths.add(findClassPath(srcDir, ClassPath.COMPILE));
346
                paths.add(findClassPath(srcDir, ClassPath.COMPILE));
354
            }
347
            }
355
            FileObject testSrcDir = project.getTestSourceDirectory();
348
            // XXX refactor to use project.supportedTestTypes
349
            FileObject testSrcDir = project.getTestSourceDirectory("unit");
356
            if (testSrcDir != null) {
350
            if (testSrcDir != null) {
357
                paths.add(findClassPath(testSrcDir, ClassPath.COMPILE));
351
                paths.add(findClassPath(testSrcDir, ClassPath.COMPILE));
358
            }
352
            }
359
            FileObject funcTestSrcDir = project.getFunctionalTestSourceDirectory();
353
            FileObject funcTestSrcDir = project.getTestSourceDirectory("qa-functional");
360
            if (funcTestSrcDir != null) {
354
            if (funcTestSrcDir != null) {
361
                paths.add(findClassPath(funcTestSrcDir, ClassPath.COMPILE));
355
                paths.add(findClassPath(funcTestSrcDir, ClassPath.COMPILE));
362
            }
356
            }
Lines 367-377 Link Here
367
            if (srcDir != null) {
361
            if (srcDir != null) {
368
                paths.add(findClassPath(srcDir, ClassPath.EXECUTE));
362
                paths.add(findClassPath(srcDir, ClassPath.EXECUTE));
369
            }
363
            }
370
            FileObject testSrcDir = project.getTestSourceDirectory();
364
            FileObject testSrcDir = project.getTestSourceDirectory("unit");
371
            if (testSrcDir != null) {
365
            if (testSrcDir != null) {
372
                paths.add(findClassPath(testSrcDir, ClassPath.EXECUTE));
366
                paths.add(findClassPath(testSrcDir, ClassPath.EXECUTE));
373
            }
367
            }
374
            FileObject funcTestSrcDir = project.getFunctionalTestSourceDirectory();
368
            FileObject funcTestSrcDir = project.getTestSourceDirectory("qa-functional");
375
            if (funcTestSrcDir != null) {
369
            if (funcTestSrcDir != null) {
376
                paths.add(findClassPath(funcTestSrcDir, ClassPath.EXECUTE));
370
                paths.add(findClassPath(funcTestSrcDir, ClassPath.EXECUTE));
377
            }
371
            }
Lines 382-392 Link Here
382
            if (srcDir != null) {
376
            if (srcDir != null) {
383
                paths.add(findClassPath(srcDir, ClassPath.SOURCE));
377
                paths.add(findClassPath(srcDir, ClassPath.SOURCE));
384
            }
378
            }
385
            FileObject testSrcDir = project.getTestSourceDirectory();
379
            FileObject testSrcDir = project.getTestSourceDirectory("unit");
386
            if (testSrcDir != null) {
380
            if (testSrcDir != null) {
387
                paths.add(findClassPath(testSrcDir, ClassPath.SOURCE));
381
                paths.add(findClassPath(testSrcDir, ClassPath.SOURCE));
388
            }
382
            }
389
            FileObject funcTestSrcDir = project.getFunctionalTestSourceDirectory();
383
            FileObject funcTestSrcDir = project.getTestSourceDirectory("qa-functional");
390
            if (funcTestSrcDir != null) {
384
            if (funcTestSrcDir != null) {
391
                paths.add(findClassPath(funcTestSrcDir, ClassPath.SOURCE));
385
                paths.add(findClassPath(funcTestSrcDir, ClassPath.SOURCE));
392
            }
386
            }
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/GlobalJavadocForBinaryImpl.java (-6 / +2 lines)
Lines 88-100 Link Here
88
            Util.err.log(binaryRoot + " is not an archive file."); // NOI18N
88
            Util.err.log(binaryRoot + " is not an archive file."); // NOI18N
89
            return null;
89
            return null;
90
        }
90
        }
91
        if (jar.toExternalForm().endsWith("/xtest/lib/junit.jar")) { // NOI18N
91
        if (jar.toExternalForm().endsWith("/modules/ext/junit-4.1.jar") || jar.toExternalForm().endsWith("/external/junit-4.1.jar")) { // NOI18N
92
            // #68685 hack - associate reasonable Javadoc with XTest's version of junit
92
            // #68685 hack - associate reasonable Javadoc with JUnit 4.1 (currently we only bundle 3.x Javadoc)
93
            File f = InstalledFileLocator.getDefault().locate("modules/ext/junit-3.8.2.jar", "org.netbeans.modules.junit", false); // NOI18N
93
            File f = InstalledFileLocator.getDefault().locate("modules/ext/junit-3.8.2.jar", "org.netbeans.modules.junit", false); // NOI18N
94
            if (f == null) {
95
                // For compat with NB 5.0.
96
                f = InstalledFileLocator.getDefault().locate("modules/ext/junit-3.8.1.jar", "org.netbeans.modules.junit", false); // NOI18N
97
            }
98
            if (f != null) {
94
            if (f != null) {
99
                return JavadocForBinaryQuery.findJavadoc(FileUtil.getArchiveRoot(f.toURI().toURL()));
95
                return JavadocForBinaryQuery.findJavadoc(FileUtil.getArchiveRoot(f.toURI().toURL()));
100
            }
96
            }
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/SourceForBinaryImpl.java (-13 / +18 lines)
Lines 64-70 Link Here
64
    
64
    
65
    private final NbModuleProject project;
65
    private final NbModuleProject project;
66
    private URL classesUrl;
66
    private URL classesUrl;
67
    private URL testClassesUrl;
67
    private final Map<String,URL> testClassesUrl = new HashMap<String,URL>();
68
    private Map<URL,SourceForBinaryQuery.Result> cache = new HashMap<URL,SourceForBinaryQuery.Result>();
68
    private Map<URL,SourceForBinaryQuery.Result> cache = new HashMap<URL,SourceForBinaryQuery.Result>();
69
    
69
    
70
    public SourceForBinaryImpl(NbModuleProject project) {
70
    public SourceForBinaryImpl(NbModuleProject project) {
Lines 85-92 Link Here
85
                    // maybe tests.jar in testdistribution
85
                    // maybe tests.jar in testdistribution
86
                    TestEntry entry = TestEntry.get(binaryJarF);
86
                    TestEntry entry = TestEntry.get(binaryJarF);
87
                    if (entry != null && project.getCodeNameBase().equals(entry.getCodeNameBase())) {
87
                    if (entry != null && project.getCodeNameBase().equals(entry.getCodeNameBase())) {
88
                        srcDir = ( entry.isUnit() ) ? project.getTestSourceDirectory() : 
88
                        srcDir = project.getTestSourceDirectory(entry.getTestType());
89
                               project.getFunctionalTestSourceDirectory();
90
                    }
89
                    }
91
                }
90
                }
92
                if (srcDir != null) {
91
                if (srcDir != null) {
Lines 99-110 Link Here
99
                if (srcDir != null) {
98
                if (srcDir != null) {
100
                    res = new Result(srcDir);
99
                    res = new Result(srcDir);
101
                }
100
                }
102
            } else if (binaryRoot.equals(getTestClassesUrl())) {
101
            } else {
103
                FileObject testSrcDir = project.getTestSourceDirectory();
102
                for (String testType : project.supportedTestTypes()) {
104
                if (testSrcDir != null) {
103
                    if (binaryRoot.equals(getTestClassesUrl(testType))) {
105
                    res = new Result(testSrcDir);
104
                        FileObject testSrcDir = project.getTestSourceDirectory(testType);
105
                        if (testSrcDir != null) {
106
                            res = new Result(testSrcDir);
107
                            break;
108
                        }
109
                    }
106
                }
110
                }
107
            } else {
111
                if (res == null) {
108
                // Check extra compilation units.
112
                // Check extra compilation units.
109
                ECUS: for (Map.Entry<FileObject,Element> entry : project.getExtraCompilationUnits().entrySet()) {
113
                ECUS: for (Map.Entry<FileObject,Element> entry : project.getExtraCompilationUnits().entrySet()) {
110
                    for (Element kid : Util.findSubElements(entry.getValue())) {
114
                    for (Element kid : Util.findSubElements(entry.getValue())) {
Lines 125-130 Link Here
125
                        }
129
                        }
126
                    }
130
                    }
127
                }
131
                }
132
                }
128
            }
133
            }
129
            if (res != null) {
134
            if (res != null) {
130
                cache.put(binaryRoot,res);
135
                cache.put(binaryRoot,res);
Lines 141-152 Link Here
141
        return classesUrl;
146
        return classesUrl;
142
    }
147
    }
143
    
148
    
144
    private URL getTestClassesUrl() {
149
    private URL getTestClassesUrl(String testType) {
145
        if (testClassesUrl == null && project.supportsUnitTests()) {
150
        if (!testClassesUrl.containsKey(testType) && project.supportedTestTypes().contains(testType)) {
146
            File testClassesDir = project.getTestClassesDirectory();
151
            File testClassesDir = project.getTestClassesDirectory(testType);
147
            testClassesUrl = FileUtil.urlForArchiveOrDir(testClassesDir);
152
            testClassesUrl.put(testType, FileUtil.urlForArchiveOrDir(testClassesDir));
148
        }
153
        }
149
        return testClassesUrl;
154
        return testClassesUrl.get(testType);
150
    }
155
    }
151
    
156
    
152
    
157
    
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/Bundle.properties (-1 / +6 lines)
Lines 87-92 Link Here
87
LBL_important_files=Important Files
87
LBL_important_files=Important Files
88
LBL_libraries=Libraries
88
LBL_libraries=Libraries
89
LBL_unit_test_libraries=Unit Test Libraries
89
LBL_unit_test_libraries=Unit Test Libraries
90
LBL_qa-functional_test_libraries=Functional Test Libraries
90
LBL_module_manifest=Module Manifest
91
LBL_module_manifest=Module Manifest
91
LBL_arch_desc=Architecture Description
92
LBL_arch_desc=Architecture Description
92
LBL_api_changes=API Changes
93
LBL_api_changes=API Changes
Lines 120-126 Link Here
120
CTL_test=Include also tests of module
121
CTL_test=Include also tests of module
121
CTL_compile=Compile-time dependency
122
CTL_compile=Compile-time dependency
122
CTL_recursive=Include dependencies recursively
123
CTL_recursive=Include dependencies recursively
123
CTL_AddTestDependency=Add Unit Test Dependency
124
CTL_AddTestDependency_unit=Add Unit Test Dependency
125
CTL_AddTestDependency_qa-functional=Add Functional Test Dependency
124
126
125
# SuiteActions
127
# SuiteActions
126
SUITE_ACTION_build=Build All
128
SUITE_ACTION_build=Build All
Lines 178-180 Link Here
178
TITLE_IconDialog=Select Icon
180
TITLE_IconDialog=Select Icon
179
LBL_IconInfo=Selected icon [size]: 
181
LBL_IconInfo=Selected icon [size]: 
180
Templates/Licenses/license-cddl-netbeans-sun.txt=NetBeans CDDL
182
Templates/Licenses/license-cddl-netbeans-sun.txt=NetBeans CDDL
183
184
TestDataDirsNodeFactory.unit_test_data=Unit Test Data
185
TestDataDirsNodeFactory.qa-functional_test_data=Functional Test Data
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/LibrariesNodeFactory.java (-5 / +4 lines)
Lines 78-85 Link Here
78
        public List<String> keys() {
78
        public List<String> keys() {
79
            List<String> toRet = new ArrayList<String>();
79
            List<String> toRet = new ArrayList<String>();
80
            toRet.add(LibrariesNode.LIBRARIES_NAME);
80
            toRet.add(LibrariesNode.LIBRARIES_NAME);
81
            if(resolveFileObjectFromProperty("test.unit.src.dir") != null) { //NOI18N
81
            for (String testType : project.supportedTestTypes()) {
82
                toRet.add(UnitTestLibrariesNode.UNIT_TEST_LIBRARIES_NAME);
82
                toRet.add(testType);
83
            }
83
            }
84
            return toRet;
84
            return toRet;
85
        }
85
        }
Lines 101-110 Link Here
101
        public Node node(String key) {
101
        public Node node(String key) {
102
            if (key == LibrariesNode.LIBRARIES_NAME) {
102
            if (key == LibrariesNode.LIBRARIES_NAME) {
103
                return  new LibrariesNode(project);
103
                return  new LibrariesNode(project);
104
            } else if (key == UnitTestLibrariesNode.UNIT_TEST_LIBRARIES_NAME) {
104
            } else {
105
                return new UnitTestLibrariesNode(project);
105
                return new UnitTestLibrariesNode(key, project);
106
            }
106
            }
107
            throw new AssertionError("Unknown key: " + key);
108
        }
107
        }
109
108
110
        public void addNotify() {
109
        public void addNotify() {
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/ModuleActions.java (-113 / +74 lines)
Lines 105-111 Link Here
105
        }
105
        }
106
        actions.add(ProjectSensitiveActions.projectCommandAction(ActionProvider.COMMAND_DEBUG, NbBundle.getMessage(ModuleActions.class, "ACTION_debug"), null));
106
        actions.add(ProjectSensitiveActions.projectCommandAction(ActionProvider.COMMAND_DEBUG, NbBundle.getMessage(ModuleActions.class, "ACTION_debug"), null));
107
        addFromLayers(actions, "Projects/Profiler_Actions_temporary"); //NOI18N
107
        addFromLayers(actions, "Projects/Profiler_Actions_temporary"); //NOI18N
108
        if (project.supportsUnitTests()) {
108
        if (!project.supportedTestTypes().isEmpty()) {
109
            actions.add(ProjectSensitiveActions.projectCommandAction(ActionProvider.COMMAND_TEST, NbBundle.getMessage(ModuleActions.class, "ACTION_test"), null));
109
            actions.add(ProjectSensitiveActions.projectCommandAction(ActionProvider.COMMAND_TEST, NbBundle.getMessage(ModuleActions.class, "ACTION_test"), null));
110
        }
110
        }
111
        actions.add(null);
111
        actions.add(null);
Lines 174-196 Link Here
174
        globalCommands.put(ActionProvider.COMMAND_RUN, new String[] {"reload"}); // NOI18N
174
        globalCommands.put(ActionProvider.COMMAND_RUN, new String[] {"reload"}); // NOI18N
175
        globalCommands.put("profile", new String[] {"profile"}); // NOI18N
175
        globalCommands.put("profile", new String[] {"profile"}); // NOI18N
176
        globalCommands.put(JavaProjectConstants.COMMAND_JAVADOC, new String[] {"javadoc-nb"}); // NOI18N
176
        globalCommands.put(JavaProjectConstants.COMMAND_JAVADOC, new String[] {"javadoc-nb"}); // NOI18N
177
        if (project.supportsUnitTests()) {
177
        if (!project.supportedTestTypes().isEmpty()) {
178
            globalCommands.put(ActionProvider.COMMAND_TEST, new String[] {"test"}); // NOI18N
178
            globalCommands.put(ActionProvider.COMMAND_TEST, new String[] {"test"}); // NOI18N
179
        }
179
        }
180
        supportedActionsSet.addAll(globalCommands.keySet());
180
        supportedActionsSet.addAll(globalCommands.keySet());
181
        supportedActionsSet.add(ActionProvider.COMMAND_COMPILE_SINGLE);
181
        supportedActionsSet.add(ActionProvider.COMMAND_COMPILE_SINGLE);
182
        supportedActionsSet.add(JavaProjectConstants.COMMAND_DEBUG_FIX); // #47012
182
        supportedActionsSet.add(JavaProjectConstants.COMMAND_DEBUG_FIX); // #47012
183
        if (project.supportsUnitTests()) {
183
        if (!project.supportedTestTypes().isEmpty()) {
184
            supportedActionsSet.add(ActionProvider.COMMAND_TEST_SINGLE);
184
            supportedActionsSet.add(ActionProvider.COMMAND_TEST_SINGLE);
185
            supportedActionsSet.add(ActionProvider.COMMAND_DEBUG_TEST_SINGLE);
185
            supportedActionsSet.add(ActionProvider.COMMAND_DEBUG_TEST_SINGLE);
186
            supportedActionsSet.add(ActionProvider.COMMAND_RUN_SINGLE);
186
            supportedActionsSet.add(ActionProvider.COMMAND_RUN_SINGLE);
187
            supportedActionsSet.add(ActionProvider.COMMAND_DEBUG_SINGLE);
187
            supportedActionsSet.add(ActionProvider.COMMAND_DEBUG_SINGLE);
188
        }
189
        if (project.getFunctionalTestSourceDirectory() != null) {
190
            supportedActionsSet.add(ActionProvider.COMMAND_RUN_SINGLE);
191
        }
192
        if (project.getPerformanceTestSourceDirectory() != null) {
193
            supportedActionsSet.add(ActionProvider.COMMAND_RUN_SINGLE);
194
        }
188
        }
195
        supportedActionsSet.add(ActionProvider.COMMAND_RENAME);
189
        supportedActionsSet.add(ActionProvider.COMMAND_RENAME);
196
        supportedActionsSet.add(ActionProvider.COMMAND_MOVE);
190
        supportedActionsSet.add(ActionProvider.COMMAND_MOVE);
Lines 207-216 Link Here
207
        return project.getProjectDirectory().getFileObject(GeneratedFilesHelper.BUILD_XML_PATH);
201
        return project.getProjectDirectory().getFileObject(GeneratedFilesHelper.BUILD_XML_PATH);
208
    }
202
    }
209
    
203
    
210
    private static FileObject findTestBuildXml(NbModuleProject project) {
211
        return project.getProjectDirectory().getFileObject("test/build.xml"); // NOI18N
212
    }
213
    
214
    private static FileObject findMasterBuildXml(NbModuleProject project) {
204
    private static FileObject findMasterBuildXml(NbModuleProject project) {
215
        return project.getNbrootFileObject("nbbuild/build.xml"); // NOI18N
205
        return project.getNbrootFileObject("nbbuild/build.xml"); // NOI18N
216
    }
206
    }
Lines 221-258 Link Here
221
                ActionProvider.COMMAND_MOVE.equals(command) ||
211
                ActionProvider.COMMAND_MOVE.equals(command) ||
222
                ActionProvider.COMMAND_COPY.equals(command)) {
212
                ActionProvider.COMMAND_COPY.equals(command)) {
223
            return true;
213
            return true;
214
        } else if (findBuildXml(project) == null) {
215
            // All other actions require a build script.
216
            return false;
224
        } else if (command.equals(COMMAND_COMPILE_SINGLE)) {
217
        } else if (command.equals(COMMAND_COMPILE_SINGLE)) {
225
            return findBuildXml(project) != null &&
218
            return findSources(context) != null || findTestSources(context, false) != null;
226
                    (findSources(context) != null || findTestSources(context, false) != null);
227
        } else if (command.equals(COMMAND_TEST_SINGLE)) {
219
        } else if (command.equals(COMMAND_TEST_SINGLE)) {
228
            return findBuildXml(project) != null &&  findTestSourcesForSources(context) != null;
220
            return findTestSourcesForSources(context) != null;
229
        } else if (command.equals(COMMAND_DEBUG_TEST_SINGLE)) {
221
        } else if (command.equals(COMMAND_DEBUG_TEST_SINGLE)) {
230
            FileObject[] files =  findTestSourcesForSources(context);
222
            TestSources testSources = findTestSourcesForSources(context);
231
            return findBuildXml(project) != null && files != null && files.length == 1;
223
            return testSources != null && testSources.sources.length == 1;
232
        } else if (command.equals(COMMAND_RUN_SINGLE)) {
224
        } else if (command.equals(COMMAND_RUN_SINGLE)) {
233
            FileObject[] files = findFunctionalTestSources(context);
225
            return findTestSources(context, false) != null;
234
            if (files != null && files.length == 1 && findTestBuildXml(project) != null) {
226
        } else if (command.equals(COMMAND_DEBUG_SINGLE)) {
227
            TestSources testSources = findTestSources(context, false);
228
            return testSources != null && testSources.sources.length == 1;
229
        } else if (command.equals(JavaProjectConstants.COMMAND_DEBUG_FIX)) {
230
            FileObject[] files = findSources(context);
231
            if (files != null && files.length == 1) {
235
                return true;
232
                return true;
236
            }
233
            }
237
            files = findPerformanceTestSources(context);
234
            TestSources testSources = findTestSources(context, false);
238
            if (files != null && files.length == 1 && findTestBuildXml(project) != null) {
235
            return testSources != null && testSources.sources.length == 1;
239
                return true;
240
            }
241
            files = findTestSources(context, false);
242
            return files != null;
243
        } else if (command.equals(COMMAND_DEBUG_SINGLE)) {
244
            FileObject[] files = findTestSources(context, false);
245
            return files != null && files.length == 1;
246
        } else if (command.equals(JavaProjectConstants.COMMAND_DEBUG_FIX)) {
247
            FileObject[] files = findSources(context);
248
            if (files != null && files.length == 1 && findBuildXml(project) != null) {
249
                return true;
250
            }
251
            files = findTestSources(context, false);
252
            return files != null && files.length == 1 && findBuildXml(project) != null;
253
        } else {
236
        } else {
254
            // other actions are global
237
            // other actions are global
255
            return findBuildXml(project) != null;
238
            return true;
256
        }
239
        }
257
    }
240
    }
258
    
241
    
Lines 270-295 Link Here
270
        }
253
        }
271
    }
254
    }
272
    
255
    
273
    private FileObject[] findTestSources(Lookup context, boolean checkInSrcDir) {
256
    static class TestSources {
274
        FileObject testSrcDir = project.getTestSourceDirectory();
257
        final FileObject[] sources;
275
        if (testSrcDir != null) {
258
        final String testType;
276
            FileObject[] files = ActionUtils.findSelectedFiles(context, testSrcDir, ".java", true); // NOI18N
259
        final FileObject sourceDirectory;
277
            if (files != null) {
260
        public TestSources(FileObject[] sources, String testType, FileObject sourceDirectory) {
278
                return files;
261
            assert sources != null;
262
            assert sourceDirectory != null;
263
            this.sources = sources;
264
            this.testType = testType;
265
            this.sourceDirectory = sourceDirectory;
266
        }
267
    }
268
    private TestSources findTestSources(Lookup context, boolean checkInSrcDir) {
269
        for (String testType : project.supportedTestTypes()) {
270
            FileObject testSrcDir = project.getTestSourceDirectory(testType);
271
            if (testSrcDir != null) {
272
                FileObject[] files = ActionUtils.findSelectedFiles(context, testSrcDir, ".java", true); // NOI18N
273
                if (files != null) {
274
                    return new TestSources(files, testType, testSrcDir);
275
                }
279
            }
276
            }
280
        }
277
        }
281
        //System.err.println("fTS: testSrcDir=" + testSrcDir + " checkInSrcDir=" + checkInSrcDir + " context=" + context);
278
        if (checkInSrcDir) {
282
        if (checkInSrcDir && testSrcDir != null) {
283
            FileObject srcDir = project.getSourceDirectory();
279
            FileObject srcDir = project.getSourceDirectory();
280
            FileObject testSrcDir = project.getTestSourceDirectory("unit"); // NOI18N
284
            //System.err.println("  srcDir=" + srcDir);
281
            //System.err.println("  srcDir=" + srcDir);
285
            if (srcDir != null) {
282
            if (srcDir != null && testSrcDir != null) {
286
                FileObject[] files = ActionUtils.findSelectedFiles(context, srcDir, ".java", true); // NOI18N
283
                FileObject[] files = ActionUtils.findSelectedFiles(context, srcDir, ".java", true); // NOI18N
287
                //System.err.println("  files=" + files);
284
                //System.err.println("  files=" + files);
288
                if (files != null) {
285
                if (files != null) {
289
                    FileObject[] files2 = ActionUtils.regexpMapFiles(files, srcDir, SRCDIRJAVA, testSrcDir, SUBST, true);
286
                    FileObject[] files2 = ActionUtils.regexpMapFiles(files, srcDir, SRCDIRJAVA, testSrcDir, SUBST, true);
290
                    //System.err.println("  files2=" + files2);
287
                    //System.err.println("  files2=" + files2);
291
                    if (files2 != null) {
288
                    if (files2 != null) {
292
                        return files2;
289
                        return new TestSources(files2, "unit", testSrcDir); // NOI18N
293
                    }
290
                    }
294
                }
291
                }
295
            }
292
            }
Lines 299-329 Link Here
299
    
296
    
300
    /** Find tests corresponding to selected sources.
297
    /** Find tests corresponding to selected sources.
301
     */
298
     */
302
    private FileObject[] findTestSourcesForSources(Lookup context) {
299
    private TestSources findTestSourcesForSources(Lookup context) {
300
        String testType = "unit"; // NOI18N
303
        FileObject[] sourceFiles = findSources(context);
301
        FileObject[] sourceFiles = findSources(context);
304
        if (sourceFiles == null) {
302
        if (sourceFiles == null) {
305
            return null;
303
            return null;
306
        }
304
        }
307
        FileObject testSrcDir = project.getTestSourceDirectory();
305
        FileObject testSrcDir = project.getTestSourceDirectory(testType);
308
        FileObject srcDir = project.getSourceDirectory();
306
        if (testSrcDir == null) {
309
        return ActionUtils.regexpMapFiles(sourceFiles, srcDir, SRCDIRJAVA, testSrcDir, SUBST, true);
310
    }
311
    
312
    private FileObject[] findFunctionalTestSources(Lookup context) {
313
        FileObject srcDir = project.getFunctionalTestSourceDirectory();
314
        if (srcDir != null) {
315
            FileObject[] files = ActionUtils.findSelectedFiles(context, srcDir, ".java", true); // NOI18N
316
            return files;
317
        } else {
318
            return null;
307
            return null;
319
        }
308
        }
320
    }
309
        FileObject srcDir = project.getSourceDirectory();
321
    
310
        FileObject[] matches = ActionUtils.regexpMapFiles(sourceFiles, srcDir, SRCDIRJAVA, testSrcDir, SUBST, true);
322
    private FileObject[] findPerformanceTestSources(Lookup context) {
311
        if (matches != null) {
323
        FileObject srcDir = project.getPerformanceTestSourceDirectory();
312
            return new TestSources(matches, testType,testSrcDir);
324
        if (srcDir != null) {
325
            FileObject[] files = ActionUtils.findSelectedFiles(context, srcDir, ".java", true); // NOI18N
326
            return files;
327
        } else {
313
        } else {
328
            return null;
314
            return null;
329
        }
315
        }
Lines 354-406 Link Here
354
        if (!verifySufficientlyNewHarness(project)) {
340
        if (!verifySufficientlyNewHarness(project)) {
355
            return;
341
            return;
356
        }
342
        }
357
        Properties p;
343
        Properties p = new Properties();
358
        String[] targetNames;
344
        String[] targetNames;
359
        FileObject buildScript = null;
360
        if (command.equals(COMMAND_COMPILE_SINGLE)) {
345
        if (command.equals(COMMAND_COMPILE_SINGLE)) {
361
            FileObject[] files = findSources(context);
346
            FileObject[] files = findSources(context);
362
            p = new Properties();
363
            if (files != null) {
347
            if (files != null) {
364
                p.setProperty("javac.includes", ActionUtils.antIncludesList(files, project.getSourceDirectory())); // NOI18N
348
                p.setProperty("javac.includes", ActionUtils.antIncludesList(files, project.getSourceDirectory())); // NOI18N
365
                targetNames = new String[] {"compile-single"}; // NOI18N
349
                targetNames = new String[] {"compile-single"}; // NOI18N
366
            } else {
350
            } else {
367
                files = findTestSources(context, false);
351
                TestSources testSources = findTestSources(context, false);
368
                p.setProperty("javac.includes", ActionUtils.antIncludesList(files, project.getTestSourceDirectory())); // NOI18N
352
                p.setProperty("javac.includes", ActionUtils.antIncludesList(testSources.sources, testSources.sourceDirectory)); // NOI18N
353
                p.setProperty("test.type", testSources.testType);
369
                targetNames = new String[] {"compile-test-single"}; // NOI18N
354
                targetNames = new String[] {"compile-test-single"}; // NOI18N
370
            }
355
            }
371
        } else if (command.equals(COMMAND_TEST_SINGLE)) {
356
        } else if (command.equals(COMMAND_TEST_SINGLE)) {
372
            p = new Properties();
357
            TestSources testSources = findTestSourcesForSources(context);
373
            FileObject[] files = findTestSourcesForSources(context);
358
            targetNames = setupTestSingle(p, testSources);
374
            targetNames = setupTestSingle(p, files);
375
        } else if (command.equals(COMMAND_DEBUG_TEST_SINGLE)) {
359
        } else if (command.equals(COMMAND_DEBUG_TEST_SINGLE)) {
376
            p = new Properties();
360
            TestSources testSources = findTestSourcesForSources(context);
377
            FileObject[] files = findTestSourcesForSources(context);
361
            targetNames = setupDebugTestSingle(p, testSources);
378
            targetNames = setupDebugTestSingle(p, files);
379
        } else if (command.equals(COMMAND_RUN_SINGLE)) {
362
        } else if (command.equals(COMMAND_RUN_SINGLE)) {
380
            FileObject[] files = findFunctionalTestSources(context);
363
            TestSources testSources = findTestSources(context, false);
381
            if (files != null) {
364
            targetNames = setupTestSingle(p, testSources);
382
                String path = FileUtil.getRelativePath(project.getFunctionalTestSourceDirectory(), files[0]);
383
                p = new Properties();
384
                p.setProperty("xtest.testtype", "qa-functional"); // NOI18N
385
                p.setProperty("classname", path.substring(0, path.length() - 5).replace('/', '.')); // NOI18N
386
                targetNames = new String[] {"internal-execution"}; // NOI18N
387
                buildScript = findTestBuildXml(project);
388
            } else if ((files = findPerformanceTestSources(context)) != null) {
389
                String path = FileUtil.getRelativePath(project.getPerformanceTestSourceDirectory(), files[0]);
390
                p = new Properties();
391
                p.setProperty("xtest.testtype", "qa-performance"); // NOI18N
392
                p.setProperty("classname", path.substring(0, path.length() - 5).replace('/', '.')); // NOI18N
393
                targetNames = new String[] {"internal-execution"}; // NOI18N
394
                buildScript = findTestBuildXml(project);
395
            }  else {
396
                files = findTestSources(context, false);
397
                p = new Properties();
398
                targetNames = setupTestSingle(p, files);
399
            }
400
        } else if (command.equals(COMMAND_DEBUG_SINGLE)) {
365
        } else if (command.equals(COMMAND_DEBUG_SINGLE)) {
401
            FileObject[] files = findTestSources(context, false);
366
            TestSources testSources = findTestSources(context, false);
402
            p = new Properties();
367
            targetNames = setupDebugTestSingle(p, testSources);
403
            targetNames = setupDebugTestSingle(p, files);
404
        } else if (command.equals(JavaProjectConstants.COMMAND_DEBUG_FIX)) {
368
        } else if (command.equals(JavaProjectConstants.COMMAND_DEBUG_FIX)) {
405
            FileObject[] files = findSources(context);
369
            FileObject[] files = findSources(context);
406
            String path = null;
370
            String path = null;
Lines 410-440 Link Here
410
                assert path.endsWith(".java");
374
                assert path.endsWith(".java");
411
                targetNames = new String[] {"debug-fix-nb"}; // NOI18N
375
                targetNames = new String[] {"debug-fix-nb"}; // NOI18N
412
            } else {
376
            } else {
413
                files = findTestSources(context, false);
377
                TestSources testSources = findTestSources(context, false);
414
                path = FileUtil.getRelativePath(project.getTestSourceDirectory(), files[0]);
378
                path = FileUtil.getRelativePath(testSources.sourceDirectory, testSources.sources[0]);
379
                p.setProperty("test.type", testSources.testType);
415
                assert path != null;
380
                assert path != null;
416
                assert path.endsWith(".java");
381
                assert path.endsWith(".java");
417
                targetNames = new String[] {"debug-fix-test-nb"}; // NOI18N
382
                targetNames = new String[] {"debug-fix-test-nb"}; // NOI18N
418
            }
383
            }
419
            String clazzSlash = path.substring(0, path.length() - 5);
384
            String clazzSlash = path.substring(0, path.length() - 5);
420
            p = new Properties();
421
            p.setProperty("fix.class", clazzSlash); // NOI18N
385
            p.setProperty("fix.class", clazzSlash); // NOI18N
422
            buildScript = findBuildXml(project);
423
        } else if (command.equals(JavaProjectConstants.COMMAND_JAVADOC) && !project.supportsJavadoc()) {
386
        } else if (command.equals(JavaProjectConstants.COMMAND_JAVADOC) && !project.supportsJavadoc()) {
424
            promptForPublicPackagesToDocument();
387
            promptForPublicPackagesToDocument();
425
            return;
388
            return;
426
        } else {
389
        } else {
427
            p = null;
428
            targetNames = globalCommands.get(command);
390
            targetNames = globalCommands.get(command);
429
            if (targetNames == null) {
391
            if (targetNames == null) {
430
                throw new IllegalArgumentException(command);
392
                throw new IllegalArgumentException(command);
431
            }
393
            }
432
        }
394
        }
433
        if (buildScript == null) {
434
            buildScript = findBuildXml(project);
435
        }
436
        try {
395
        try {
437
            ActionUtils.runTarget(buildScript, targetNames, p);
396
            ActionUtils.runTarget(findBuildXml(project), targetNames, p);
438
        } catch (IOException e) {
397
        } catch (IOException e) {
439
            Util.err.notify(e);
398
            Util.err.notify(e);
440
        }
399
        }
Lines 469-483 Link Here
469
        DialogDisplayer.getDefault().notify(d);
428
        DialogDisplayer.getDefault().notify(d);
470
    }
429
    }
471
    
430
    
472
    private String[] setupTestSingle(Properties p, FileObject[] files) {
431
    private String[] setupTestSingle(Properties p, TestSources testSources) {
473
        p.setProperty("test.includes", ActionUtils.antIncludesList(files, project.getTestSourceDirectory())); // NOI18N
432
        p.setProperty("test.includes", ActionUtils.antIncludesList(testSources.sources, testSources.sourceDirectory)); // NOI18N
433
        p.setProperty("test.type", testSources.testType); // NOI18N
474
        return new String[] {"test-single"}; // NOI18N
434
        return new String[] {"test-single"}; // NOI18N
475
    }
435
    }
476
    
436
    
477
    private String[] setupDebugTestSingle(Properties p, FileObject[] files) {
437
    private String[] setupDebugTestSingle(Properties p, TestSources testSources) {
478
        String path = FileUtil.getRelativePath(project.getTestSourceDirectory(), files[0]);
438
        String path = FileUtil.getRelativePath(testSources.sourceDirectory, testSources.sources[0]);
479
        // Convert foo/FooTest.java -> foo.FooTest
439
        // Convert foo/FooTest.java -> foo.FooTest
480
        p.setProperty("test.class", path.substring(0, path.length() - 5).replace('/', '.')); // NOI18N
440
        p.setProperty("test.class", path.substring(0, path.length() - 5).replace('/', '.')); // NOI18N
441
        p.setProperty("test.type", testSources.testType); // NOI18N
481
        return new String[] {"debug-test-single-nb"}; // NOI18N
442
        return new String[] {"debug-test-single-nb"}; // NOI18N
482
    }
443
    }
483
    
444
    
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/TestDataDirsNodeFactory.java (+121 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.modules.apisupport.project.ui;
41
42
import java.util.ArrayList;
43
import java.util.List;
44
import javax.swing.event.ChangeListener;
45
import org.netbeans.api.project.Project;
46
import org.netbeans.api.project.SourceGroup;
47
import org.netbeans.modules.apisupport.project.NbModuleProject;
48
import org.netbeans.spi.project.support.GenericSources;
49
import org.netbeans.spi.project.ui.support.NodeFactory;
50
import org.netbeans.spi.project.ui.support.NodeList;
51
import org.openide.filesystems.FileObject;
52
import org.openide.loaders.DataObject;
53
import org.openide.loaders.DataObjectNotFoundException;
54
import org.openide.nodes.FilterNode;
55
import org.openide.nodes.Node;
56
import org.openide.util.NbBundle;
57
58
/**
59
 * Displays data directories.
60
 */
61
public class TestDataDirsNodeFactory implements NodeFactory {
62
63
    /** public for layer */
64
    public TestDataDirsNodeFactory() {}
65
66
    public NodeList<?> createNodes(Project p) {
67
        NbModuleProject prj = p.getLookup().lookup(NbModuleProject.class);
68
        return new TestDataDirsNL(prj);
69
    }
70
71
    private static class TestDataDirsNL implements NodeList<SourceGroup> {
72
73
        private final NbModuleProject project;
74
75
        public TestDataDirsNL(NbModuleProject project) {
76
            this.project = project;
77
        }
78
79
        public List<SourceGroup> keys() {
80
            List<SourceGroup> keys = new ArrayList<SourceGroup>();
81
            for (String testType : project.supportedTestTypes()) {
82
                String dataDir = project.evaluator().getProperty("test." + testType + ".data.dir");
83
                if (dataDir != null) {
84
                    FileObject root = project.getHelper().resolveFileObject(dataDir);
85
                    if (root != null) {
86
                        String displayName = NbBundle.getMessage(TestDataDirsNodeFactory.class, "TestDataDirsNodeFactory." + testType + "_test_data");
87
                        keys.add(GenericSources.group(project, root, testType,displayName, null, null));
88
                    }
89
                }
90
            }
91
            return keys;
92
        }
93
94
        public Node node(final SourceGroup key) {
95
            try {
96
                return new FilterNode(DataObject.find(key.getRootFolder()).getNodeDelegate()) {
97
                    @Override
98
                    public String getName() {
99
                        return key.getName();
100
                    }
101
                    @Override
102
                    public String getDisplayName() {
103
                        return key.getDisplayName();
104
                    }
105
                };
106
            } catch (DataObjectNotFoundException ex) {
107
                throw new AssertionError(ex);
108
            }
109
        }
110
111
        public void addChangeListener(ChangeListener l) {}
112
113
        public void removeChangeListener(ChangeListener l) {}
114
115
        public void addNotify() {}
116
117
        public void removeNotify() {}
118
119
    }
120
121
}
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/UnitTestLibrariesNode.java (-102 / +51 lines)
Lines 87-93 Link Here
87
import org.openide.nodes.Children;
87
import org.openide.nodes.Children;
88
import org.openide.nodes.FilterNode;
88
import org.openide.nodes.FilterNode;
89
import org.openide.nodes.Node;
89
import org.openide.nodes.Node;
90
import org.openide.util.Exceptions;
91
import org.openide.util.HelpCtx;
90
import org.openide.util.HelpCtx;
92
import org.openide.util.Lookup;
91
import org.openide.util.Lookup;
93
import org.openide.util.Mutex;
92
import org.openide.util.Mutex;
Lines 104-121 Link Here
104
 */
103
 */
105
final class UnitTestLibrariesNode extends AbstractNode {
104
final class UnitTestLibrariesNode extends AbstractNode {
106
    
105
    
107
    static final String UNIT_TEST_LIBRARIES_NAME = "unit libraries"; // NOI18N
108
    
109
    private static final String DISPLAY_NAME = getMessage("LBL_unit_test_libraries");
110
    
111
    private final Action[] actions;
106
    private final Action[] actions;
112
    
107
    
113
    public UnitTestLibrariesNode(final NbModuleProject project) {
108
    public UnitTestLibrariesNode(String testType, final NbModuleProject project) {
114
        super(new LibrariesChildren(project));
109
        super(new LibrariesChildren(testType, project));
115
        setName(UNIT_TEST_LIBRARIES_NAME);
110
        setName(testType);
116
        setDisplayName(DISPLAY_NAME);
111
        setDisplayName(getMessage("LBL_" + testType + "_test_libraries"));
117
        actions = new Action[] {
112
        actions = new Action[] {
118
            new AddUnitTestDependencyAction(project)
113
            new AddUnitTestDependencyAction(testType, project)
119
        };
114
        };
120
    }
115
    }
121
    
116
    
Lines 156-181 Link Here
156
    }
151
    }
157
    
152
    
158
    
153
    
159
    private static final class LibrariesChildren extends Children.Keys<Object> implements AntProjectListener {
154
    private static final class LibrariesChildren extends Children.Keys<TestModuleDependency> implements AntProjectListener {
160
        
161
        private static final String JUNIT = "junit"; //NOI18N
162
        
163
        private static final String JUNIT_CNB = "org.netbeans.modules.junit";
164
        
165
        private static final String NBJUNIT = "nbjunit"; //NOI18N
166
        
167
        private static final String NBJUNIT_CNB = "org.netbeans.modules.nbjunit";
168
        
155
        
169
        private static final String LIBRARIES_ICON =
156
        private static final String LIBRARIES_ICON =
170
                "org/netbeans/modules/apisupport/project/ui/resources/libraries.gif"; // NOI18N
157
                "org/netbeans/modules/apisupport/project/ui/resources/libraries.gif"; // NOI18N
171
        
158
        
172
        static final Action REMOVE_DEPENDENCY_ACTION = new RemoveDependencyAction();
159
        static final Action REMOVE_DEPENDENCY_ACTION = new RemoveDependencyAction();
173
        
160
        
161
        private final String testType;
174
        private final NbModuleProject project;
162
        private final NbModuleProject project;
175
        
163
        
176
        private ImageIcon librariesIcon;
164
        private ImageIcon librariesIcon;
177
        
165
        
178
        LibrariesChildren(final NbModuleProject project) {
166
        LibrariesChildren(String testType, final NbModuleProject project) {
167
            this.testType = testType;
179
            this.project = project;
168
            this.project = project;
180
        }
169
        }
181
        
170
        
Lines 186-192 Link Here
186
        }
175
        }
187
        
176
        
188
        protected void removeNotify() {
177
        protected void removeNotify() {
189
            setKeys(Collections.emptySet());
178
            setKeys(Collections.<TestModuleDependency>emptySet());
190
            project.getHelper().removeAntProjectListener(this);
179
            project.getHelper().removeAntProjectListener(this);
191
            super.removeNotify();
180
            super.removeNotify();
192
        }
181
        }
Lines 196-211 Link Here
196
                ProjectManager.mutex().readAccess(new Mutex.ExceptionAction<Object>() {
185
                ProjectManager.mutex().readAccess(new Mutex.ExceptionAction<Object>() {
197
                    public Object run() throws Exception {
186
                    public Object run() throws Exception {
198
                        ProjectXMLManager pxm = new ProjectXMLManager(project);
187
                        ProjectXMLManager pxm = new ProjectXMLManager(project);
199
                        List<Object> keys = new ArrayList<Object>();
188
                        final List<TestModuleDependency> keys = new ArrayList<TestModuleDependency>();
200
                        if(isModuleInModuleList(JUNIT_CNB)) {
201
                            keys.add(JUNIT);
202
                        }
203
                        if(isModuleInModuleList(NBJUNIT_CNB)) {
204
                            keys.add(NBJUNIT);
205
                        }
206
                        SortedSet<TestModuleDependency> deps = new TreeSet<TestModuleDependency>(TestModuleDependency.CNB_COMPARATOR);
189
                        SortedSet<TestModuleDependency> deps = new TreeSet<TestModuleDependency>(TestModuleDependency.CNB_COMPARATOR);
207
                        Set<TestModuleDependency> d =  pxm.getTestDependencies(
190
                        Set<TestModuleDependency> d =  pxm.getTestDependencies(
208
                                project.getModuleList()).get(TestModuleDependency.UNIT);
191
                                project.getModuleList()).get(testType);
209
                        //draw only compile time deps
192
                        //draw only compile time deps
210
                        if(d != null){
193
                        if(d != null){
211
                            for (TestModuleDependency tmd : d) {
194
                            for (TestModuleDependency tmd : d) {
Lines 224-292 Link Here
224
            }
207
            }
225
        }
208
        }
226
        
209
        
227
        private boolean isModuleInModuleList(String cnb){
210
        protected Node[] createNodes(TestModuleDependency dep) {
228
            ModuleEntry me = null;
211
            Node node = null;
229
            boolean result = false;
212
            File srcF = dep.getModule().getSourceLocation();
230
            try {
213
            if (srcF == null) {
231
                me = project.getModuleList().getEntry(cnb);
214
                File jarF = dep.getModule().getJarLocation();
232
                if(me != null) {
215
                URL jarRootURL = FileUtil.urlForArchiveOrDir(jarF);
233
                    File moduleJar = me.getJarLocation();
216
                assert jarRootURL != null;
234
                    result = moduleJar.exists();
217
                FileObject root = URLMapper.findFileObject(jarRootURL);
235
                    
218
                ModuleEntry me = dep.getModule();
236
                }
219
                String name = me.getLocalizedName() + " - " + me.getCodeNameBase(); // NOI18N
237
            } catch (IOException ex) {
220
                Icon icon = getLibrariesIcon();
238
                Exceptions.printStackTrace(ex);
221
                Node pvNode = ActionFilterNode.create(
222
                        PackageView.createPackageView(new LibrariesSourceGroup(root, name, icon, icon)));
223
                node = new LibraryDependencyNode(dep, testType, project, pvNode);
224
                node.setName(me.getLocalizedName());
225
            } else {
226
                node = new ProjectDependencyNode(dep, testType, project);
227
                node.setName(dep.getModule().getLocalizedName());
239
            }
228
            }
240
            return result;
241
        }
242
        
243
        
244
        protected Node[] createNodes(Object key) {
245
            Node node = null;
246
            //special nodes - junit, nbjunit
247
            if (JUNIT.equals(key) || NBJUNIT.equals(key)) {
248
                String cnb = null;
249
                if (JUNIT.equals(key)) {
250
                    cnb = JUNIT_CNB;
251
                } else {
252
                    cnb = NBJUNIT_CNB;
253
                }
254
                try {
255
                    ModuleEntry me = project.getModuleList().getEntry(cnb);
256
                    Icon icon = getLibrariesIcon(); // TODO a better icon for JUNIT
257
                    File junitJar = me.getJarLocation();
258
                    URL junitURL = FileUtil.urlForArchiveOrDir(junitJar);
259
                    assert junitURL != null;
260
                    FileObject junitFO = URLMapper.findFileObject(junitURL);
261
                    String name = me.getLocalizedName();
262
                    node = ActionFilterNode.create(
263
                            PackageView.createPackageView(new LibrariesSourceGroup(junitFO, name, icon, icon)));
264
                    node.setName(name); //node does not have a name by default
265
                } catch (IOException ex) {
266
                    ex.printStackTrace();
267
                }
268
            } else {
269
                TestModuleDependency dep = (TestModuleDependency) key;
270
                File srcF = dep.getModule().getSourceLocation();
271
                if (srcF == null) {
272
                    File jarF = dep.getModule().getJarLocation();
273
                    URL jarRootURL = FileUtil.urlForArchiveOrDir(jarF);
274
                    assert jarRootURL != null;
275
                    FileObject root = URLMapper.findFileObject(jarRootURL);
276
                    ModuleEntry me = dep.getModule();
277
                    String name = me.getLocalizedName() + " - " + me.getCodeNameBase(); // NOI18N
278
                    Icon icon = getLibrariesIcon();
279
                    Node pvNode = ActionFilterNode.create(
280
                            PackageView.createPackageView(new LibrariesSourceGroup(root, name, icon, icon)));
281
                    node = new LibraryDependencyNode(dep, project, pvNode);
282
                    node.setName(me.getLocalizedName());
283
                } else {
284
                    node = new ProjectDependencyNode(dep, project);
285
                    node.setName(dep.getModule().getLocalizedName());
286
                }
287
                
288
            }
289
            
290
            assert node != null;
229
            assert node != null;
291
            return new Node[] { node };
230
            return new Node[] { node };
292
        }
231
        }
Lines 316-327 Link Here
316
    private static final class ProjectDependencyNode extends AbstractNode {
255
    private static final class ProjectDependencyNode extends AbstractNode {
317
        
256
        
318
        private final TestModuleDependency dep;
257
        private final TestModuleDependency dep;
258
        private final String testType;
319
        private final NbModuleProject project;
259
        private final NbModuleProject project;
320
        private Action[] actions;
260
        private Action[] actions;
321
        
261
        
322
        ProjectDependencyNode(final TestModuleDependency dep, final NbModuleProject project) {
262
        ProjectDependencyNode(final TestModuleDependency dep, String testType, final NbModuleProject project) {
323
            super(Children.LEAF, Lookups.fixed(new Object[] { dep, project, dep.getModule()}));
263
            super(Children.LEAF, Lookups.fixed(new Object[] { dep, project, dep.getModule()}));
324
            this.dep = dep;
264
            this.dep = dep;
265
            this.testType = testType;
325
            this.project = project;
266
            this.project = project;
326
            ModuleEntry me = dep.getModule();
267
            ModuleEntry me = dep.getModule();
327
            setIconBaseWithExtension(NbModuleProject.NB_PROJECT_ICON_PATH);
268
            setIconBaseWithExtension(NbModuleProject.NB_PROJECT_ICON_PATH);
Lines 336-342 Link Here
336
                // Open project action
277
                // Open project action
337
                result.add(SystemAction.get(LibrariesNode.OpenProjectAction.class));
278
                result.add(SystemAction.get(LibrariesNode.OpenProjectAction.class));
338
                // Edit dependency action
279
                // Edit dependency action
339
                result.add(new EditTestDependencyAction(dep, project));
280
                result.add(new EditTestDependencyAction(dep, testType, project));
340
                // Remove dependency
281
                // Remove dependency
341
                result.add(LibrariesChildren.REMOVE_DEPENDENCY_ACTION);
282
                result.add(LibrariesChildren.REMOVE_DEPENDENCY_ACTION);
342
                actions = result.toArray(new Action[result.size()]);
283
                actions = result.toArray(new Action[result.size()]);
Lines 353-368 Link Here
353
    private static final class LibraryDependencyNode extends FilterNode {
294
    private static final class LibraryDependencyNode extends FilterNode {
354
        
295
        
355
        private final TestModuleDependency dep;
296
        private final TestModuleDependency dep;
297
        private final String testType;
356
        private final NbModuleProject project;
298
        private final NbModuleProject project;
357
        private Action[] actions;
299
        private Action[] actions;
358
        
300
        
359
        LibraryDependencyNode(final TestModuleDependency dep,
301
        LibraryDependencyNode(final TestModuleDependency dep,
302
                String testType,
360
                final NbModuleProject project, final Node original) {
303
                final NbModuleProject project, final Node original) {
361
            super(original, null, new ProxyLookup(new Lookup[] {
304
            super(original, null, new ProxyLookup(new Lookup[] {
362
                original.getLookup(),
305
                original.getLookup(),
363
                Lookups.fixed(new Object[] { dep, project })
306
                Lookups.fixed(new Object[] { dep, project })
364
            }));
307
            }));
365
            this.dep = dep;
308
            this.dep = dep;
309
            this.testType = testType;
366
            this.project = project;
310
            this.project = project;
367
            setShortDescription(UnitTestLibrariesNode.createHtmlDescription(dep));
311
            setShortDescription(UnitTestLibrariesNode.createHtmlDescription(dep));
368
        }
312
        }
Lines 370-376 Link Here
370
        public Action[] getActions(boolean context) {
314
        public Action[] getActions(boolean context) {
371
            if (actions == null) {
315
            if (actions == null) {
372
                Set<Action> result = new LinkedHashSet<Action>();
316
                Set<Action> result = new LinkedHashSet<Action>();
373
                result.add(new EditTestDependencyAction(dep, project));
317
                result.add(new EditTestDependencyAction(dep, testType, project));
374
                Action[] superActions = super.getActions(false);
318
                Action[] superActions = super.getActions(false);
375
                for (int i = 0; i < superActions.length; i++) {
319
                for (int i = 0; i < superActions.length; i++) {
376
                    if (superActions[i] instanceof FindAction) {
320
                    if (superActions[i] instanceof FindAction) {
Lines 391-400 Link Here
391
    
335
    
392
    static final class AddUnitTestDependencyAction extends AbstractAction {
336
    static final class AddUnitTestDependencyAction extends AbstractAction {
393
        
337
        
338
        private final String testType;
394
        private final NbModuleProject project;
339
        private final NbModuleProject project;
395
        
340
        
396
        AddUnitTestDependencyAction(final NbModuleProject project) {
341
        AddUnitTestDependencyAction(String testType, final NbModuleProject project) {
397
            super(getMessage("CTL_AddTestDependency"));
342
            super(getMessage("CTL_AddTestDependency_" + testType));
343
            this.testType = testType;
398
            this.project = project;
344
            this.project = project;
399
        }
345
        }
400
        
346
        
Lines 403-409 Link Here
403
            SingleModuleProperties props = SingleModuleProperties.getInstance(project);
349
            SingleModuleProperties props = SingleModuleProperties.getInstance(project);
404
            final AddModulePanel addPanel = new AddModulePanel(props);
350
            final AddModulePanel addPanel = new AddModulePanel(props);
405
            final DialogDescriptor descriptor = new DialogDescriptor(addPanel,
351
            final DialogDescriptor descriptor = new DialogDescriptor(addPanel,
406
                    getMessage("CTL_AddTestDependency"));
352
                    getMessage("CTL_AddTestDependency_" + testType));
407
            descriptor.setHelpCtx(new HelpCtx(AddModulePanel.class));
353
            descriptor.setHelpCtx(new HelpCtx(AddModulePanel.class));
408
            descriptor.setClosingOptions(new Object[0]);
354
            descriptor.setClosingOptions(new Object[0]);
409
            final Dialog d = DialogDisplayer.getDefault().createDialog(descriptor);
355
            final Dialog d = DialogDisplayer.getDefault().createDialog(descriptor);
Lines 425-431 Link Here
425
                try {
371
                try {
426
                    for (int i = 0; i < newDeps.length; i++) {
372
                    for (int i = 0; i < newDeps.length; i++) {
427
                        // by default, add compile-time dependency
373
                        // by default, add compile-time dependency
428
                        pxm.addTestDependency(TestModuleDependency.UNIT
374
                        pxm.addTestDependency(testType
429
                                ,new TestModuleDependency(newDeps[i].getModuleEntry(), false, false, true));
375
                                ,new TestModuleDependency(newDeps[i].getModuleEntry(), false, false, true));
430
                        ProjectManager.getDefault().saveProject(project);
376
                        ProjectManager.getDefault().saveProject(project);
431
                    }
377
                    }
Lines 464-470 Link Here
464
                ProjectXMLManager pxm = new ProjectXMLManager(project);
410
                ProjectXMLManager pxm = new ProjectXMLManager(project);
465
                //remove dep one by one
411
                //remove dep one by one
466
                for (TestModuleDependency rem : me.getValue()) {
412
                for (TestModuleDependency rem : me.getValue()) {
413
                    // XXX fix - should know what test type it is
467
                    pxm.removeTestDependency(TestModuleDependency.UNIT, rem.getModule().getCodeNameBase());
414
                    pxm.removeTestDependency(TestModuleDependency.UNIT, rem.getModule().getCodeNameBase());
415
                    pxm.removeTestDependency(TestModuleDependency.QA_FUNCTIONAL, rem.getModule().getCodeNameBase());
468
                }
416
                }
469
                try {
417
                try {
470
                    ProjectManager.getDefault().saveProject(project);
418
                    ProjectManager.getDefault().saveProject(project);
Lines 503-513 Link Here
503
    static final class EditTestDependencyAction extends AbstractAction {
451
    static final class EditTestDependencyAction extends AbstractAction {
504
        
452
        
505
        private final TestModuleDependency testDep;
453
        private final TestModuleDependency testDep;
454
        private final String testType;
506
        private final NbModuleProject project;
455
        private final NbModuleProject project;
507
        
456
        
508
        EditTestDependencyAction(final TestModuleDependency testDep, final NbModuleProject project) {
457
        EditTestDependencyAction(final TestModuleDependency testDep, String testType, final NbModuleProject project) {
509
            super(getMessage("CTL_EditDependency"));
458
            super(getMessage("CTL_EditDependency"));
510
            this.testDep = testDep;
459
            this.testDep = testDep;
460
            this.testType = testType;
511
            this.project = project;
461
            this.project = project;
512
        }
462
        }
513
        
463
        
Lines 524-532 Link Here
524
                TestModuleDependency editedDep = editTestPanel.getEditedDependency();
474
                TestModuleDependency editedDep = editTestPanel.getEditedDependency();
525
                try {
475
                try {
526
                    ProjectXMLManager pxm = new ProjectXMLManager(project);
476
                    ProjectXMLManager pxm = new ProjectXMLManager(project);
527
                    final String UNIT = TestModuleDependency.UNIT;
477
                    pxm.removeTestDependency(testType, testDep.getModule().getCodeNameBase());
528
                    pxm.removeTestDependency(UNIT, testDep.getModule().getCodeNameBase());
478
                    pxm.addTestDependency(testType, editedDep);
529
                    pxm.addTestDependency(UNIT, editedDep);
530
                    ProjectManager.getDefault().saveProject(project);
479
                    ProjectManager.getDefault().saveProject(project);
531
                    
480
                    
532
                    
481
                    
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/resources/layer.xml (+3 lines)
Lines 268-273 Link Here
268
                <file name="org-netbeans-modules-apisupport-project-ui-SourcesNodeFactory.instance">
268
                <file name="org-netbeans-modules-apisupport-project-ui-SourcesNodeFactory.instance">
269
                    <attr name="position" intvalue="100"/>
269
                    <attr name="position" intvalue="100"/>
270
                </file>
270
                </file>
271
                <file name="org-netbeans-modules-apisupport-project-ui-TestDataDirsNodeFactory.instance">
272
                    <attr name="position" intvalue="150"/>
273
                </file>
271
                <file name="org-netbeans-modules-apisupport-project-ui-ImportantFilesNodeFactory.instance">
274
                <file name="org-netbeans-modules-apisupport-project-ui-ImportantFilesNodeFactory.instance">
272
                    <attr name="position" intvalue="200"/>
275
                    <attr name="position" intvalue="200"/>
273
                </file>
276
                </file>
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/universe/TestEntry.java (-20 / +6 lines)
Lines 60-81 Link Here
60
public final class TestEntry {
60
public final class TestEntry {
61
    
61
    
62
    private static final String JAR_NAME = "tests.jar"; // NOI18N
62
    private static final String JAR_NAME = "tests.jar"; // NOI18N
63
    private static final String QA_FUNCTIONAL = "qa-functional"; // NOI18N
64
    private static final String UNIT = "unit"; // NOI18N;
65
    /** Hardcoded location of testdistribution relatively to nb source root. */
63
    /** Hardcoded location of testdistribution relatively to nb source root. */
66
    private static final String TEST_DIST_DIR = "nbbuild/build/testdist"; // NOI18N;
64
    private static final String TEST_DIST_DIR = "nbbuild/build/testdist"; // NOI18N;
67
    private final String codeNameBase;
65
    private final String codeNameBase;
68
    private final boolean unit;
66
    private final String testType;
69
    private final String cluster;
67
    private final String cluster;
70
    private final File jarFile;
68
    private final File jarFile;
71
    
69
    
72
    /**
70
    /**
73
     * Creates a new instance of TestEntry
71
     * Creates a new instance of TestEntry
74
     */
72
     */
75
    private TestEntry(File jarFile,String codeNameBase,boolean unit,String cluster) {
73
    private TestEntry(File jarFile, String codeNameBase, String testType, String cluster) {
76
        this.jarFile = jarFile;
74
        this.jarFile = jarFile;
77
        this.codeNameBase = codeNameBase;
75
        this.codeNameBase = codeNameBase;
78
        this.unit = unit;
76
        this.testType = testType;
79
        this.cluster = cluster;
77
        this.cluster = cluster;
80
        
78
        
81
    }
79
    }
Lines 95-109 Link Here
95
               String cnb = tokens[len - 2].replace('-','.') ;
93
               String cnb = tokens[len - 2].replace('-','.') ;
96
               String cluster = tokens[len - 3];
94
               String cluster = tokens[len - 3];
97
               String testType = tokens[len - 4];
95
               String testType = tokens[len - 4];
98
               boolean unit = true;
96
               return new TestEntry(jarFile, cnb, testType, cluster);
99
               if (!testType.equals(UNIT)) {
100
                   if (testType.equals(QA_FUNCTIONAL)) {
101
                       unit = false;
102
                   } else {
103
                       return null;
104
                   }
105
               }
106
               return new TestEntry(jarFile,cnb,unit,cluster);
107
            }
97
            }
108
        }
98
        }
109
        return null;
99
        return null;
Lines 111-120 Link Here
111
    
101
    
112
    public String getCodeNameBase() {
102
    public String getCodeNameBase() {
113
        return codeNameBase;
103
        return codeNameBase;
114
    }
115
116
    public boolean isUnit() {
117
        return unit;
118
    }
104
    }
119
105
120
    public String getCluster() {
106
    public String getCluster() {
Lines 158-164 Link Here
158
                    if (p instanceof NbModuleProject) {
144
                    if (p instanceof NbModuleProject) {
159
                        NbModuleProject nbm = (NbModuleProject) p;
145
                        NbModuleProject nbm = (NbModuleProject) p;
160
                        if (nbm != null && nbm.getCodeNameBase().equals(getCodeNameBase())) {
146
                        if (nbm != null && nbm.getCodeNameBase().equals(getCodeNameBase())) {
161
                            FileObject file = (isUnit()) ? nbm.getTestSourceDirectory() : nbm.getFunctionalTestSourceDirectory();
147
                            FileObject file = nbm.getTestSourceDirectory(testType);
162
                            if (file != null) {
148
                            if (file != null) {
163
                                return file.getURL();
149
                                return file.getURL();
164
                            }
150
                            }
Lines 195-201 Link Here
195
    }
181
    }
196
182
197
    public String getTestType() {
183
    public String getTestType() {
198
        return (isUnit()) ? UNIT : QA_FUNCTIONAL;
184
        return testType;
199
    }
185
    }
200
186
201
    /** 
187
    /** 

Return to bug 138191