1.1 --- a/testng.ant/src/org/netbeans/modules/contrib/testng/ant/testng-build.xml Thu Dec 22 03:08:04 2011 +0100
1.2 +++ b/testng.ant/src/org/netbeans/modules/contrib/testng/ant/testng-build.xml Fri Dec 23 16:40:59 2011 +0100
1.3 @@ -58,7 +58,7 @@
1.4 <macrodef name="testng-ant">
1.5 <attribute name="testincludes" default="${test.includes}"/>
1.6 <sequential>
1.7 - <pathconvert property="test.includes.classes" pathsep=",">
1.8 + <pathconvert property="test.includes.classes" pathsep=",">
1.9 <path location="@{testincludes}" />
1.10 <globmapper from="${basedir}/*.java" to="*.class"/>
1.11 </pathconvert>
1.12 @@ -376,25 +376,31 @@
1.13 <delete dir="${build.test.results.dir}" quiet="true"/>
1.14 <mkdir dir="${build.test.results.dir}"/>
1.15 <java classname="org.testng.TestNG" dir="${basedir}" fork="true">
1.16 - <jvmarg line="${debug-args-line}"/>
1.17 - <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
1.18 - <jvmarg line="${run.jvmargs.prop}"/>
1.19 - <arg line="-d ${build.test.results.dir}"/>
1.20 - <arg line="-sourcedir ${test.src.dir}"/>
1.21 - <arg line="${testng.config}"/>
1.22 + <classpath>
1.23 + <pathelement path="${ant.home}/lib/ant.jar"/>
1.24 + <pathelement path="${ant.home}/lib/ant-junit.jar"/>
1.25 + <pathelement path="${debug.test.classpath}"/>
1.26 + <pathelement path="${j2ee.platform.classpath}"/>
1.27 + </classpath>
1.28 + <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
1.29 <syspropertyset>
1.30 <propertyref prefix="test-sys-prop."/>
1.31 <mapper from="test-sys-prop.*" to="*" type="glob"/>
1.32 </syspropertyset>
1.33 - <jvmarg value="-Dtestng.test.classpath=${build.test.classes.dir}"/>
1.34 - <jvmarg value="-ea"/>
1.35 - <classpath>
1.36 - <path path="${ant.home}/lib/ant.jar:${ant.home}/lib/ant-junit.jar:${debug.test.classpath}:${j2ee.platform.classpath}"/>
1.37 - </classpath>
1.38 <syspropertyset>
1.39 <propertyref prefix="run-sys-prop."/>
1.40 <mapper from="run-sys-prop.*" to="*" type="glob"/>
1.41 </syspropertyset>
1.42 + <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
1.43 + <jvmarg line="${debug-args-line}"/>
1.44 + <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
1.45 + <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
1.46 + <jvmarg line="${run.jvmargs.prop}"/>
1.47 + <jvmarg value="-Dtestng.test.classpath=${build.test.classes.dir}"/>
1.48 + <jvmarg value="-ea"/>
1.49 + <arg line="-d ${build.test.results.dir}"/>
1.50 + <arg line="-listener org.testng.reporters.VerboseReporter"/>
1.51 + <arg line="${testng.config}"/>
1.52 </java>
1.53 </target>
1.54
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/testng/src/org/netbeans/modules/contrib/testng/actions/TestNGActionProvider.java Fri Dec 23 16:40:59 2011 +0100
2.3 @@ -0,0 +1,106 @@
2.4 +/*
2.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2.6 + *
2.7 + * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
2.8 + *
2.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
2.10 + * Other names may be trademarks of their respective owners.
2.11 + *
2.12 + * The contents of this file are subject to the terms of either the GNU
2.13 + * General Public License Version 2 only ("GPL") or the Common
2.14 + * Development and Distribution License("CDDL") (collectively, the
2.15 + * "License"). You may not use this file except in compliance with the
2.16 + * License. You can obtain a copy of the License at
2.17 + * http://www.netbeans.org/cddl-gplv2.html
2.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
2.19 + * specific language governing permissions and limitations under the
2.20 + * License. When distributing the software, include this License Header
2.21 + * Notice in each file and include the License file at
2.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
2.23 + * particular file as subject to the "Classpath" exception as provided
2.24 + * by Oracle in the GPL Version 2 section of the License file that
2.25 + * accompanied this code. If applicable, add the following below the
2.26 + * License Header, with the fields enclosed by brackets [] replaced by
2.27 + * your own identifying information:
2.28 + * "Portions Copyrighted [year] [name of copyright owner]"
2.29 + *
2.30 + * If you wish your version of this file to be governed by only the CDDL
2.31 + * or only the GPL Version 2, indicate your decision by adding
2.32 + * "[Contributor] elects to include this software in this distribution
2.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
2.34 + * single choice of license, a recipient has the option to distribute
2.35 + * your version of this file under either the CDDL, the GPL Version 2 or
2.36 + * to extend the choice of license to its licensees as provided above.
2.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
2.38 + * Version 2 license, then the option applies only if the new code is
2.39 + * made subject to such option by the copyright holder.
2.40 + *
2.41 + * Contributor(s):
2.42 + *
2.43 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
2.44 + */
2.45 +package org.netbeans.modules.contrib.testng.actions;
2.46 +
2.47 +import java.io.IOException;
2.48 +import java.util.logging.Level;
2.49 +import java.util.logging.Logger;
2.50 +import org.netbeans.api.java.source.JavaSource;
2.51 +import org.netbeans.api.project.FileOwnerQuery;
2.52 +import org.netbeans.api.project.Project;
2.53 +import org.netbeans.modules.contrib.testng.api.TestNGSupport;
2.54 +import org.netbeans.modules.contrib.testng.spi.TestConfig;
2.55 +import org.netbeans.modules.contrib.testng.spi.TestNGSupportImplementation;
2.56 +import org.netbeans.spi.project.ActionProvider;
2.57 +import org.netbeans.spi.project.SingleMethod;
2.58 +import org.openide.filesystems.FileObject;
2.59 +import org.openide.util.Lookup;
2.60 +import org.openide.util.lookup.ServiceProvider;
2.61 +
2.62 +/**
2.63 + *
2.64 + * @author lukas
2.65 + */
2.66 +@ServiceProvider(service = ActionProvider.class)
2.67 +public class TestNGActionProvider implements ActionProvider {
2.68 +
2.69 + private static final Logger LOGGER = Logger.getLogger(TestNGActionProvider.class.getName());
2.70 + private static final String[] SUPPORTED_ACTIONS = {
2.71 + SingleMethod.COMMAND_RUN_SINGLE_METHOD,
2.72 + SingleMethod.COMMAND_DEBUG_SINGLE_METHOD
2.73 + };
2.74 +
2.75 + public TestNGActionProvider() {
2.76 + }
2.77 +
2.78 + public String[] getSupportedActions() {
2.79 + return SUPPORTED_ACTIONS;
2.80 + }
2.81 +
2.82 + public boolean isActionEnabled(String command, Lookup context) throws IllegalArgumentException {
2.83 + return context.lookup(SingleMethod.class) != null;
2.84 + }
2.85 +
2.86 + public void invokeAction(String command, Lookup context) throws IllegalArgumentException {
2.87 + TestNGSupport.Action action = SingleMethod.COMMAND_RUN_SINGLE_METHOD.equals(command)
2.88 + ? TestNGSupport.Action.RUN_TESTMETHOD
2.89 + : TestNGSupport.Action.DEBUG_TESTMETHOD;
2.90 + SingleMethod sm = context.lookup(SingleMethod.class);
2.91 + FileObject fo = sm.getFile();
2.92 +
2.93 + TestClassInfoTask task = new TestClassInfoTask(0);
2.94 + JavaSource js = JavaSource.forFileObject(fo);
2.95 + try {
2.96 + js.runUserActionTask(task, true);
2.97 + } catch (IOException ex) {
2.98 + LOGGER.log(Level.WARNING, null, ex);
2.99 + }
2.100 + Project p = FileOwnerQuery.getOwner(fo);
2.101 + TestNGSupportImplementation.TestExecutor exec = TestNGSupport.findTestNGSupport(p).createExecutor(p);
2.102 + TestConfig conf = TestConfigAccessor.getDefault().createTestConfig(fo, false, task.getPackageName(), task.getClassName(), sm.getMethodName());
2.103 + try {
2.104 + exec.execute(action, conf);
2.105 + } catch (IOException ex) {
2.106 + LOGGER.log(Level.SEVERE, null, ex);
2.107 + }
2.108 + }
2.109 +}
3.1 --- a/testng/src/org/netbeans/modules/contrib/testng/output/Bundle.properties Thu Dec 22 03:08:04 2011 +0100
3.2 +++ b/testng/src/org/netbeans/modules/contrib/testng/output/Bundle.properties Fri Dec 23 16:40:59 2011 +0100
3.3 @@ -38,4 +38,6 @@
3.4 # made subject to such option by the copyright holder.
3.5
3.6 LBL_GotoSource=Go to Source
3.7 +LBL_RerunTest=Run Again
3.8 +LBL_DebugTest=Debug
3.9 UNKNOWN_NAME=???
4.1 --- a/testng/src/org/netbeans/modules/contrib/testng/output/TestNGMethodNode.java Thu Dec 22 03:08:04 2011 +0100
4.2 +++ b/testng/src/org/netbeans/modules/contrib/testng/output/TestNGMethodNode.java Fri Dec 23 16:40:59 2011 +0100
4.3 @@ -41,18 +41,20 @@
4.4 package org.netbeans.modules.contrib.testng.output;
4.5
4.6 import java.util.ArrayList;
4.7 +import java.util.Arrays;
4.8 import java.util.List;
4.9 +import java.util.logging.Logger;
4.10 import javax.swing.Action;
4.11 import org.netbeans.api.project.Project;
4.12 -import org.netbeans.modules.contrib.testng.actions.DebugTestMethodAction;
4.13 -import org.netbeans.modules.contrib.testng.actions.RunTestMethodAction;
4.14 import org.netbeans.modules.gsf.testrunner.api.DiffViewAction;
4.15 import org.netbeans.modules.gsf.testrunner.api.TestMethodNode;
4.16 import org.netbeans.modules.gsf.testrunner.api.Testcase;
4.17 +import org.netbeans.spi.project.ActionProvider;
4.18 import org.netbeans.spi.project.SingleMethod;
4.19 -import org.openide.util.actions.SystemAction;
4.20 +import org.openide.util.Lookup;
4.21 import org.openide.util.lookup.AbstractLookup;
4.22 import org.openide.util.lookup.InstanceContent;
4.23 +import org.openide.util.lookup.Lookups;
4.24
4.25 /**
4.26 *
4.27 @@ -74,7 +76,8 @@
4.28
4.29 @Override
4.30 public Action[] getActions(boolean context) {
4.31 - ic.add(new SingleMethod(getTestcase().getClassFileObject(), getTestcase().getTestName()));
4.32 + SingleMethod sm = new SingleMethod(getTestcase().getClassFileObject(), getTestcase().getTestName());
4.33 + ic.add(sm);
4.34 ic.add(getTestcase());
4.35 List<Action> actions = new ArrayList<Action>();
4.36 Action preferred = getPreferredAction();
4.37 @@ -85,9 +88,15 @@
4.38 //TODO: differs in TestNG
4.39 actions.add(new DiffViewAction(testcase));
4.40 }
4.41 - if (!getTestcase().isConfigMethod()) {
4.42 - actions.add(SystemAction.get(RunTestMethodAction.class));
4.43 - actions.add(SystemAction.get(DebugTestMethodAction.class));
4.44 +
4.45 + for (ActionProvider ap : Lookup.getDefault().lookupAll(ActionProvider.class)) {
4.46 + List<String> supportedActions = Arrays.asList(ap.getSupportedActions());
4.47 + if (!getTestcase().isConfigMethod() && supportedActions.contains(SingleMethod.COMMAND_RUN_SINGLE_METHOD)) {
4.48 + actions.add(new TestMethodNodeAction(ap, Lookups.singleton(sm), SingleMethod.COMMAND_RUN_SINGLE_METHOD, "LBL_RerunTest"));
4.49 + }
4.50 + if (!getTestcase().isConfigMethod() && supportedActions.contains(SingleMethod.COMMAND_DEBUG_SINGLE_METHOD)) {
4.51 + actions.add(new TestMethodNodeAction(ap, Lookups.singleton(sm), SingleMethod.COMMAND_DEBUG_SINGLE_METHOD, "LBL_DebugTest"));
4.52 + }
4.53 }
4.54 return actions.toArray(new Action[actions.size()]);
4.55 }