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 |
TMP_FOLDER |
| Constructor and Description |
|---|
TestBase() |
| Modifier and Type | Method and Description |
|---|---|
protected static ArtifactManager |
addAppArtifact(co.cask.cdap.proto.id.ArtifactId artifactId,
Class<?> appClass)
Build an application artifact from the specified class and then add it.
|
protected static ArtifactManager |
addAppArtifact(co.cask.cdap.proto.id.ArtifactId artifactId,
Class<?> appClass,
Manifest manifest)
Build an application artifact from the specified class and then add it.
|
protected static ArtifactManager |
addAppArtifact(co.cask.cdap.proto.id.ArtifactId artifactId,
Class<?> appClass,
String... exportPackages)
Build an application artifact from the specified class and then add it.
|
protected static ArtifactManager |
addArtifact(co.cask.cdap.proto.id.ArtifactId artifactId,
File artifactFile)
Add the specified artifact.
|
protected <T extends DatasetAdmin> |
addDatasetInstance(co.cask.cdap.proto.id.DatasetId datasetId,
String datasetTypeName)
Adds an instance of dataset.
|
protected static <T extends DatasetAdmin> |
addDatasetInstance(String datasetTypeName,
co.cask.cdap.proto.id.DatasetId datasetId,
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 ArtifactManager |
addPluginArtifact(co.cask.cdap.proto.id.ArtifactId artifactId,
co.cask.cdap.proto.id.ArtifactId parent,
Class<?> pluginClass,
Class<?>... pluginClasses)
Build an artifact from the specified plugin classes and then add it.
|
protected static ArtifactManager |
addPluginArtifact(co.cask.cdap.proto.id.ArtifactId artifactId,
co.cask.cdap.proto.id.ArtifactId parent,
Set<PluginClass> additionalPlugins,
Class<?> pluginClass,
Class<?>... pluginClasses)
Build an artifact from the specified plugin classes and then add it.
|
protected static ArtifactManager |
addPluginArtifact(co.cask.cdap.proto.id.ArtifactId artifactId,
Set<ArtifactRange> parentArtifacts,
Class<?> pluginClass,
Class<?>... pluginClasses)
Build an artifact from the specified plugin classes and then add it.
|
protected void |
addSchedule(co.cask.cdap.proto.id.ScheduleId scheduleId,
co.cask.cdap.proto.ScheduleDetail scheduleDetail)
Add a new schedule to an existing application
|
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 |
deleteAllApplications(co.cask.cdap.proto.id.NamespaceId namespaceId)
Deletes all applications in the specified namespace.
|
protected void |
deleteDatasetInstance(co.cask.cdap.proto.id.DatasetId datasetId)
Deletes an instance of dataset.
|
protected void |
deleteSchedule(co.cask.cdap.proto.id.ScheduleId scheduleId)
Delete an existing schedule.
|
protected static ApplicationManager |
deployApplication(co.cask.cdap.proto.id.ApplicationId appId,
co.cask.cdap.proto.artifact.AppRequest appRequest)
Deploys an
Application with version. |
protected static ApplicationManager |
deployApplication(Class<? extends Application> applicationClz,
Config appConfig,
File... bundleEmbeddedJars)
Deploys an
Application. |
protected static ApplicationManager |
deployApplication(Class<? extends Application> applicationClz,
File... bundleEmbeddedJars)
Deploys an
Application. |
protected static ApplicationManager |
deployApplication(co.cask.cdap.proto.id.NamespaceId namespace,
Class<? extends Application> applicationClz,
Config appConfig,
File... bundleEmbeddedJars)
Deploys an
Application with a config. |
protected static ApplicationManager |
deployApplication(co.cask.cdap.proto.id.NamespaceId namespace,
Class<? extends Application> applicationClz,
File... bundleEmbeddedJars)
Deploys an
Application. |
protected static void |
deployDatasetModule(co.cask.cdap.proto.id.DatasetModuleId datasetModuleId,
Class<? extends DatasetModule> datasetModule)
Deploys
DatasetModule. |
protected static void |
deployDatasetModule(String moduleName,
Class<? extends DatasetModule> datasetModule)
Deploys
DatasetModule. |
static void |
finish() |
protected co.cask.cdap.proto.ApplicationDetail |
getAppDetail(co.cask.cdap.proto.id.ApplicationId applicationId)
Gets the app detail of an application
|
protected static co.cask.cdap.security.spi.authorization.Authorizer |
getAuthorizer()
Returns an
Authorizer for performing authorization operations. |
protected static co.cask.cdap.common.conf.CConfiguration |
getConfiguration()
Returns the
CConfiguration used in tests. |
protected <T> DataSetManager<T> |
getDataset(co.cask.cdap.proto.id.DatasetId datasetId)
Gets Dataset manager of Dataset instance of type <T>.
|
protected <T> DataSetManager<T> |
getDataset(String datasetInstanceName)
Gets Dataset manager of Dataset instance of type <T>.
|
protected static MessagingAdmin |
getMessagingAdmin(co.cask.cdap.proto.id.NamespaceId namespace) |
protected static MessagingAdmin |
getMessagingAdmin(String namespace)
Returns a
MessagingAdmin for the given namespace. |
protected MessagingContext |
getMessagingContext()
Returns a
MessagingContext for interacting with the messaging system. |
protected static MetadataAdmin |
getMetadataAdmin() |
protected MetricsManager |
getMetricsManager() |
protected static co.cask.cdap.common.namespace.NamespaceAdmin |
getNamespaceAdmin()
Returns a
NamespaceAdmin to interact with namespaces. |
protected static PreviewManager |
getPreviewManager()
Returns a
PreviewManager to interact with preview. |
protected Connection |
getQueryClient()
Returns a JDBC connection that allows the running of SQL queries over data sets.
|
protected Connection |
getQueryClient(co.cask.cdap.proto.id.NamespaceId namespace)
Returns a JDBC connection that allows the running of SQL queries over data sets.
|
protected static SecureStore |
getSecureStore()
Returns a
SecureStore to interact with secure storage. |
protected static SecureStoreManager |
getSecureStoreManager()
Returns a
SecureStoreManager to interact with secure storage. |
protected StreamManager |
getStreamManager(co.cask.cdap.proto.id.StreamId streamId)
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 |
static void |
initialize() |
protected void |
updateSchedule(co.cask.cdap.proto.id.ScheduleId scheduleId,
co.cask.cdap.proto.ScheduleDetail scheduleDetail)
Update an existing schedule.
|
public void afterTest()
throws Exception
Exceptionprotected MetricsManager getMetricsManager()
protected static ApplicationManager deployApplication(co.cask.cdap.proto.id.NamespaceId 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.namespace - the namespace to deploy the application toapplicationClz - the application classbundleEmbeddedJars - any extra jars to bundle in the application jarApplicationManager to manage the deployed application.protected static ApplicationManager deployApplication(co.cask.cdap.proto.id.NamespaceId namespace, Class<? extends Application> applicationClz, Config appConfig, File... bundleEmbeddedJars)
Application with a config. The Flows and
other programs defined in the application must be in the same or children package as the application.namespace - the namespace to deploy the application toapplicationClz - the application classappConfig - the application configAppbundleEmbeddedJars - any extra jars to bundle in the application jarApplicationManager to manage the deployed application.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 classbundleEmbeddedJars - any extra jars to bundle in the application jarApplicationManager to manage the deployed application.protected static ApplicationManager deployApplication(Class<? extends Application> applicationClz, Config appConfig, 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 classappConfig - the application configbundleEmbeddedJars - any extra jars to bundle in the application jarApplicationManager to manage the deployed application.protected static ApplicationManager deployApplication(co.cask.cdap.proto.id.ApplicationId appId, co.cask.cdap.proto.artifact.AppRequest appRequest) throws Exception
Application with version. 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 ArtifactManager addArtifact(co.cask.cdap.proto.id.ArtifactId 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 ArtifactManager addAppArtifact(co.cask.cdap.proto.id.ArtifactId artifactId, Class<?> appClass) throws Exception
artifactId - the id of the artifact to addappClass - the application class to build the artifact fromArtifactManager to manage the added artifactExceptionprotected static ArtifactManager addAppArtifact(co.cask.cdap.proto.id.ArtifactId 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.ArtifactManager to manage the added artifactExceptionprotected static ArtifactManager addAppArtifact(co.cask.cdap.proto.id.ArtifactId 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 jarArtifactManager to manage the added artifactExceptionprotected static ArtifactManager addPluginArtifact(co.cask.cdap.proto.id.ArtifactId artifactId, co.cask.cdap.proto.id.ArtifactId 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 jarArtifactManager to manage the added plugin artifactExceptionprotected static ArtifactManager addPluginArtifact(co.cask.cdap.proto.id.ArtifactId artifactId, co.cask.cdap.proto.id.ArtifactId 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 jarArtifactManager to manage the added plugin artifactExceptionprotected static ArtifactManager addPluginArtifact(co.cask.cdap.proto.id.ArtifactId artifactId, Set<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 jarArtifactManager to manage the added plugin artifactExceptionprotected static void clear()
protected static void deployDatasetModule(co.cask.cdap.proto.id.DatasetModuleId datasetModuleId,
Class<? extends DatasetModule> datasetModule)
throws Exception
DatasetModule.datasetModuleId - the module iddatasetModule - 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(String datasetTypeName, co.cask.cdap.proto.id.DatasetId datasetId, DatasetProperties props) throws Exception
T - type of the dataset admindatasetId - the dataset iddatasetTypeName - dataset type name, like "table" or "fileset"props - 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.DatasetId datasetId, String datasetTypeName) throws Exception
T - type of the dataset admindatasetId - the dataset iddatasetTypeName - dataset type nameExceptionprotected final <T extends DatasetAdmin> T addDatasetInstance(String datasetTypeName, String datasetInstanceName) throws Exception
T - type of the dataset admindatasetTypeName - dataset type namedatasetInstanceName - instance nameExceptionprotected void deleteDatasetInstance(co.cask.cdap.proto.id.DatasetId datasetId)
throws Exception
datasetId - the dataset to deleteExceptionprotected final <T> DataSetManager<T> getDataset(co.cask.cdap.proto.id.DatasetId datasetId) throws Exception
datasetId - the id of the dataset to getExceptionprotected final <T> DataSetManager<T> getDataset(String datasetInstanceName) throws Exception
datasetInstanceName - instance name of datasetExceptionprotected final co.cask.cdap.proto.ApplicationDetail getAppDetail(co.cask.cdap.proto.id.ApplicationId applicationId)
throws Exception
applicationId - the app id of the applicationExceptionprotected final void addSchedule(co.cask.cdap.proto.id.ScheduleId scheduleId,
co.cask.cdap.proto.ScheduleDetail scheduleDetail)
throws Exception
scheduleId - the ID of the schedule to addscheduleDetail - the ScheduleDetail describing the new schedule.Exceptionprotected final void deleteSchedule(co.cask.cdap.proto.id.ScheduleId scheduleId)
throws Exception
scheduleId - the ID of the schedule to be deletedExceptionprotected final void updateSchedule(co.cask.cdap.proto.id.ScheduleId scheduleId,
co.cask.cdap.proto.ScheduleDetail scheduleDetail)
throws Exception
scheduleId - the ID of the schedule to addscheduleDetail - the ScheduleDetail describing the updated schedule.Exceptionprotected final Connection getQueryClient(co.cask.cdap.proto.id.NamespaceId namespace) throws Exception
namespace - namespace for the connectionExceptionprotected 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.StreamId streamId)
StreamManager for the specified stream in the specified namespacestreamId - the stream to getStreamManager for the specified stream in the specified namespaceprotected final MessagingContext getMessagingContext()
MessagingContext for interacting with the messaging system.protected static MessagingAdmin getMessagingAdmin(String namespace)
MessagingAdmin for the given namespace.protected static MessagingAdmin getMessagingAdmin(co.cask.cdap.proto.id.NamespaceId namespace)
protected static MetadataAdmin getMetadataAdmin()
MetadataAdmin to interact with metadataprotected static co.cask.cdap.common.namespace.NamespaceAdmin getNamespaceAdmin()
NamespaceAdmin to interact with namespaces.protected static SecureStore getSecureStore()
SecureStore to interact with secure storage.protected static SecureStoreManager getSecureStoreManager()
SecureStoreManager to interact with secure storage.@Beta protected static co.cask.cdap.security.spi.authorization.Authorizer getAuthorizer() throws IOException, co.cask.cdap.security.authorization.InvalidAuthorizerException
Authorizer for performing authorization operations.protected static PreviewManager getPreviewManager()
PreviewManager to interact with preview.protected static co.cask.cdap.common.conf.CConfiguration getConfiguration()
CConfiguration used in tests.Copyright © 2018 Cask Data, Inc. Licensed under the Apache License, Version 2.0.