Package org.apache.flink.test.util
Class AbstractTestBase
- java.lang.Object
-
- org.apache.flink.test.util.AbstractTestBase
-
- Direct Known Subclasses:
JavaProgramTestBase
,MultipleProgramsTestBase
public abstract class AbstractTestBase extends Object
Base class for unit tests that run multiple tests and want to reuse the same Flink cluster. This saves a significant amount of time, since the startup and shutdown of the Flink clusters (including actor systems, etc) usually dominates the execution of the actual tests.To write a unit test against this test base, simply extend it and add one or more regular test methods and retrieve the StreamExecutionEnvironment from the context:
@Test public void someTest() { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); // test code env.execute(); } @Test public void anotherTest() { StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); // test code env.execute(); }
-
-
Field Summary
Fields Modifier and Type Field Description static MiniClusterExtension
MINI_CLUSTER_EXTENSION
protected File
temporaryFolder
-
Constructor Summary
Constructors Constructor Description AbstractTestBase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cleanupRunningJobs(MiniClusterClient clusterClient)
File
createAndRegisterTempFile(String fileName)
String
createTempFile(String fileName, String contents)
String
getTempDirPath(String dirName)
String
getTempFilePath(String fileName)
-
-
-
Field Detail
-
MINI_CLUSTER_EXTENSION
@RegisterExtension public static final MiniClusterExtension MINI_CLUSTER_EXTENSION
-
temporaryFolder
@TempDir protected File temporaryFolder
-
-
Method Detail
-
cleanupRunningJobs
@AfterEach public final void cleanupRunningJobs(MiniClusterClient clusterClient) throws Exception
- Throws:
Exception
-
getTempDirPath
public String getTempDirPath(String dirName) throws IOException
- Throws:
IOException
-
getTempFilePath
public String getTempFilePath(String fileName) throws IOException
- Throws:
IOException
-
createTempFile
public String createTempFile(String fileName, String contents) throws IOException
- Throws:
IOException
-
createAndRegisterTempFile
public File createAndRegisterTempFile(String fileName) throws IOException
- Throws:
IOException
-
-