public class TestBase extends Object
Application.
To clean App Fabric state, you can use the clear() method.
Custom configurations for CDAP can be set by using ClassRule and TestConfiguration.
TestConfiguration| Modifier and Type | Field and Description |
|---|---|
static org.junit.rules.TemporaryFolder |
tmpFolder |
| Constructor and Description |
|---|
TestBase() |
| Modifier and Type | Method and Description |
|---|---|
protected static void |
addAppArtifact(co.cask.cdap.proto.Id.Artifact artifactId,
Class<?> appClass)
Build an application artifact from the specified class and then add it.
|
protected static void |
addAppArtifact(co.cask.cdap.proto.Id.Artifact artifactId,
Class<?> appClass,
Manifest manifest)
Build an application artifact from the specified class and then add it.
|
protected static void |
addAppArtifact(co.cask.cdap.proto.Id.Artifact artifactId,
Class<?> appClass,
String... exportPackages)
Build an application artifact from the specified class and then add it.
|
protected static void |
addArtifact(co.cask.cdap.proto.Id.Artifact artifactId,
File artifactFile)
Add the specified artifact.
|
protected <T extends DatasetAdmin> |
addDatasetInstance(co.cask.cdap.proto.Id.Namespace namespace,
String datasetTypeName,
String datasetInstanceName)
Adds an instance of dataset.
|
protected static <T extends DatasetAdmin> |
addDatasetInstance(co.cask.cdap.proto.Id.Namespace namespace,
String datasetTypeName,
String datasetInstanceName,
DatasetProperties props)
Adds an instance of a dataset.
|
protected <T extends DatasetAdmin> |
addDatasetInstance(String datasetTypeName,
String datasetInstanceName)
Adds an instance of dataset.
|
protected static <T extends DatasetAdmin> |
addDatasetInstance(String datasetTypeName,
String datasetInstanceName,
DatasetProperties props)
Adds an instance of a dataset.
|
protected static void |
addPluginArtifact(co.cask.cdap.proto.Id.Artifact artifactId,
co.cask.cdap.proto.Id.Artifact parent,
Class<?> pluginClass,
Class<?>... pluginClasses)
Build an artifact from the specified plugin classes and then add it.
|
protected static void |
addPluginArtifact(co.cask.cdap.proto.Id.Artifact artifactId,
co.cask.cdap.proto.Id.Artifact parent,
Set<PluginClass> additionalPlugins,
Class<?> pluginClass,
Class<?>... pluginClasses)
Build an artifact from the specified plugin classes and then add it.
|
protected static void |
addPluginArtifact(co.cask.cdap.proto.Id.Artifact artifactId,
Set<co.cask.cdap.proto.artifact.ArtifactRange> parentArtifacts,
Class<?> pluginClass,
Class<?>... pluginClasses)
Build an artifact from the specified plugin classes and then add it.
|
void |
afterTest()
By default after each test finished, it will stop all apps started during the test.
|
void |
beforeTest() |
protected static void |
clear()
Clear the state of app fabric, by removing all deployed applications, Datasets and Streams.
|
protected static void |
createNamespace(co.cask.cdap.proto.Id.Namespace namespace)
Creates a Namespace.
|
protected static void |
deleteNamespace(co.cask.cdap.proto.Id.Namespace namespace)
Deletes a Namespace.
|
protected static ApplicationManager |
deployApplication(Class<? extends Application> applicationClz,
Config appConfig,
File... bundleEmbeddedJars) |
protected static ApplicationManager |
deployApplication(Class<? extends Application> applicationClz,
File... bundleEmbeddedJars)
Deploys an
Application. |
protected static ApplicationManager |
deployApplication(co.cask.cdap.proto.Id.Application appId,
co.cask.cdap.proto.artifact.AppRequest appRequest)
Deploys an
Application. |
protected static ApplicationManager |
deployApplication(co.cask.cdap.proto.Id.Namespace namespace,
Class<? extends Application> applicationClz,
Config appConfig,
File... bundleEmbeddedJars) |
protected static ApplicationManager |
deployApplication(co.cask.cdap.proto.Id.Namespace namespace,
Class<? extends Application> applicationClz,
File... bundleEmbeddedJars)
Deploys an
Application. |
protected static void |
deployDatasetModule(co.cask.cdap.proto.Id.Namespace namespace,
String moduleName,
Class<? extends DatasetModule> datasetModule)
Deploys
DatasetModule. |
protected static void |
deployDatasetModule(String moduleName,
Class<? extends DatasetModule> datasetModule)
Deploys
DatasetModule. |
static void |
finish() |
protected <T> DataSetManager<T> |
getDataset(co.cask.cdap.proto.Id.Namespace namespace,
String datasetInstanceName)
Gets Dataset manager of Dataset instance of type
|
protected <T> DataSetManager<T> |
getDataset(String datasetInstanceName)
Gets Dataset manager of Dataset instance of type
|
protected MetricsManager |
getMetricsManager() |
protected Connection |
getQueryClient()
Returns a JDBC connection that allows to run SQL queries over data sets.
|
protected Connection |
getQueryClient(co.cask.cdap.proto.Id.Namespace namespace)
Returns a JDBC connection that allows to run SQL queries over data sets.
|
protected StreamManager |
getStreamManager(co.cask.cdap.proto.Id.Namespace namespace,
String streamName)
Returns a
StreamManager for the specified stream in the specified namespace |
protected StreamManager |
getStreamManager(String streamName)
Returns a
StreamManager for the specified stream in the default namespace |
protected co.cask.tephra.TransactionManager |
getTxService() |
static void |
initialize() |
public void afterTest()
throws Exception
Exceptionprotected MetricsManager getMetricsManager()
protected static void createNamespace(co.cask.cdap.proto.Id.Namespace namespace)
throws Exception
namespace - the namespace to createExceptionprotected static void deleteNamespace(co.cask.cdap.proto.Id.Namespace namespace)
throws Exception
namespace - the namespace to createExceptionprotected static ApplicationManager deployApplication(co.cask.cdap.proto.Id.Namespace namespace, Class<? extends Application> applicationClz, File... bundleEmbeddedJars)
Application. The Flows and
other programs defined in the application must be in the same or children package as the application.applicationClz - The application classApplicationManager to manage the deployed application.protected static ApplicationManager deployApplication(co.cask.cdap.proto.Id.Namespace namespace, Class<? extends Application> applicationClz, Config appConfig, File... bundleEmbeddedJars)
protected static ApplicationManager deployApplication(Class<? extends Application> applicationClz, File... bundleEmbeddedJars)
Application. The Flows and
other programs defined in the application must be in the same or children package as the application.applicationClz - The application classApplicationManager to manage the deployed application.protected static ApplicationManager deployApplication(Class<? extends Application> applicationClz, Config appConfig, File... bundleEmbeddedJars)
protected static ApplicationManager deployApplication(co.cask.cdap.proto.Id.Application appId, co.cask.cdap.proto.artifact.AppRequest appRequest) throws Exception
Application. The application artifact must already exist.appId - the id of the application to createappRequest - the application create or update requestApplicationManager to manage the deployed applicationExceptionprotected static void addArtifact(co.cask.cdap.proto.Id.Artifact artifactId,
File artifactFile)
throws Exception
artifactId - the id of the artifact to addartifactFile - the contents of the artifact. Must be a valid jar file containing apps or pluginsExceptionprotected static void addAppArtifact(co.cask.cdap.proto.Id.Artifact artifactId,
Class<?> appClass)
throws Exception
artifactId - the id of the artifact to addappClass - the application class to build the artifact fromExceptionprotected static void addAppArtifact(co.cask.cdap.proto.Id.Artifact artifactId,
Class<?> appClass,
String... exportPackages)
throws Exception
artifactId - the id of the artifact to addappClass - the application class to build the artifact fromexportPackages - the packages to export and place in the manifest of the jar to build. This should include
packages that contain classes that plugins for the application will implement.Exceptionprotected static void addAppArtifact(co.cask.cdap.proto.Id.Artifact artifactId,
Class<?> appClass,
Manifest manifest)
throws Exception
artifactId - the id of the artifact to addappClass - the application class to build the artifact frommanifest - the manifest to use when building the jarExceptionprotected static void addPluginArtifact(co.cask.cdap.proto.Id.Artifact artifactId,
co.cask.cdap.proto.Id.Artifact parent,
Class<?> pluginClass,
Class<?>... pluginClasses)
throws Exception
artifactId - the id of the artifact to addparent - the parent artifact it extendspluginClass - the plugin class to build the jar frompluginClasses - any additional plugin classes that should be included in the jarExceptionprotected static void addPluginArtifact(co.cask.cdap.proto.Id.Artifact artifactId,
co.cask.cdap.proto.Id.Artifact parent,
Set<PluginClass> additionalPlugins,
Class<?> pluginClass,
Class<?>... pluginClasses)
throws Exception
artifactId - the id of the artifact to addparent - the parent artifact it extendsadditionalPlugins - any plugin classes that need to be explicitly declared because they cannot be found
by inspecting the jar. This is true for 3rd party plugins, such as jdbc driverspluginClass - the plugin class to build the jar frompluginClasses - any additional plugin classes that should be included in the jarExceptionprotected static void addPluginArtifact(co.cask.cdap.proto.Id.Artifact artifactId,
Set<co.cask.cdap.proto.artifact.ArtifactRange> parentArtifacts,
Class<?> pluginClass,
Class<?>... pluginClasses)
throws Exception
artifactId - the id of the artifact to addparentArtifacts - the parent artifacts it extendspluginClass - the plugin class to build the jar frompluginClasses - any additional plugin classes that should be included in the jarExceptionprotected static void clear()
protected static void deployDatasetModule(co.cask.cdap.proto.Id.Namespace namespace,
String moduleName,
Class<? extends DatasetModule> datasetModule)
throws Exception
DatasetModule.moduleName - name of the moduledatasetModule - module classExceptionprotected static void deployDatasetModule(String moduleName, Class<? extends DatasetModule> datasetModule) throws Exception
DatasetModule.moduleName - name of the moduledatasetModule - module classExceptionprotected static <T extends DatasetAdmin> T addDatasetInstance(co.cask.cdap.proto.Id.Namespace namespace, String datasetTypeName, String datasetInstanceName, DatasetProperties props) throws Exception
T - type of the dataset admindatasetTypeName - dataset type namedatasetInstanceName - instance nameprops - propertiesExceptionprotected static <T extends DatasetAdmin> T addDatasetInstance(String datasetTypeName, String datasetInstanceName, DatasetProperties props) throws Exception
T - type of the dataset admindatasetTypeName - dataset type namedatasetInstanceName - instance nameprops - propertiesExceptionprotected final <T extends DatasetAdmin> T addDatasetInstance(co.cask.cdap.proto.Id.Namespace namespace, String datasetTypeName, String datasetInstanceName) throws Exception
T - type of the dataset admindatasetTypeName - dataset type namedatasetInstanceName - instance nameExceptionprotected final <T extends DatasetAdmin> T addDatasetInstance(String datasetTypeName, String datasetInstanceName) throws Exception
T - type of the dataset admindatasetTypeName - dataset type namedatasetInstanceName - instance nameExceptionprotected final <T> DataSetManager<T> getDataset(co.cask.cdap.proto.Id.Namespace namespace, String datasetInstanceName) throws Exception
datasetInstanceName - - instance name of datasetExceptionprotected final <T> DataSetManager<T> getDataset(String datasetInstanceName) throws Exception
datasetInstanceName - - instance name of datasetExceptionprotected final Connection getQueryClient(co.cask.cdap.proto.Id.Namespace namespace) throws Exception
Exceptionprotected final Connection getQueryClient() throws Exception
Exceptionprotected final StreamManager getStreamManager(String streamName)
StreamManager for the specified stream in the default namespacestreamName - the specified streamStreamManager for the specified stream in the default namespaceprotected final StreamManager getStreamManager(co.cask.cdap.proto.Id.Namespace namespace, String streamName)
StreamManager for the specified stream in the specified namespacestreamName - the specified streamStreamManager for the specified stream in the specified namespaceprotected co.cask.tephra.TransactionManager getTxService()
Copyright © 2016 Cask Data, Inc. Licensed under the Apache License, Version 2.0.