com.github.mlk.junit.rules.SparkRule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of assortmentofjunitrules Show documentation
Show all versions of assortmentofjunitrules Show documentation
Useful assortment of JUnit rules for integration testing
package com.github.mlk.junit.rules;
import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaSparkContext;
import org.junit.rules.ExternalResource;
/**
* Starts and stops a local Spark instance for integration testing against Apache Spark. For an
* example of it in action see the tests for this class.
*/
public class SparkRule extends ExternalResource {
private JavaSparkContext sc;
@Override
protected void before() throws Throwable {
SparkConf conf = new SparkConf().setAppName("UNIT_TEST").setMaster("local[4]");
sc = new JavaSparkContext(conf);
}
@Override
protected void after() {
sc.close();
}
public JavaSparkContext getContext() {
return sc;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy