本文整理匯總了Java中junit.extensions.TestSetup類的典型用法代碼示例。如果您正苦於以下問題:Java TestSetup類的具體用法?Java TestSetup怎麽用?Java TestSetup使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
TestSetup類屬於junit.extensions包,在下文中一共展示了TestSetup類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: suite
import junit.extensions.TestSetup; //導入依賴的package包/類
public static Test suite() {
TestSetup setup = new TestSetup(new TestSuite(TestJoinProperties.class)) {
protected void setUp() throws Exception {
Configuration conf = new Configuration();
cluster = new MiniDFSCluster.Builder(conf).numDataNodes(2).build();
base = cluster.getFileSystem().makeQualified(new Path("/nested"));
src = generateSources(conf);
}
protected void tearDown() throws Exception {
if (cluster != null) {
cluster.shutdown();
}
}
};
return setup;
}
示例2: additionalDatabaseDecoratorNoShutdown
import junit.extensions.TestSetup; //導入依賴的package包/類
/**
* Similar to additionalDatabaseDecorator except the database will
* not be shutdown, only deleted. It is the responsibility of the
* test to shut it down.
*
* @param test Test to be decorated
* @param logicalDbName The logical database name. This name is
* used to identify the database in
* openConnection(String logicalDatabaseName)
* method calls.
* @return decorated test.
*/
public static TestSetup additionalDatabaseDecoratorNoShutdown(
Test test,
String logicalDbName)
{
return new DatabaseChangeSetup(
new DropDatabaseSetup(test, logicalDbName)
{
protected void tearDown() throws Exception {
// the test is responsible for shutdown
removeDatabase();
}
},
logicalDbName,
generateUniqueDatabaseName(),
false);
}
示例3: baseSuite
import junit.extensions.TestSetup; //導入依賴的package包/類
/**
* The suite contains all testcases in this class running on different
* data models
*/
private static Test baseSuite(String name) {
TestSuite mainSuite = new TestSuite(name);
// Iterate over all data models and decorate the tests:
for (Iterator i = SURDataModelSetup.SURDataModel.values().iterator();
i.hasNext();) {
SURDataModelSetup.SURDataModel model =
(SURDataModelSetup.SURDataModel) i.next();
TestSuite suite = new TestSuite(SURTest.class);
TestSetup decorator = new SURDataModelSetup
(suite, model);
mainSuite.addTest(decorator);
}
return mainSuite;
}
示例4: baseSuite
import junit.extensions.TestSetup; //導入依賴的package包/類
/**
* The suite contains all testcases in this class running on different data models
*/
private static Test baseSuite(String name) {
TestSuite mainSuite = new TestSuite(name);
// Iterate over all data models and decorate the tests:
for (Iterator i = SURDataModelSetup.SURDataModel.values().iterator();
i.hasNext();) {
SURDataModelSetup.SURDataModel model =
(SURDataModelSetup.SURDataModel) i.next();
TestSuite suite = createTestCases(model.toString());
TestSetup decorator = new SURDataModelSetup(suite, model);
mainSuite.addTest(decorator);
}
return mainSuite;
}
示例5: suite
import junit.extensions.TestSetup; //導入依賴的package包/類
public static Test suite() {
TestSetup setup = new TestSetup(new TestSuite(TestMiniMRDFSSort.class)) {
protected void setUp() throws Exception {
Configuration conf = new Configuration();
dfsCluster = new MiniDFSCluster(conf, NUM_HADOOP_SLAVES, true, null);
dfs = dfsCluster.getFileSystem();
mrCluster = new MiniMRCluster(NUM_HADOOP_SLAVES,
dfs.getUri().toString(), 1);
}
protected void tearDown() throws Exception {
if (dfsCluster != null) { dfsCluster.shutdown(); }
if (mrCluster != null) { mrCluster.shutdown(); }
}
};
return setup;
}
示例6: suite
import junit.extensions.TestSetup; //導入依賴的package包/類
public static Test suite() {
TestSetup setup =
new TestSetup(new TestSuite(TestSpeculativeExecution.class)) {
@Override
protected void setUp() throws Exception {
JobConf conf = new JobConf();
conf.set(JT_IPC_ADDRESS, "localhost:0");
conf.set(JT_HTTP_ADDRESS, "0.0.0.0:0");
jobTracker = new FakeJobTracker
(conf, (clock = new SpecFakeClock(conf.getMapSpeculativeLag())),
trackers);
for (String tracker : trackers) {
FakeObjectUtilities.establishFirstContact(jobTracker, tracker);
}
}
@Override
protected void tearDown() throws Exception {
//delete the build/test/logs/ dir
}
};
return setup;
}
示例7: suite
import junit.extensions.TestSetup; //導入依賴的package包/類
public static Test suite() {
TestSetup setup = new TestSetup(new TestSuite(TestClusterStatus.class)) {
protected void setUp() throws Exception {
JobConf conf = new JobConf();
conf.setClass("mapred.jobtracker.taskScheduler",
TestClusterStatus.FakeTaskScheduler.class,
TaskScheduler.class);
mr = new MiniMRCluster(0, 0, 0, "file:///", 1, null, null, null, conf);
jobTracker = mr.getJobTrackerRunner().getJobTracker();
for (String tracker : trackers) {
establishFirstContact(jobTracker, tracker);
}
client = new JobClient(mr.createJobConf());
}
protected void tearDown() throws Exception {
client.close();
mr.shutdown();
}
};
return setup;
}
示例8: suite
import junit.extensions.TestSetup; //導入依賴的package包/類
public static Test suite() {
return new TestSetup(new TestSuite(TestAvailableForUnderConstruction.class)) {
protected void setUp() throws java.lang.Exception {
AppendTestUtil.LOG.info("setUp()");
conf = new Configuration();
conf.setInt("io.bytes.per.checksum", 512);
conf.setBoolean("dfs.support.append", true);
conf.setLong("dfs.timeout.get.available.from.datanode", 1000L);
buffersize = conf.getInt("io.file.buffer.size", 4096);
cluster = new MiniDFSCluster(conf, DATANODE_NUM, true, null);
fs = (DistributedFileSystem) cluster.getFileSystem();
}
protected void tearDown() throws Exception {
AppendTestUtil.LOG.info("tearDown()");
if (fs != null)
fs.close();
if (cluster != null)
cluster.shutdown();
}
};
}
示例9: suite
import junit.extensions.TestSetup; //導入依賴的package包/類
public static Test suite() {
return new TestSetup(new TestSuite(TestFileAppend3.class)) {
protected void setUp() throws java.lang.Exception {
AppendTestUtil.LOG.info("setUp()");
conf = new Configuration();
conf.setInt("io.bytes.per.checksum", 512);
conf.setBoolean("dfs.support.append", true);
buffersize = conf.getInt("io.file.buffer.size", 4096);
cluster = new MiniDFSCluster(conf, DATANODE_NUM, true, null);
fs = (DistributedFileSystem)cluster.getFileSystem();
}
protected void tearDown() throws Exception {
AppendTestUtil.LOG.info("tearDown()");
if(fs != null) fs.close();
if(cluster != null) cluster.shutdown();
}
};
}
示例10: testRunningErrorsInTestSetup
import junit.extensions.TestSetup; //導入依賴的package包/類
public void testRunningErrorsInTestSetup() {
TestCase failure= new TestCase("failure") {
public void runTest() {
fail();
}
};
TestCase error= new TestCase("error") {
public void runTest() {
throw new Error();
}
};
TestSuite suite= new TestSuite();
suite.addTest(failure);
suite.addTest(error);
TestSetup wrapper= new TestSetup(suite);
TestResult result= new TestResult();
wrapper.run(result);
assertEquals(1, result.failureCount());
assertEquals(1, result.errorCount());
}
示例11: suite
import junit.extensions.TestSetup; //導入依賴的package包/類
public static Test suite() {
TestSetup setup = new TestSetup(new TestSuite(TestJoinProperties.class)) {
protected void setUp() throws Exception {
Configuration conf = new Configuration();
cluster = new MiniDFSCluster(conf, 2, true, null);
base = cluster.getFileSystem().makeQualified(new Path("/nested"));
src = generateSources(conf);
}
protected void tearDown() throws Exception {
if (cluster != null) {
cluster.shutdown();
}
}
};
return setup;
}
示例12: suite
import junit.extensions.TestSetup; //導入依賴的package包/類
public static Test suite() {
return new TestSetup(new TestSuite(GreenPepperRepositoryTest.class)) {
@Override
protected void setUp() throws Exception
{
ws = new WebServer( 9005 );
ws.start();
}
@Override
protected void tearDown() throws Exception
{
ws.shutdown();
}
};
}
示例13: suite
import junit.extensions.TestSetup; //導入依賴的package包/類
public static Test suite()
{
TestSetup setup = new TestSetup(new TestSuite(TestResourceEventVoter.class))
{
protected void setUp() throws Exception
{
oneTimeSetup();
}
protected void tearDown() throws Exception
{
oneTimeTearDown();
}
};
return setup;
}
示例14: suite
import junit.extensions.TestSetup; //導入依賴的package包/類
public static Test suite()
{
TestSetup setup = new TestSetup(new TestSuite(PrivacyTest.class))
{
protected void setUp() throws Exception
{
log.info("starting setup -- PrivacyTest");
oneTimeSetup();
log.info("finished setup -- PrivacyTest");
}
protected void tearDown() throws Exception
{
oneTimeTearDown();
}
};
return setup;
}
示例15: testSetupErrorInTestSetup
import junit.extensions.TestSetup; //導入依賴的package包/類
public void testSetupErrorInTestSetup() {
WasRun test = new WasRun();
TestSetup wrapper = new TestSetup(test) {
@Override
public void setUp() {
fail();
}
};
TestResult result = new TestResult();
wrapper.run(result);
assertTrue(!test.fWasRun);
assertTrue(!result.wasSuccessful());
}