8022749: Convert junit tests to testng in test/java/lang/invoke
Reviewed-by: mduigou, alanb
Contributed-by: Mani Sarkar <sadhak001@gmail.com>
--- a/jdk/test/java/lang/invoke/AccessControlTest.java Mon Aug 12 17:40:14 2013 +0100
+++ b/jdk/test/java/lang/invoke/AccessControlTest.java Mon Aug 12 12:11:04 2013 -0700
@@ -28,7 +28,7 @@
* @library ../../../..
* @build test.java.lang.invoke.AccessControlTest
* @build test.java.lang.invoke.AccessControlTest_subpkg.Acquaintance_remote
- * @run junit/othervm test.java.lang.invoke.AccessControlTest
+ * @run testng/othervm test.java.lang.invoke.AccessControlTest
*/
package test.java.lang.invoke;
@@ -36,12 +36,14 @@
import java.lang.invoke.*;
import java.lang.reflect.*;
import java.util.*;
-import org.junit.*;
+import org.testng.*;
+import org.testng.annotations.*;
import static java.lang.invoke.MethodHandles.*;
import static java.lang.invoke.MethodHandles.Lookup.*;
import static java.lang.invoke.MethodType.*;
-import static org.junit.Assert.*;
+import static org.testng.Assert.*;
+
import test.java.lang.invoke.AccessControlTest_subpkg.Acquaintance_remote;
--- a/jdk/test/java/lang/invoke/ClassValueTest.java Mon Aug 12 17:40:14 2013 +0100
+++ b/jdk/test/java/lang/invoke/ClassValueTest.java Mon Aug 12 12:11:04 2013 -0700
@@ -26,20 +26,14 @@
/* @test
* @summary tests for class-specific values
* @compile ClassValueTest.java
- * @run junit/othervm test.java.lang.invoke.ClassValueTest
- */
-
-/*
- Manually:
- $ $JAVA7X_HOME/bin/javac -d foo -cp $JUNIT4_JAR test/java/lang/invoke/ClassValueTest.java
- $ $JAVA7X_HOME/bin/java -cp foo:$JUNIT4_JAR org.junit.runner.JUnitCore test.java.lang.invoke.ClassValueTest
- Output: .testAdd => 1000 : Integer
+ * @run testng/othervm test.java.lang.invoke.ClassValueTest
*/
package test.java.lang.invoke;
-import org.junit.*;
-import static org.junit.Assert.*;
+import org.testng.*;
+import static org.testng.AssertJUnit.*;
+import org.testng.annotations.*;
/**
* @author jrose
--- a/jdk/test/java/lang/invoke/InvokeGenericTest.java Mon Aug 12 17:40:14 2013 +0100
+++ b/jdk/test/java/lang/invoke/InvokeGenericTest.java Mon Aug 12 12:11:04 2013 -0700
@@ -26,7 +26,7 @@
/* @test
* @summary unit tests for java.lang.invoke.MethodHandle.invoke
* @compile InvokeGenericTest.java
- * @run junit/othervm test.java.lang.invoke.InvokeGenericTest
+ * @run testng/othervm test.java.lang.invoke.InvokeGenericTest
*/
package test.java.lang.invoke;
@@ -36,10 +36,9 @@
import static java.lang.invoke.MethodType.*;
import java.lang.reflect.*;
import java.util.*;
-import org.junit.*;
-import static org.junit.Assert.*;
-import static org.junit.Assume.*;
-
+import org.testng.*;
+import static org.testng.AssertJUnit.*;
+import org.testng.annotations.*;
/**
*
@@ -71,7 +70,7 @@
String testName;
static int allPosTests, allNegTests;
int posTests, negTests;
- @After
+ @AfterMethod
public void printCounts() {
if (verbosity >= 2 && (posTests | negTests) != 0) {
System.out.println();
--- a/jdk/test/java/lang/invoke/JavaDocExamplesTest.java Mon Aug 12 17:40:14 2013 +0100
+++ b/jdk/test/java/lang/invoke/JavaDocExamplesTest.java Mon Aug 12 12:11:04 2013 -0700
@@ -26,19 +26,9 @@
/* @test
* @summary example code used in javadoc for java.lang.invoke API
* @compile JavaDocExamplesTest.java
- * @run junit/othervm test.java.lang.invoke.JavaDocExamplesTest
+ * @run testng/othervm test.java.lang.invoke.JavaDocExamplesTest
*/
-/*
----- To run outside jtreg:
-$ $JAVA7X_HOME/bin/javac -cp $JUNIT4_JAR -d /tmp/Classes \
- $DAVINCI/sources/jdk/test/java/lang/invoke/JavaDocExamplesTest.java
-$ $JAVA7X_HOME/bin/java -cp $JUNIT4_JAR:/tmp/Classes \
- -DJavaDocExamplesTest.verbosity=1 \
- test.java.lang.invoke.JavaDocExamplesTest
-----
-*/
-
package test.java.lang.invoke;
import java.lang.invoke.*;
@@ -47,22 +37,21 @@
import java.util.*;
-import org.junit.*;
-import static org.junit.Assert.*;
-
+import org.testng.*;
+import static org.testng.AssertJUnit.*;
+import org.testng.annotations.*;
/**
* @author jrose
*/
public class JavaDocExamplesTest {
- /** Wrapper for running the JUnit tests in this module.
- * Put JUnit on the classpath!
+ /** Wrapper for running the TestNG tests in this module.
+ * Put TestNG on the classpath!
*/
public static void main(String... ignore) throws Throwable {
- System.out.println("can run this as:");
- System.out.println("$ java org.junit.runner.JUnitCore "+JavaDocExamplesTest.class.getName());
new JavaDocExamplesTest().run();
}
+
public void run() throws Throwable {
testFindVirtual();
testPermuteArguments();
--- a/jdk/test/java/lang/invoke/MethodTypeTest.java Mon Aug 12 17:40:14 2013 +0100
+++ b/jdk/test/java/lang/invoke/MethodTypeTest.java Mon Aug 12 12:11:04 2013 -0700
@@ -24,7 +24,7 @@
/* @test
* @summary unit tests for java.lang.invoke.MethodType
* @compile MethodTypeTest.java
- * @run junit/othervm test.java.lang.invoke.MethodTypeTest
+ * @run testng/othervm test.java.lang.invoke.MethodTypeTest
*/
package test.java.lang.invoke;
@@ -34,8 +34,9 @@
import java.lang.reflect.Method;
import java.util.*;
-import org.junit.*;
-import static org.junit.Assert.*;
+import org.testng.*;
+import static org.testng.AssertJUnit.*;
+import org.testng.annotations.*;
/**
*
@@ -53,7 +54,7 @@
private MethodType[] GALLERY;
private Method compareTo;
- @Before
+ @BeforeMethod
public void setUp() throws Exception {
rtype = void.class;
ptypes = new Class<?>[] { int.class, String.class };
@@ -94,7 +95,7 @@
};
}
- @After
+ @AfterMethod
public void tearDown() throws Exception {
}
--- a/jdk/test/java/lang/invoke/PermuteArgsTest.java Mon Aug 12 17:40:14 2013 +0100
+++ b/jdk/test/java/lang/invoke/PermuteArgsTest.java Mon Aug 12 12:11:04 2013 -0700
@@ -25,7 +25,7 @@
/* @test
* @summary unit tests for method handles which permute their arguments
- * @run junit/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies -ea -esa -DPermuteArgsTest.MAX_ARITY=8 test.java.lang.invoke.PermuteArgsTest
+ * @run testng/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies -ea -esa -DPermuteArgsTest.MAX_ARITY=8 test.java.lang.invoke.PermuteArgsTest
*/
/* Examples of manual runs:
* java -DPermuteArgsTest.{DRY_RUN=true,MAX_ARITY=253} test.java.lang.invoke.PermuteArgsTest
@@ -35,7 +35,8 @@
package test.java.lang.invoke;
-import org.junit.*;
+import org.testng.*;
+import org.testng.annotations.*;
import java.util.*;
import java.lang.reflect.*;
--- a/jdk/test/java/lang/invoke/ThrowExceptionsTest.java Mon Aug 12 17:40:14 2013 +0100
+++ b/jdk/test/java/lang/invoke/ThrowExceptionsTest.java Mon Aug 12 12:11:04 2013 -0700
@@ -25,12 +25,13 @@
/* @test
* @summary unit tests for method handles which permute their arguments
- * @run junit test.java.lang.invoke.ThrowExceptionsTest
+ * @run testng test.java.lang.invoke.ThrowExceptionsTest
*/
package test.java.lang.invoke;
-import org.junit.*;
+import org.testng.*;
+import org.testng.annotations.*;
import java.util.*;
import java.lang.reflect.*;