本文整理汇总了Java中org.junit.Test类的典型用法代码示例。如果您正苦于以下问题:Java Test类的具体用法?Java Test怎么用?Java Test使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Test类属于org.junit包,在下文中一共展示了Test类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createAlternateRowsDocument
import org.junit.Test; //导入依赖的package包/类
@Test
public void createAlternateRowsDocument() throws Exception {
final PDDocument document = new PDDocument();
final PDPage page = new PDPage(PDRectangle.A4);
page.setRotation(90);
document.addPage(page);
final PDPageContentStream contentStream = new PDPageContentStream(document, page);
// TODO replace deprecated method call
contentStream.concatenate2CTM(0, 1, -1, 0, page.getMediaBox().getWidth(), 0);
final float startY = page.getMediaBox().getWidth() - 30;
(new TableDrawer(contentStream, createAndGetTableWithAlternatingColors(), 30, startY)).draw();
contentStream.close();
document.save("target/alternateRows.pdf");
document.close();
}
示例2: importJobsTest
import org.junit.Test; //导入依赖的package包/类
@Test
public void importJobsTest() throws Exception {
List<AssetImportJob> importJobs = apiClient.getAssetImportApi().getAssetImportJobs();
assertNotNull(importJobs);
for (AssetImportJob job : importJobs) {
assertImportJobFields( job );
}
// Retreive asset import job by job id
if ( importJobs.size() > 0 ) {
AssetImportJob importJob = apiClient.getAssetImportApi().getAssetImportJob( importJobs.get( 0 ).getJobId() );
assertNotNull( importJob );
assertImportJobFields( importJob );
}
}
示例3: testFormFailsIfRequiredStringIsNotString
import org.junit.Test; //导入依赖的package包/类
@Test(expected = BadRequestException.class)
public void testFormFailsIfRequiredStringIsNotString() {
Builder<Map<String, Object>> builder = new Builder<>(emptyList());
Form<Map<String, Object>> form = builder.title(
__ -> "title"
).description(
__ -> "description"
).constructor(
HashMap::new
).addRequiredString(
"long1", (map, string) -> map.put("l1", string)
).build();
form.get(_body);
}
示例4: testCancel_BuyLimit_1_Failed_for_PriceNotMatch
import org.junit.Test; //导入依赖的package包/类
@Test
public void testCancel_BuyLimit_1_Failed_for_PriceNotMatch() throws Exception {
// cancel:
sendOrders("100 cancel_buy_limit 003 2699.88");
// check ticks:
assertTicks();
// check order books:
assertOrderBook(
// seq type price amount
"001 sell 2703.33 4.4444", //
"006 sell 2702.22 3.3333", //
"002 sell 2702.22 2.2222", //
"004 sell 2701.11 1.1111", //
// -----------------------------------
"003 buy 2699.99 0.1111", //
"005 buy 2688.88 2.2222", //
"007 buy 2688.88 2.2222", //
"009 buy 2666.66 4.4444" //
);
}
示例5: manageDeletionProcess_VSERVERS_STOPPING_NextStatusNotNormal
import org.junit.Test; //导入依赖的package包/类
@Test
public void manageDeletionProcess_VSERVERS_STOPPING_NextStatusNotNormal()
throws Exception {
// given
doReturn(Boolean.TRUE).when(vSystemProcessor.vsysComm)
.getCombinedVServerState(paramHandler, VServerStatus.STOPPED);
doReturn(Boolean.FALSE).when(vSystemProcessor).checkNextStatus(
CONTROLLER_ID, INSTANCE_ID, FlowState.VSYSTEM_DELETING,
paramHandler);
// when
FlowState newState = vSystemProcessor.manageDeletionProcess(
CONTROLLER_ID, INSTANCE_ID, paramHandler,
FlowState.VSERVERS_STOPPING);
// then
assertNull(newState);
}
示例6: testFetchGenesOnRegion
import org.junit.Test; //导入依赖的package包/类
@Test
public void testFetchGenesOnRegion()
throws IOException, ExternalDbUnavailableException, InterruptedException {
// arrange
String fetchRes = readFile("ensembl_overlap_gene.json");
Mockito.when(
httpDataManager.fetchData(Mockito.any(), Mockito.any(ParameterNameValue[].class))
).thenReturn(fetchRes);
// act
List<EnsemblEntryVO> ensemblGeneList =
ensemblDataManager.fetchVariationsOnRegion("human", "140424943", "140624564", "7");
// assert
Assert.assertNotNull(ensemblGeneList);
Assert.assertEquals(6, ensemblGeneList.size());
EnsemblEntryVO ensemblEntryVO = ensemblGeneList.get(0);
Assert.assertNotNull(ensemblEntryVO);
Assert.assertTrue(ensemblEntryVO.getStart().equals(START_ENTRY));
Assert.assertTrue(ensemblEntryVO.getEnd().equals(END_ENTRY));
}
示例7: testConvertToIdsList
import org.junit.Test; //导入依赖的package包/类
@Test
public void testConvertToIdsList() {
// Test data
final SearchResponse searchResponse = createMock(SearchResponse.class);
final SearchHits searchHits = createMock(SearchHits.class);
final SearchHit searchHit1 = createMock(SearchHit.class);
final SearchHit searchHit2 = createMock(SearchHit.class);
final SearchHit[] searchHitsArray = new SearchHit[]{searchHit1, searchHit2};
final String searchHit1Id = "search hit 1 id";
final String searchHit2Id = "search hit 1 id";
// Reset
resetAll();
// Expectations
expect(searchResponse.getHits()).andReturn(searchHits);
expect(searchHits.getHits()).andReturn(searchHitsArray);
expect(searchHit1.getId()).andReturn(searchHit1Id);
expect(searchHit2.getId()).andReturn(searchHit2Id);
// Replay
replayAll();
// Run test scenario
final List<String> response = searchResponseComponent.convertToIdsList(searchResponse);
// Verify
verifyAll();
assertEquals(Arrays.asList(searchHit1Id, searchHit2Id), response);
}
示例8: testDiamondQueryWithTypes
import org.junit.Test; //导入依赖的package包/类
/**
* Tests the execution of a diamond query with types.
*/
@Test
public void testDiamondQueryWithTypes() throws Exception {
// Initialize the {@code TypeStore} with types used in the MATCH query.
TypeAndPropertyKeyStore.getInstance().mapStringTypeToShortOrInsert("FOLLOWS");
TypeAndPropertyKeyStore.getInstance().mapStringTypeToShortOrInsert("LIKES");
//Create a one time MATCH query plan for a simple diamond pattern with types.
StructuredQuery diamondStructuredQuery = new StructuredQueryParser().parse("MATCH (a)" +
"-[:FOLLOWS]->(b),(a)-[:FOLLOWS]->(c),(b)-[:LIKES]->(d),(c)-[:LIKES]->(d)");
Integer[][] expectedMotifsAfterAdditions = {{0, 1, 1, 0}, {0, 1, 1, 4}, {3, 0, 0, 1},
{3, 0, 4, 1}, {3, 4, 0, 1}, {3, 4, 4, 1}, {3, 4, 4, 3}, {4, 1, 1, 0}, {4, 1, 1, 4}};
Integer[][] expectedMotifsAfterDeletion = {{3, 0, 0, 1}, {3, 0, 4, 1}, {3, 4, 0, 1},
{3, 4, 4, 1}, {3, 4, 4, 3}, {4, 1, 1, 0}, {4, 1, 1, 4}};
String[] headers = {"a", "b", "c", "d"};
assertComplexMatchQueryOutput(diamondStructuredQuery, constructSubgraphsQueryResult(
expectedMotifsAfterAdditions, headers), constructSubgraphsQueryResult(
expectedMotifsAfterDeletion, headers));
}
示例9: testClose
import org.junit.Test; //导入依赖的package包/类
@Test
public void testClose() {
// create dynamic routing
DynamicRoutingManager dynamicRoutingManager = new DynamicRoutingManager(
"NAME",
"GROUP",
PropertyFactory.PREFIX,
properties
);
// close connection
dynamicRoutingManager.close();
// verify all close methods have been called
verify(publicationObserver, times(1)).close();
verify(subscriptionObserver, times(1)).close();
verify(dynamicPartitionObserver, times(1)).close();
verify(dynamicPartitionCommander, times(1)).close();
verify(domainParticipantAdministration, times(1)).delete_contained_entities();
verify(domainParticipantFactory, times(1)).delete_participant(domainParticipantAdministration);
verify(domainParticipantDiscovery, times(1)).delete_contained_entities();
verify(domainParticipantFactory, times(1)).delete_participant(domainParticipantDiscovery);
}
示例10: testLosingFileAfterScannerInit
import org.junit.Test; //导入依赖的package包/类
@Test(timeout=180000)
public void testLosingFileAfterScannerInit() throws Exception {
assertEquals(rowCount, fullScanAndCount(TEST_TABLE.getTableName()));
final FileSystem fs = getFileSystem();
final Path tmpStoreFilePath = new Path(UTIL.getDataTestDir(), "corruptedHFile");
// try to query with the missing file
int count = fullScanAndCount(TEST_TABLE.getTableName(), new ScanInjector() {
private boolean hasFile = true;
@Override
public void beforeScan(Table table, Scan scan) throws Exception {
// move the path away (now the region is corrupted)
if (hasFile) {
fs.copyToLocalFile(true, storeFiles.get(0), tmpStoreFilePath);
LOG.info("Move file to local");
evictHFileCache(storeFiles.get(0));
hasFile = false;
}
}
});
assertTrue("expected one file lost: rowCount=" + count + " lostRows=" + (NUM_ROWS - count),
count >= (NUM_ROWS - ROW_PER_FILE));
}
示例11: testListMemberWithNoCache
import org.junit.Test; //导入依赖的package包/类
/**
* Tests the execution of "list member" command, when no cache is created
*
* @throws IOException
* @throws ClassNotFoundException
*/
@Test
public void testListMemberWithNoCache() throws IOException, ClassNotFoundException {
final Host host = Host.getHost(0);
final VM[] servers = {host.getVM(0), host.getVM(1)};
final int openPorts[] = AvailablePortHelper.getRandomAvailableTCPPorts(1);
final File logFile = new File(getUniqueName() + "-locator" + openPorts[0] + ".log");
Locator locator = Locator.startLocator(openPorts[0], logFile);
try {
final Properties props = createProperties(host, openPorts[0]);
CommandProcessor commandProcessor = new CommandProcessor();
Result result =
commandProcessor.createCommandStatement(CliStrings.LIST_MEMBER, EMPTY_ENV).process();
getLogWriter().info("#SB" + getResultAsString(result));
assertEquals(true, result.getStatus().equals(Status.ERROR));
} finally {
locator.stop(); // fix for bug 46562
}
}
示例12: xirr_issue_from_node_js_version
import org.junit.Test; //导入依赖的package包/类
@Test
public void xirr_issue_from_node_js_version() {
double rate = new Xirr(
new Transaction(-10000, "2000-05-24"),
new Transaction(3027.25, "2000-06-05"),
new Transaction(630.68, "2001-04-09"),
new Transaction(2018.2, "2004-02-24"),
new Transaction(1513.62, "2005-03-18"),
new Transaction(1765.89, "2006-02-15"),
new Transaction(4036.33, "2007-01-10"),
new Transaction(4036.33, "2007-11-14"),
new Transaction(1513.62, "2008-12-17"),
new Transaction(1513.62, "2010-01-15"),
new Transaction(2018.16, "2011-01-14"),
new Transaction(1513.62, "2012-02-03"),
new Transaction(1009.08, "2013-01-18"),
new Transaction(1513.62, "2014-01-24"),
new Transaction(1513.62, "2015-01-30"),
new Transaction(1765.89, "2016-01-22"),
new Transaction(1765.89, "2017-01-20"),
new Transaction(22421.55, "2017-06-05")
).xirr();
assertEquals(0.2126861, rate, TOLERANCE);
}
示例13: testScoredSortedSetEntryRange
import org.junit.Test; //导入依赖的package包/类
@Test
public void testScoredSortedSetEntryRange() {
RScoredSortedSetReactive<String> set = redisson.<String>getScoredSortedSet("simple");
sync(set.add(0, "a"));
sync(set.add(1, "b"));
sync(set.add(2, "c"));
sync(set.add(3, "d"));
sync(set.add(4, "e"));
Collection<ScoredEntry<String>> r = sync(set.entryRange(1, true, 4, false, 1, 2));
ScoredEntry<String>[] a = r.toArray(new ScoredEntry[0]);
Assert.assertEquals(2d, a[0].getScore(), 0);
Assert.assertEquals(3d, a[1].getScore(), 0);
Assert.assertEquals("c", a[0].getValue());
Assert.assertEquals("d", a[1].getValue());
}
示例14: requestMaxStaleDirectiveWithNoValue
import org.junit.Test; //导入依赖的package包/类
@Test public void requestMaxStaleDirectiveWithNoValue() throws IOException {
// Add a stale response to the cache.
server.enqueue(new MockResponse()
.setBody("A")
.addHeader("Cache-Control: max-age=120")
.addHeader("Date: " + formatDate(-4, TimeUnit.MINUTES)));
server.enqueue(new MockResponse()
.setBody("B"));
assertEquals("A", readAscii(openConnection(server.url("/").url())));
// With max-stale, we'll return that stale response.
URLConnection maxStaleConnection = openConnection(server.url("/").url());
maxStaleConnection.setRequestProperty("Cache-Control", "max-stale");
assertEquals("A", readAscii(maxStaleConnection));
assertEquals("110 HttpURLConnection \"Response is stale\"",
maxStaleConnection.getHeaderField("Warning"));
}
示例15: testAddsBitmapsToBitmapPoolIfMemoryCacheIsFull
import org.junit.Test; //导入依赖的package包/类
@Test
public void testAddsBitmapsToBitmapPoolIfMemoryCacheIsFull() {
Bitmap bitmap = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
when(cache.getMaxSize()).thenReturn(0);
PreFillType size =
new PreFillType.Builder(bitmap.getWidth(), bitmap.getHeight()).setConfig(bitmap.getConfig())
.build();
Map<PreFillType, Integer> allocationOrder = new HashMap<>();
allocationOrder.put(size, 1);
getHandler(allocationOrder).run();
verify(cache, never()).put(any(Key.class), anyResource());
// TODO(b/20335397): This code was relying on Bitmap equality which Robolectric removed
// verify(pool).put(eq(bitmap));
// assertThat(addedBitmaps).containsExactly(bitmap);
}