co.cask.cdap.test
Class TestBase

java.lang.Object
  extended by co.cask.cdap.test.TestBase

public class TestBase
extends Object

Base class to inherit from, provides testing functionality for Application. To clean App Fabric state, you can use the clear() method.


Field Summary
static org.junit.rules.TemporaryFolder tmpFolder
           
 
Constructor Summary
TestBase()
           
 
Method Summary
protected
<T extends DatasetAdmin>
T
addDatasetInstance(String datasetTypeName, String datasetInstanceName)
          Adds an instance of dataset.
protected
<T extends DatasetAdmin>
T
addDatasetInstance(String datasetTypeName, String datasetInstanceName, DatasetProperties props)
          Adds an instance of a dataset.
protected  void clear()
          Clear the state of app fabric, by removing all deployed applications, Datasets and Streams.
protected  ApplicationManager deployApplication(Class<? extends Application> applicationClz, File... bundleEmbeddedJars)
          Deploys an Application.
protected  void deployDatasetModule(String moduleName, Class<? extends DatasetModule> datasetModule)
          Deploys DatasetModule.
static void finish()
           
protected
<T> DataSetManager<T>
getDataset(String datasetInstanceName)
          Gets Dataset manager of Dataset instance of type
protected  Connection getQueryClient()
          Returns a JDBC connection that allows to run SQL queries over data sets.
static void init()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tmpFolder

public static org.junit.rules.TemporaryFolder tmpFolder
Constructor Detail

TestBase

public TestBase()
Method Detail

deployApplication

protected ApplicationManager deployApplication(Class<? extends Application> applicationClz,
                                               File... bundleEmbeddedJars)
Deploys an Application. The Flows and Procedures defined in the application must be in the same or children package as the application.

Parameters:
applicationClz - The application class
Returns:
An ApplicationManager to manage the deployed application.

clear

protected void clear()
Clear the state of app fabric, by removing all deployed applications, Datasets and Streams. This method could be called between two unit tests, to make them independent.


init

public static void init()
                 throws Exception
Throws:
Exception

finish

public static final void finish()

deployDatasetModule

@Beta
protected final void deployDatasetModule(String moduleName,
                                              Class<? extends DatasetModule> datasetModule)
                                  throws Exception
Deploys DatasetModule.

Parameters:
moduleName - name of the module
datasetModule - module class
Throws:
Exception

addDatasetInstance

@Beta
protected final <T extends DatasetAdmin> T addDatasetInstance(String datasetTypeName,
                                                                   String datasetInstanceName,
                                                                   DatasetProperties props)
                                                   throws Exception
Adds an instance of a dataset.

Type Parameters:
T - type of the dataset admin
Parameters:
datasetTypeName - dataset type name
datasetInstanceName - instance name
props - properties
Throws:
Exception

addDatasetInstance

@Beta
protected final <T extends DatasetAdmin> T addDatasetInstance(String datasetTypeName,
                                                                   String datasetInstanceName)
                                                   throws Exception
Adds an instance of dataset.

Type Parameters:
T - type of the dataset admin
Parameters:
datasetTypeName - dataset type name
datasetInstanceName - instance name
Throws:
Exception

getDataset

@Beta
protected final <T> DataSetManager<T> getDataset(String datasetInstanceName)
                                      throws Exception
Gets Dataset manager of Dataset instance of type

Parameters:
datasetInstanceName - - instance name of dataset
Returns:
Dataset Manager of Dataset instance of type
Throws:
Exception

getQueryClient

@Beta
protected final Connection getQueryClient()
                                   throws Exception
Returns a JDBC connection that allows to run SQL queries over data sets.

Throws:
Exception


Copyright © 2015 Cask Data, Inc. Licensed under the Apache License, Version 2.0.