当前位置: 首页>>代码示例>>Java>>正文


Java Test类代码示例

本文整理汇总了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();
}
 
开发者ID:vandeseer,项目名称:easytable,代码行数:18,代码来源:TableDrawerIntegrationTest.java

示例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 );
    }
}
 
开发者ID:tenable,项目名称:Tenable.io-SDK-for-Java,代码行数:18,代码来源:AssetImportApiClientTest.java

示例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);
}
 
开发者ID:liferay,项目名称:com-liferay-apio-architect,代码行数:17,代码来源:FormTest.java

示例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" //
	);
}
 
开发者ID:michaelliao,项目名称:cryptoexchange,代码行数:21,代码来源:MatchService_CancelBuyLimitTest.java

示例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);
}
 
开发者ID:servicecatalog,项目名称:oscm-app,代码行数:19,代码来源:VSystemProcessorBeanTest.java

示例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));
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:25,代码来源:EnsemblDataManagerTest.java

示例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);
}
 
开发者ID:Biacode,项目名称:escommons,代码行数:26,代码来源:SearchResponseComponentImplTest.java

示例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));
}
 
开发者ID:graphflow,项目名称:graphflow,代码行数:21,代码来源:GenericJoinExecutorTest.java

示例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);
}
 
开发者ID:aguther,项目名称:dds-examples,代码行数:24,代码来源:DynamicRoutingManagerTest.java

示例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));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:26,代码来源:TestCorruptedRegionStoreFile.java

示例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
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:28,代码来源:MemberCommandsDUnitTest.java

示例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);
}
 
开发者ID:RayDeCampo,项目名称:java-xirr,代码行数:25,代码来源:XirrTest.java

示例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());
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:18,代码来源:RedissonScoredSortedSetReactiveTest.java

示例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"));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:ResponseCacheTest.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:BitmapPreFillRunnerTest.java


注:本文中的org.junit.Test类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。