Skip to content
Snippets Groups Projects
Commit 2f9c2736 authored by Shivaram Venkataraman's avatar Shivaram Venkataraman
Browse files

[SPARK-16581][SPARKR] Fix JVM API tests in SparkR

## What changes were proposed in this pull request?

Remove cleanup.jobj test. Use JVM wrapper API for other test cases.

## How was this patch tested?

Run R unit tests with testthat 1.0

Author: Shivaram Venkataraman <shivaram@cs.berkeley.edu>

Closes #14904 from shivaram/sparkr-jvm-tests-fix.
parent d375c8a3
No related branches found
No related tags found
No related merge requests found
......@@ -20,24 +20,17 @@ context("JVM API")
sparkSession <- sparkR.session(enableHiveSupport = FALSE)
test_that("Create and call methods on object", {
jarr <- newJObject("java.util.ArrayList")
jarr <- sparkR.newJObject("java.util.ArrayList")
# Add an element to the array
callJMethod(jarr, "add", 1L)
sparkR.callJMethod(jarr, "add", 1L)
# Check if get returns the same element
expect_equal(callJMethod(jarr, "get", 0L), 1L)
expect_equal(sparkR.callJMethod(jarr, "get", 0L), 1L)
})
test_that("Call static methods", {
# Convert a boolean to a string
strTrue <- callJStatic("java.lang.String", "valueOf", TRUE)
strTrue <- sparkR.callJStatic("java.lang.String", "valueOf", TRUE)
expect_equal(strTrue, "true")
})
test_that("Manually garbage collect objects", {
jarr <- newJObject("java.util.ArrayList")
cleanup.jobj(jarr)
# Using a jobj after GC should throw an error
expect_error(print(jarr), "Error in invokeJava.*")
})
sparkR.session.stop()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment