Command line option/Ant task attribute "target" deprecated for "annotations" javadoc|jdk
diff --git a/src/jdk15/org/testng/internal/version/VersionInfo.java b/src/jdk15/org/testng/internal/version/VersionInfo.java
index f9a588f..9273bd5 100644
--- a/src/jdk15/org/testng/internal/version/VersionInfo.java
+++ b/src/jdk15/org/testng/internal/version/VersionInfo.java
@@ -23,6 +23,6 @@
* @since 5.2
*/
public static AnnotationTypeEnum getDefaultAnnotationType() {
- return AnnotationTypeEnum.JDK5;
+ return AnnotationTypeEnum.JDK;
}
}
diff --git a/src/main/org/testng/SuiteRunner.java b/src/main/org/testng/SuiteRunner.java
index 4eb3a9d..7550abd 100644
--- a/src/main/org/testng/SuiteRunner.java
+++ b/src/main/org/testng/SuiteRunner.java
@@ -390,7 +390,7 @@
{
AnnotationTypeEnum annotationType = AnnotationTypeEnum.valueOf(pAnnotationType);
- return annotationType == AnnotationTypeEnum.JDK5 ? m_jdkAnnotationFinder : m_javadocAnnotationFinder;
+ return annotationType == AnnotationTypeEnum.JDK ? m_jdkAnnotationFinder : m_javadocAnnotationFinder;
}
public static void ppp(String s) {
diff --git a/src/main/org/testng/TestNG.java b/src/main/org/testng/TestNG.java
index 03e89b7..eb64ff2 100644
--- a/src/main/org/testng/TestNG.java
+++ b/src/main/org/testng/TestNG.java
@@ -102,7 +102,7 @@
public static final String SRC_SEPARATOR = ";";
/** The JDK50 annotation type ID ("JDK5").*/
- public static final String JDK5_ANNOTATION_TYPE = AnnotationTypeEnum.JDK5.getName();
+ public static final String JDK_ANNOTATION_TYPE = AnnotationTypeEnum.JDK.getName();
/** The JavaDoc annotation type ID ("javadoc"). */
public static final String JAVADOC_ANNOTATION_TYPE = AnnotationTypeEnum.JAVADOC.getName();
@@ -226,31 +226,41 @@
* Sets the default annotation type for suites that have not explicitly set the
* annotation property. The target is used only in JDK5+.
* @param target the default annotation type. This is one of the two constants
- * (TestNG.JAVADOC_ANNOTATION_TYPE or TestNG.JDK5_ANNOTATION_TYPE).
+ * (TestNG.JAVADOC_ANNOTATION_TYPE or TestNG.JDK_ANNOTATION_TYPE).
* For backward compatibility reasons we accept "1.4", "1.5". Any other value will
- * default to TestNG.JDK5_ANNOTATION_TYPE.
+ * default to TestNG.JDK_ANNOTATION_TYPE.
*
* @deprecated use the setDefaultAnnotationType replacement method.
*/
@Deprecated
public void setTarget(String target) {
// Target is used only in JDK 1.5 and may get null in JDK 1.4
+ LOGGER.warn("The usage of " + TestNGCommandLineArgs.TARGET_COMMAND_OPT + " option is deprecated." +
+ " Please use " + TestNGCommandLineArgs.ANNOTATIONS_COMMAND_OPT + " instead.");
if (null == target) {
return;
}
- setDefaultAnnotations(target);
+ setAnnotations(target);
}
/**
* Sets the default annotation type for suites that have not explicitly set the
* annotation property. The target is used only in JDK5+.
* @param annotationType the default annotation type. This is one of the two constants
- * (TestNG.JAVADOC_ANNOTATION_TYPE or TestNG.JDK5_ANNOTATION_TYPE).
+ * (TestNG.JAVADOC_ANNOTATION_TYPE or TestNG.JDK_ANNOTATION_TYPE).
* For backward compatibility reasons we accept "1.4", "1.5". Any other value will
- * default to TestNG.JDK5_ANNOTATION_TYPE.
+ * default to TestNG.JDK_ANNOTATION_TYPE.
*/
- public void setDefaultAnnotations(String annotationType) {
- m_defaultAnnotations = AnnotationTypeEnum.valueOf(annotationType);
+ public void setAnnotations(String annotationType) {
+ if(null != annotationType && !"".equals(annotationType)) {
+ setAnnotations(AnnotationTypeEnum.valueOf(annotationType));
+ }
+ }
+
+ private void setAnnotations(AnnotationTypeEnum annotationType) {
+ if(null != annotationType) {
+ m_defaultAnnotations= annotationType;
+ }
}
/**
@@ -382,7 +392,7 @@
* annotation finder?
*/
private IAnnotationFinder getAnnotationFinder() {
- return AnnotationTypeEnum.JDK5 == m_defaultAnnotations
+ return AnnotationTypeEnum.JDK == m_defaultAnnotations
? m_jdkAnnotationFinder
: m_javadocAnnotationFinder;
}
@@ -1040,7 +1050,7 @@
setOutputDirectory((String) cmdLineArgs.get(TestNGCommandLineArgs.OUTDIR_COMMAND_OPT));
setSourcePath((String) cmdLineArgs.get(TestNGCommandLineArgs.SRC_COMMAND_OPT));
- setTarget((String) cmdLineArgs.get(TestNGCommandLineArgs.TARGET_COMMAND_OPT));
+ setAnnotations(((AnnotationTypeEnum) cmdLineArgs.get(TestNGCommandLineArgs.ANNOTATIONS_COMMAND_OPT)));
List<String> testClasses = (List<String>) cmdLineArgs.get(TestNGCommandLineArgs.TESTCLASS_COMMAND_OPT);
if (null != testClasses) {
diff --git a/src/main/org/testng/TestNGAntTask.java b/src/main/org/testng/TestNGAntTask.java
index ccaa6ce..b0669a0 100644
--- a/src/main/org/testng/TestNGAntTask.java
+++ b/src/main/org/testng/TestNGAntTask.java
@@ -371,21 +371,23 @@
* Sets the default annotation type for suites that have not explicitly set the
* annotation property. The target is used only in JDK5+.
* @param defaultAnnotations the default annotation type. This is one of the two constants
- * (TestNG.JAVADOC_ANNOTATION_TYPE or TestNG.JDK5_ANNOTATION_TYPE).
+ * (TestNG.JAVADOC_ANNOTATION_TYPE or TestNG.JDK_ANNOTATION_TYPE).
*
* @since 5.2
*/
- public void setDefaultAnnotations(String defaultAnnotations) {
+ public void setAnnotations(String defaultAnnotations) {
m_target = defaultAnnotations;
}
/**
* @param target
- * @deprecated use setDefaultAnnotations
+ * @deprecated use setAnnotations
*/
@Deprecated
public void setTarget(String target) {
m_target= target;
+ log("The usage of " + TestNGCommandLineArgs.TARGET_COMMAND_OPT + " option is deprecated. Please use "
+ + TestNGCommandLineArgs.ANNOTATIONS_COMMAND_OPT + " instead", Project.MSG_WARN);
}
/**
@@ -487,7 +489,7 @@
}
if(null != m_target) {
- argv.add(TestNGCommandLineArgs.DEFAULT_ANNOTATIONS_COMMAND_OPT);
+ argv.add(TestNGCommandLineArgs.ANNOTATIONS_COMMAND_OPT);
argv.add(m_target);
}
diff --git a/src/main/org/testng/TestNGCommandLineArgs.java b/src/main/org/testng/TestNGCommandLineArgs.java
index b0352a0..f90cf88 100644
--- a/src/main/org/testng/TestNGCommandLineArgs.java
+++ b/src/main/org/testng/TestNGCommandLineArgs.java
@@ -52,8 +52,8 @@
/** @deprecated replaced by DEFAULT_ANNOTATIONS_COMMAND_OPT. */
public static final String TARGET_COMMAND_OPT = "-target";
- /** The default annotations option (useful in TestNg 15 only). */
- public static final String DEFAULT_ANNOTATIONS_COMMAND_OPT = "-defaultAnnotations";
+ /** The default annotations option (useful in TestNG 15 only). */
+ public static final String ANNOTATIONS_COMMAND_OPT = "-annotations";
public static final String GROUPS_COMMAND_OPT = "-groups";
public static final String EXCLUDED_GROUPS_COMMAND_OPT = "-excludegroups";
@@ -155,14 +155,14 @@
}
else if (TARGET_COMMAND_OPT.equalsIgnoreCase(argv[i])) {
if ((i + 1) < argv.length) {
- arguments.put(DEFAULT_ANNOTATIONS_COMMAND_OPT, AnnotationTypeEnum.valueOf(argv[i + 1]));
- LOGGER.info(TARGET_COMMAND_OPT + " has been deprecated use " + DEFAULT_ANNOTATIONS_COMMAND_OPT);
+ arguments.put(ANNOTATIONS_COMMAND_OPT, AnnotationTypeEnum.valueOf(argv[i + 1]));
+ LOGGER.warn("The usage of " + TARGET_COMMAND_OPT + " has been deprecated. Please use " + ANNOTATIONS_COMMAND_OPT + " instead.");
++i;
}
}
- else if (DEFAULT_ANNOTATIONS_COMMAND_OPT.equalsIgnoreCase(argv[i])) {
+ else if (ANNOTATIONS_COMMAND_OPT.equalsIgnoreCase(argv[i])) {
if ((i + 1) < argv.length) {
- arguments.put(DEFAULT_ANNOTATIONS_COMMAND_OPT, AnnotationTypeEnum.valueOf(argv[i + 1]));
+ arguments.put(ANNOTATIONS_COMMAND_OPT, AnnotationTypeEnum.valueOf(argv[i + 1]));
++i;
}
}
@@ -678,18 +678,18 @@
System.out.println("[" + SRC_COMMAND_OPT + " a source directory]");
if (VersionInfo.IS_JDK14) {
- System.out.println("[" + DEFAULT_ANNOTATIONS_COMMAND_OPT + " " + AnnotationTypeEnum.JAVADOC.getName() + "]");
+ System.out.println("[" + ANNOTATIONS_COMMAND_OPT + " " + AnnotationTypeEnum.JAVADOC.getName() + "]");
System.out.println("\t\tSpecifies the default annotation type to be used in suites when none is explicitly specified.");
System.out.println("\t\tThis version of TestNG (14) only supports " + AnnotationTypeEnum.JAVADOC.getName() + " annotation type.");
System.out.println("\t\tFor interface compatibility reasons, we allow this value to be explicitly set to " +
AnnotationTypeEnum.JAVADOC.getName() + "\" ");
}
else {
- System.out.println("[" + DEFAULT_ANNOTATIONS_COMMAND_OPT + " " + AnnotationTypeEnum.JAVADOC.getName() + " or "
+ System.out.println("[" + ANNOTATIONS_COMMAND_OPT + " " + AnnotationTypeEnum.JAVADOC.getName() + " or "
+ AnnotationTypeEnum.JAVADOC.getName() + "]");
System.out.println("\t\tSpecifies the default annotation type to be used in suites when none is explicitly");
System.out.println("\t\tspecified. This version of TestNG (15) supports both \""
- + AnnotationTypeEnum.JAVADOC.getName() + "\" and \"" + AnnotationTypeEnum.JDK5.getName() + "\" annotation types.");
+ + AnnotationTypeEnum.JAVADOC.getName() + "\" and \"" + AnnotationTypeEnum.JDK.getName() + "\" annotation types.");
}
System.out.println("[" + GROUPS_COMMAND_OPT + " comma-separated list of group names to be run]");
diff --git a/src/main/org/testng/internal/AnnotationTypeEnum.java b/src/main/org/testng/internal/AnnotationTypeEnum.java
index 4510a58..8ddbd68 100644
--- a/src/main/org/testng/internal/AnnotationTypeEnum.java
+++ b/src/main/org/testng/internal/AnnotationTypeEnum.java
@@ -19,7 +19,7 @@
private static final Logger LOGGER = Logger.getLogger(AnnotationTypeEnum.class);
/** The JDK50 annotation type ID ("JDK5").*/
- private static final String JDK5_ANNOTATION_TYPE = "JDK5";
+ private static final String JDK_ANNOTATION_TYPE = "JDK";
/** The JavaDoc annotation type ID ("javadoc"). */
private static final String JAVADOC_ANNOTATION_TYPE = "javadoc";
@@ -28,7 +28,7 @@
public static final AnnotationTypeEnum JAVADOC = new AnnotationTypeEnum(JAVADOC_ANNOTATION_TYPE);
/** JDK5 annotation type */
- public static final AnnotationTypeEnum JDK5 = new AnnotationTypeEnum(JDK5_ANNOTATION_TYPE);
+ public static final AnnotationTypeEnum JDK = new AnnotationTypeEnum(JDK_ANNOTATION_TYPE);
/** The enumeration name (one of JAVADOC_ANNOTATION_TYPE or JDK5_ANNOTATION_TYPE) */
private String m_name;
@@ -57,8 +57,8 @@
if (pAnnotationType.equals(JAVADOC_ANNOTATION_TYPE)) {
annotationType = JAVADOC;
}
- else if (pAnnotationType.equals(JDK5_ANNOTATION_TYPE)) {
- annotationType = JDK5;
+ else if (pAnnotationType.equals(JDK_ANNOTATION_TYPE)) {
+ annotationType = JDK;
}
else if (pAnnotationType.equals("1.4")
|| pAnnotationType.toLowerCase().equals(JAVADOC_ANNOTATION_TYPE.toLowerCase())) {
@@ -67,14 +67,14 @@
log(pAnnotationType, annotationType);
}
else if ("1.5".equals(pAnnotationType)
- || pAnnotationType.toLowerCase().equals(JDK5_ANNOTATION_TYPE.toLowerCase())) {
+ || pAnnotationType.toLowerCase().equals(JDK_ANNOTATION_TYPE.toLowerCase())) {
// For backward compatibility only
- annotationType = JDK5;
+ annotationType = JDK;
log(pAnnotationType, annotationType);
}
- else if (pAnnotationType.toLowerCase().equals("jdk15")) {
+ else if ("jdk1.5".equals(pAnnotationType.toLowerCase()) || "jdk5".equals(pAnnotationType.toLowerCase())) {
// For backward compatibility only
- annotationType = JDK5;
+ annotationType = JDK;
log(pAnnotationType, annotationType);
}
else {
@@ -84,7 +84,7 @@
log(pAnnotationType, annotationType);
}
- if (VersionInfo.IS_JDK14 && annotationType == JDK5) {
+ if (VersionInfo.IS_JDK14 && annotationType == JDK) {
throw new IllegalArgumentException(
"Cannot specify \"" + pAnnotationType + "\" with 1.4 version of TestNG");
}
diff --git a/src/main/org/testng/xml/XmlSuite.java b/src/main/org/testng/xml/XmlSuite.java
index 5e2333f..a970159 100644
--- a/src/main/org/testng/xml/XmlSuite.java
+++ b/src/main/org/testng/xml/XmlSuite.java
@@ -28,7 +28,7 @@
public static final String JAVADOC = "javadoc";
/** The JDK50 annotation type ID ("JDK5"). */
- public static final String JDK5_ANNOTATION_TYPE = AnnotationTypeEnum.JDK5.getName();
+ public static final String JDK5_ANNOTATION_TYPE = AnnotationTypeEnum.JDK.getName();
/** The JavaDoc annotation type ID ("javadoc"). */
public static final String JAVADOC_ANNOTATION_TYPE = AnnotationTypeEnum.JAVADOC.getName();
diff --git a/test-14/src/test/annotationtransformer/AnnotationTransformerSampleTest.java b/test-14/src/test/annotationtransformer/AnnotationTransformerSampleTest.java
index d15c9b3..4e2936f 100644
--- a/test-14/src/test/annotationtransformer/AnnotationTransformerSampleTest.java
+++ b/test-14/src/test/annotationtransformer/AnnotationTransformerSampleTest.java
@@ -64,7 +64,7 @@
public static void main(String[] argv) {
TestNG tng = new TestNG();
tng.setVerbose(0);
- tng.setDefaultAnnotations(TestNG.JAVADOC_ANNOTATION_TYPE);
+ tng.setAnnotations(TestNG.JAVADOC_ANNOTATION_TYPE);
tng.setSourcePath("test-14/src");
tng.setAnnotationTransformer(new MyTransformer());
tng.setTestClasses(new Class[] { AnnotationTransformerSampleTest.class});
diff --git a/test-14/src/test/annotationtransformer/AnnotationTransformerTest.java b/test-14/src/test/annotationtransformer/AnnotationTransformerTest.java
index ac1c209..450509d 100644
--- a/test-14/src/test/annotationtransformer/AnnotationTransformerTest.java
+++ b/test-14/src/test/annotationtransformer/AnnotationTransformerTest.java
@@ -17,7 +17,7 @@
public void verifyInvocationCount() {
TestNG tng = new TestNG();
tng.setVerbose(0);
- tng.setDefaultAnnotations(TestNG.JAVADOC_ANNOTATION_TYPE);
+ tng.setAnnotations(TestNG.JAVADOC_ANNOTATION_TYPE);
tng.setSourcePath("test-14/src");
tng.setAnnotationTransformer(new MyTransformer());
tng.setTestClasses(new Class[] { AnnotationTransformerSampleTest.class});
diff --git a/test-14/src/test/failedconfs/FailedBeforeTestMethodConfigurationBehaviorTest.java b/test-14/src/test/failedconfs/FailedBeforeTestMethodConfigurationBehaviorTest.java
index db24494..65832b1 100644
--- a/test-14/src/test/failedconfs/FailedBeforeTestMethodConfigurationBehaviorTest.java
+++ b/test-14/src/test/failedconfs/FailedBeforeTestMethodConfigurationBehaviorTest.java
@@ -29,7 +29,7 @@
public void beforeTestMethodFailureInTwoClasses() {
TestNG testng = new TestNG();
testng.setSourcePath("./test-14/src;src");
- testng.setDefaultAnnotations(TestNG.JAVADOC_ANNOTATION_TYPE);
+ testng.setAnnotations(TestNG.JAVADOC_ANNOTATION_TYPE);
testng.setTestClasses(new Class[] { Test1.class, Test2.class });
testng.setVerbose(0);
testng.setOutputDirectory(OutputDirectoryPatch.getOutputDirectory());
diff --git a/test-14/src/test/reports/ReportTest.java b/test-14/src/test/reports/ReportTest.java
index 64637b3..f2ee1e2 100644
--- a/test-14/src/test/reports/ReportTest.java
+++ b/test-14/src/test/reports/ReportTest.java
@@ -93,7 +93,7 @@
public void shouldHonorSuiteName() {
TestNG testng = TestHelper.createTestNG();
testng.setSourcePath("./test-14/src;src");
- testng.setDefaultAnnotations(TestNG.JAVADOC_ANNOTATION_TYPE);
+ testng.setAnnotations(TestNG.JAVADOC_ANNOTATION_TYPE);
testng.setTestClasses(new Class[] { A.class, B.class });
String outputDir = testng.getOutputDirectory();
String dirA = outputDir + File.separatorChar + "SuiteA-JDK14";
diff --git a/test/build.xml b/test/build.xml
index 1760f00..4fbed0c 100644
--- a/test/build.xml
+++ b/test/build.xml
@@ -97,7 +97,7 @@
<testng classpathref="run14.cp"
outputdir="${testng.report.dir}"
sourcedir="${test14.src.dir}"
- target="1.4">
+ annotations="javadoc">
<xmlfileset dir="${test14.dir}" includes="testng.xml"/>
</testng>
</target>
diff --git a/test/v4/build.xml b/test/v4/build.xml
index a74bb53..fcbcbff 100644
--- a/test/v4/build.xml
+++ b/test/v4/build.xml
@@ -97,7 +97,7 @@
<testng classpathref="run14.cp"
outputdir="${testng.report.dir}"
sourcedir="${test14.src.dir}"
- target="1.4">
+ annotations="javadoc">
<xmlfileset dir="${test14.dir}" includes="testng.xml"/>
</testng>
</target>