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

(-)a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEActionProvider.java (-41 / +16 lines)
Lines 482-500 Link Here
482
            FileObject[] files = findTestSourcesForSources(context);
482
            FileObject[] files = findTestSourcesForSources(context);
483
            targetNames = setupDebugTestSingle(p, files);
483
            targetNames = setupDebugTestSingle(p, files);
484
        }
484
        }
485
        else if ( command.equals( SingleMethod.COMMAND_RUN_SINGLE_METHOD ) ) {
485
        else if ( command.equals( SingleMethod.COMMAND_RUN_SINGLE_METHOD )
486
               || command.equals( SingleMethod.COMMAND_DEBUG_SINGLE_METHOD ) ) {
486
            SingleMethod[] methodSpecs = findTestMethods(context);
487
            SingleMethod[] methodSpecs = findTestMethods(context);
487
            if ((methodSpecs == null) || (methodSpecs.length != 1)) {
488
            if ((methodSpecs == null) || (methodSpecs.length != 1)) {
488
                return new String[0];
489
                return new String[0];
489
            }
490
            }
490
            targetNames = setupRunSingleTestMethod(p, methodSpecs[0]);
491
            boolean debug = command.equals(SingleMethod.COMMAND_DEBUG_SINGLE_METHOD);
491
        }
492
            targetNames = setupRunSingleTestMethod(p, methodSpecs[0], debug);
492
        else if ( command.equals( SingleMethod.COMMAND_DEBUG_SINGLE_METHOD ) ) {
493
            SingleMethod[] methodSpecs = findTestMethods(context);
494
            if ((methodSpecs == null) || (methodSpecs.length != 1)) {
495
                return new String[0];
496
            }
497
            targetNames = setupDebugSingleTestMethod(p, methodSpecs[0]);
498
        }
493
        }
499
        else if ( command.equals( JavaProjectConstants.COMMAND_DEBUG_FIX ) ) {
494
        else if ( command.equals( JavaProjectConstants.COMMAND_DEBUG_FIX ) ) {
500
            FileObject[] files = findSources( context );
495
            FileObject[] files = findSources( context );
Lines 785-816 Link Here
785
        return new String[] {"debug-test"}; // NOI18N
780
        return new String[] {"debug-test"}; // NOI18N
786
    }
781
    }
787
782
788
    private String[] setupRunSingleTestMethod(Properties p, SingleMethod methodSpec) {
783
    private String[] setupRunSingleTestMethod(Properties p, SingleMethod methodSpec, boolean debug) {
789
        return setupTestSingle(p, new FileObject[] {methodSpec.getFile()});
784
        FileObject[] testSrcPath = project.getTestSourceRoots().getRoots();
790
785
        FileObject testFile = methodSpec.getFile();
791
        //FileObject[] testSrcPath = project.getTestSourceRoots().getRoots();
786
        FileObject root = getRoot(testSrcPath, testFile);
792
        //FileObject testFile = methodSpec.getFile();
787
        String relPath = FileUtil.getRelativePath(root, testFile);
793
        //FileObject root = getRoot(testSrcPath, testFile);
788
        String className = getClassName(relPath);
794
        //String relPath = FileUtil.getRelativePath(root, testFile);
789
        p.setProperty("javac.includes", relPath); // NOI18N
795
        //String className = getClassName(relPath);
790
        p.setProperty("test.class", className); // NOI18N
796
        //p.setProperty("javac.includes", relPath); // NOI18N
791
        p.setProperty("test.method", methodSpec.getMethodName()); // NOI18N
797
        //p.setProperty("test.class", className); // NOI18N
792
        return new String[] {debug ? "debug-test" : "test-single"}; // NOI18N
798
        //p.setProperty("test.method", methodSpec.getMethodName()); // NOI18N
799
        //return new String[] {"test-single-method"}; // NOI18N
800
    }
801
802
    private String[] setupDebugSingleTestMethod(Properties p, SingleMethod methodSpec) {
803
        return setupDebugTestSingle(p, new FileObject[] {methodSpec.getFile()});
804
805
        //FileObject[] testSrcPath = project.getTestSourceRoots().getRoots();
806
        //FileObject testFile = methodSpec.getFile();
807
        //FileObject root = getRoot(testSrcPath, testFile);
808
        //String relPath = FileUtil.getRelativePath(root, testFile);
809
        //String className = getClassName(relPath);
810
        //p.setProperty("javac.includes", relPath); // NOI18N
811
        //p.setProperty("test.class", className); // NOI18N
812
        //p.setProperty("test.method", methodSpec.getMethodName()); // NOI18N
813
        //return new String[] {"debug-test-method"}; // NOI18N
814
    }
793
    }
815
794
816
    private static String getClassName(String relPath) {
795
    private static String getClassName(String relPath) {
Lines 854-865 Link Here
854
            return fos != null && fos.length == 1;
833
            return fos != null && fos.length == 1;
855
        } else if (command.equals(SingleMethod.COMMAND_RUN_SINGLE_METHOD)
834
        } else if (command.equals(SingleMethod.COMMAND_RUN_SINGLE_METHOD)
856
                || command.equals(SingleMethod.COMMAND_DEBUG_SINGLE_METHOD)) {
835
                || command.equals(SingleMethod.COMMAND_DEBUG_SINGLE_METHOD)) {
857
            if (isCompileOnSaveEnabled(J2SEProjectProperties.DISABLE_COMPILE_ON_SAVE)) {
836
            SingleMethod[] methodSpecs = findTestMethods(context);
858
                SingleMethod[] methodSpecs = findTestMethods(context);
837
            return (methodSpecs != null) && (methodSpecs.length == 1);
859
                return (methodSpecs != null) && (methodSpecs.length == 1);
860
            } else {
861
                return false;
862
            }
863
        } else {
838
        } else {
864
            // other actions are global
839
            // other actions are global
865
            return true;
840
            return true;
(-)a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/resources/build-impl.xsl (-4 / +116 lines)
Lines 2-8 Link Here
2
<!--
2
<!--
3
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
4
5
Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5
Copyright 1997-2008 Sun Microsystems, Inc. All rights reserved.
6
6
7
7
8
The contents of this file are subject to the terms of either the GNU
8
The contents of this file are subject to the terms of either the GNU
Lines 26-32 Link Here
26
Contributor(s):
26
Contributor(s):
27
27
28
The Original Software is NetBeans. The Initial Developer of the Original
28
The Original Software is NetBeans. The Initial Developer of the Original
29
Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
29
Software is Sun Microsystems, Inc. Portions Copyright 1997-2008 Sun
30
Microsystems, Inc. All Rights Reserved.
30
Microsystems, Inc. All Rights Reserved.
31
31
32
If you wish your version of this file to be governed by only the CDDL
32
If you wish your version of this file to be governed by only the CDDL
Lines 448-453 Link Here
448
                        <xsl:attribute name="name">testincludes</xsl:attribute>
448
                        <xsl:attribute name="name">testincludes</xsl:attribute>
449
                        <xsl:attribute name="default">**</xsl:attribute>
449
                        <xsl:attribute name="default">**</xsl:attribute>
450
                    </attribute>
450
                    </attribute>
451
                    <element>
452
                        <xsl:attribute name="name">customize</xsl:attribute>
453
                        <xsl:attribute name="optional">true</xsl:attribute>
454
                    </element>
451
                    <sequential>
455
                    <sequential>
452
                        <junit>
456
                        <junit>
453
                            <xsl:attribute name="showoutput">true</xsl:attribute>
457
                            <xsl:attribute name="showoutput">true</xsl:attribute>
Lines 459-464 Link Here
459
                                <xsl:attribute name="jvm">${platform.java}</xsl:attribute>
463
                                <xsl:attribute name="jvm">${platform.java}</xsl:attribute>
460
                            </xsl:if>
464
                            </xsl:if>
461
                            <batchtest todir="${{build.test.results.dir}}">
465
                            <batchtest todir="${{build.test.results.dir}}">
466
                                <xsl:attribute name="unless">test.method</xsl:attribute>
462
                                <xsl:call-template name="createFilesets">
467
                                <xsl:call-template name="createFilesets">
463
                                    <xsl:with-param name="roots" select="/p:project/p:configuration/j2seproject3:data/j2seproject3:test-roots"/>
468
                                    <xsl:with-param name="roots" select="/p:project/p:configuration/j2seproject3:data/j2seproject3:test-roots"/>
464
                                    <xsl:with-param name="includes">@{includes}</xsl:with-param>
469
                                    <xsl:with-param name="includes">@{includes}</xsl:with-param>
Lines 466-471 Link Here
466
                                    <xsl:with-param name="excludes">@{excludes}</xsl:with-param>
471
                                    <xsl:with-param name="excludes">@{excludes}</xsl:with-param>
467
                                </xsl:call-template>
472
                                </xsl:call-template>
468
                            </batchtest>
473
                            </batchtest>
474
                            <customize/>
469
                            <classpath>
475
                            <classpath>
470
                                <path path="${{run.test.classpath}}"/>
476
                                <path path="${{run.test.classpath}}"/>
471
                            </classpath>
477
                            </classpath>
Lines 574-579 Link Here
574
                        <xsl:attribute name="name">customize</xsl:attribute>
580
                        <xsl:attribute name="name">customize</xsl:attribute>
575
                        <xsl:attribute name="optional">true</xsl:attribute>
581
                        <xsl:attribute name="optional">true</xsl:attribute>
576
                    </element>
582
                    </element>
583
                    <element>
584
                        <xsl:attribute name="name">classpath-prepend</xsl:attribute>
585
                        <xsl:attribute name="optional">true</xsl:attribute>
586
                    </element>
577
                    <sequential>
587
                    <sequential>
578
                        <java fork="true" classname="@{{classname}}">
588
                        <java fork="true" classname="@{{classname}}">
579
                            <xsl:attribute name="dir">${work.dir}</xsl:attribute>
589
                            <xsl:attribute name="dir">${work.dir}</xsl:attribute>
Lines 584-589 Link Here
584
                            <jvmarg value="-Xrunjdwp:transport=${{debug-transport}},address=${{jpda.address}}"/>
594
                            <jvmarg value="-Xrunjdwp:transport=${{debug-transport}},address=${{jpda.address}}"/>
585
                            <jvmarg line="${{run.jvmargs}}"/>
595
                            <jvmarg line="${{run.jvmargs}}"/>
586
                            <classpath>
596
                            <classpath>
597
                                <classpath-prepend/>
587
                                <path path="@{{classpath}}"/>
598
                                <path path="@{{classpath}}"/>
588
                            </classpath>
599
                            </classpath>
589
                            <syspropertyset>
600
                            <syspropertyset>
Lines 1236-1246 Link Here
1236
                <mkdir dir="${{build.test.results.dir}}"/>
1247
                <mkdir dir="${{build.test.results.dir}}"/>
1237
            </target>
1248
            </target>
1238
            
1249
            
1239
            <target name="-do-test-run-single">
1250
            <target name="-check-can-run-tests">
1240
                <xsl:attribute name="if">have.tests</xsl:attribute>
1251
                <xsl:attribute name="if">have.tests</xsl:attribute>
1241
                <xsl:attribute name="depends">init,compile-test-single,-pre-test-run-single</xsl:attribute>
1252
                <xsl:attribute name="depends">init,compile-test-single,-pre-test-run-single</xsl:attribute>
1253
                <condition property="run.test.method">
1254
                    <isset property="test.method"/>
1255
                </condition>
1256
                <condition property="run.test.class">
1257
                    <not>
1258
                        <isset property="test.method"/>
1259
                    </not>
1260
                </condition>
1261
            </target>
1262
            
1263
            <target name="-do-test-run-single-class">
1264
                <xsl:attribute name="if">run.test.class</xsl:attribute>
1265
                <xsl:attribute name="depends">-check-can-run-tests</xsl:attribute>
1242
                <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
1266
                <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
1243
                <j2seproject3:junit includes="${{test.includes}}" excludes=""/>
1267
                <j2seproject3:junit includes="${{test.includes}}" excludes=""/>
1268
            </target>
1269
1270
            <target name="-do-test-run-single-method">
1271
                <xsl:attribute name="if">run.test.method</xsl:attribute>
1272
                <xsl:attribute name="depends">-check-can-run-tests</xsl:attribute>
1273
                <fail unless="test.class">Must also set test.class if test.method is specified</fail>
1274
                <fail message="Execution of a single test method is not supported by this version of Ant.">
1275
                    <condition>
1276
                        <not>
1277
                            <available classname="org.apache.tools.ant.taskdefs.optional.junit.XMLResultParser">
1278
                                <classpath path="${{run.test.classpath}}"/>
1279
                            </available>
1280
                        </not>
1281
                    </condition>
1282
                </fail>
1283
                <j2seproject3:junit>
1284
                    <customize>
1285
                        <test name="${{test.class}}">
1286
                            <xsl:attribute name="methods">${test.method}</xsl:attribute>
1287
                            <xsl:attribute name="todir">${build.test.results.dir}</xsl:attribute>
1288
                        </test>
1289
                    </customize>
1290
                </j2seproject3:junit>
1291
            </target>
1292
1293
            <target name="-do-test-run-single">
1294
                <xsl:attribute name="depends">-do-test-run-single-method,-do-test-run-single-class</xsl:attribute>
1244
            </target>
1295
            </target>
1245
            
1296
            
1246
            <target name="-post-test-run-single">
1297
            <target name="-post-test-run-single">
Lines 1260-1268 Link Here
1260
                =======================
1311
                =======================
1261
            </xsl:comment>
1312
            </xsl:comment>
1262
            
1313
            
1263
            <target name="-debug-start-debuggee-test">
1314
            <target name="-check-can-debug-tests">
1264
                <xsl:attribute name="if">have.tests</xsl:attribute>
1315
                <xsl:attribute name="if">have.tests</xsl:attribute>
1265
                <xsl:attribute name="depends">init,compile-test</xsl:attribute>
1316
                <xsl:attribute name="depends">init,compile-test</xsl:attribute>
1317
                <condition property="debug.test.method">
1318
                    <isset property="test.method"/>
1319
                </condition>
1320
                <condition property="debug.test.class">
1321
                    <not>
1322
                        <isset property="test.method"/>
1323
                    </not>
1324
                </condition>
1325
            </target>
1326
            
1327
            <target name="-debug-start-debuggee-test-class">
1328
                <xsl:attribute name="if">debug.test.class</xsl:attribute>
1329
                <xsl:attribute name="depends">-check-can-debug-tests</xsl:attribute>
1266
                <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
1330
                <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
1267
                <property name="test.report.file" location="${{build.test.results.dir}}/TEST-${{test.class}}.xml"/>
1331
                <property name="test.report.file" location="${{build.test.results.dir}}/TEST-${{test.class}}.xml"/>
1268
                <delete file="${{test.report.file}}"/>
1332
                <delete file="${{test.report.file}}"/>
Lines 1280-1285 Link Here
1280
                        <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${{test.report.file}}"/>
1344
                        <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${{test.report.file}}"/>
1281
                    </customize>
1345
                    </customize>
1282
                </j2seproject3:debug>
1346
                </j2seproject3:debug>
1347
            </target>
1348
1349
            <target name="-debug-start-debuggee-test-method">
1350
                <xsl:attribute name="if">debug.test.method</xsl:attribute>
1351
                <xsl:attribute name="depends">-check-can-debug-tests</xsl:attribute>
1352
                <fail unless="test.class">Must also set test.class if test.method is specified</fail>
1353
                <fail message="Execution of a single test method is not supported by this version of Ant.">
1354
                    <condition>
1355
                        <not>
1356
                            <available classname="org.apache.tools.ant.taskdefs.optional.junit.XMLResultParser">
1357
                                <classpath>
1358
                                    <fileset>
1359
                                        <xsl:attribute name="dir">${ant.home}</xsl:attribute>
1360
                                        <xsl:attribute name="includes">patches/*.jar</xsl:attribute>
1361
                                    </fileset>
1362
                                    <path path="${{ant.home}}/lib/ant.jar:${{ant.home}}/lib/ant-junit.jar"/>
1363
                                </classpath>
1364
                            </available>
1365
                        </not>
1366
                    </condition>
1367
                </fail>
1368
                <property name="test.report.file" location="${{build.test.results.dir}}/TEST-${{test.class}}.xml"/>
1369
                <delete file="${{test.report.file}}"/>
1370
                <mkdir dir="${{build.test.results.dir}}"/>
1371
                <!--Ugly, puts ant and ant-junit to the test classpath, but there is probably no other solution how to run the XML formatter -->
1372
                <j2seproject3:debug classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" classpath="${{ant.home}}/lib/ant.jar:${{ant.home}}/lib/ant-junit.jar:${{debug.test.classpath}}">
1373
                    <classpath-prepend>
1374
                        <fileset>
1375
                            <xsl:attribute name="dir">${ant.home}</xsl:attribute>
1376
                            <xsl:attribute name="includes">patches/*.jar</xsl:attribute>
1377
                        </fileset>
1378
                    </classpath-prepend>
1379
                    <customize>
1380
                        <syspropertyset>
1381
                            <propertyref prefix="test-sys-prop."/>
1382
                            <mapper type="glob" from="test-sys-prop.*" to="*"/>
1383
                        </syspropertyset>
1384
                        <arg value="${{test.class}}"/>
1385
                        <arg value="methods=${{test.method}}"/>
1386
                        <arg value="showoutput=true"/>
1387
                        <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
1388
                        <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${{test.report.file}}"/>
1389
                    </customize>
1390
                </j2seproject3:debug>
1391
            </target>
1392
1393
            <target name="-debug-start-debuggee-test">
1394
                <xsl:attribute name="depends">-debug-start-debuggee-test-method,-debug-start-debuggee-test-class</xsl:attribute>
1283
            </target>
1395
            </target>
1284
            
1396
            
1285
            <target name="-debug-start-debugger-test">
1397
            <target name="-debug-start-debugger-test">

Return to bug 142579