當前位置: 首頁>>代碼示例>>Java>>正文


Java Assert.assertTrue方法代碼示例

本文整理匯總了Java中org.junit.Assert.assertTrue方法的典型用法代碼示例。如果您正苦於以下問題:Java Assert.assertTrue方法的具體用法?Java Assert.assertTrue怎麽用?Java Assert.assertTrue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.junit.Assert的用法示例。


在下文中一共展示了Assert.assertTrue方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: compareOutputJNetPcapMetal

import org.junit.Assert; //導入方法依賴的package包/類
@Ignore("This interface does not exist anymore")
@Test
public void compareOutputJNetPcapMetal() throws IOException{
    // Create a dumper using both the libraries. Wrapper around the others.
    final String[] cmd = String.format("-4 30313233343536373839414243444546 /16 test -c all %s",
        Paths.get(".").toAbsolutePath().normalize().toString()).split(" ");
    LiveCapture.main(cmd);
    final File metalFile = new File("metal-test.pcap");
    final File jnetpcapFile = new File("jnetpcap-test.pcap");
    //There is not test for comparing with the reference file because if no DNS was found
    // no packets have been modified.
    final File referenceFile = new File("reference");

    Assert.assertTrue("The files should be identical!", FileUtils.contentEquals(metalFile, jnetpcapFile));

    // Temporary cleanup.
    if (metalFile.exists()) {
        metalFile.delete();
    }
    if (jnetpcapFile.exists()) {
        jnetpcapFile.delete();
    }
    if (referenceFile.exists()) {
        referenceFile.delete();
    }
}
 
開發者ID:NCSC-NL,項目名稱:PEF,代碼行數:27,代碼來源:LiveCaptureTest.java

示例2: testWithTags

import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void testWithTags() {
    Span child = tracer.buildSpan("child")
        .withTag("string-key", "string-value")
        .withTag("boolean-key", false)
        .withTag("number-key", 1l)
        .startManual();

    Map<String, ?> tags = child.getTags();

    Assert.assertEquals(3, tags.size());
    Assert.assertTrue(tags.containsKey("string-key"));
    Assert.assertEquals("string-value", tags.get("string-key"));
    Assert.assertTrue(tags.containsKey("boolean-key"));
    Assert.assertEquals(false, tags.get("boolean-key"));
    Assert.assertTrue(tags.containsKey("number-key"));
    Assert.assertEquals(1l, tags.get("number-key"));
}
 
開發者ID:ExpediaDotCom,項目名稱:haystack-client-java,代碼行數:19,代碼來源:SpanBuilderTest.java

示例3: testAnonymous_VERBOSE_IllegelPort

import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void testAnonymous_VERBOSE_IllegelPort() {
  try {
    when(mockFTPClient.login("anonymous", "")).thenReturn(true);
    when(mockFTPClient.logout()).thenReturn(true);
    when(mockFTPClient.isConnected()).thenReturn(false);
    when(mockFTPClient.getReplyCode()).thenReturn(200);
  } catch (IOException e) {
    fail("No IOException should be thrown!");
  }

  conf.set(DBConfiguration.URL_PROPERTY, "localhost:testPort");
  conf.setBoolean(JobBase.PROPERTY_VERBOSE, true);

  FTPClient ftp = null;
  boolean success = false;
  try {
    ftp = MainframeFTPClientUtils.getFTPConnection(conf);
  } catch (IOException ioe) {
    fail("No IOException should be thrown!");
  } finally {
    success = MainframeFTPClientUtils.closeFTPConnection(ftp);
  }
  Assert.assertTrue(success);
}
 
開發者ID:aliyun,項目名稱:aliyun-maxcompute-data-collectors,代碼行數:26,代碼來源:TestMainframeFTPClientUtils.java

示例4: testHangReportNotSuppressedOnLongRunningFutureCompleted

import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void testHangReportNotSuppressedOnLongRunningFutureCompleted() {
	getFactory().setHangDetectionTimeout(Duration.ofMillis(10));
	AtomicBoolean hangReported = new AtomicBoolean(false);
	getContext().onReportHang = (hangDuration, iterations, id) -> hangReported.set(true);

	JoinableFuture<Void> task = getFactory().runAsync(
		() -> Async.awaitAsync(Async.delayAsync(Duration.ofMillis(30))),
		EnumSet.of(JoinableFutureCreationOption.LONG_RUNNING));

	task.join();
	Assert.assertFalse(hangReported.get());

	JoinableFutureCollection taskCollection = new JoinableFutureCollection(getFactory().getContext());
	taskCollection.add(task);

	getFactory().run(() -> Async.usingAsync(
		taskCollection.join(),
		tempJoin -> Async.awaitAsync(Async.delayAsync(Duration.ofMillis(30)))));

	Assert.assertTrue(hangReported.get());
}
 
開發者ID:tunnelvisionlabs,項目名稱:java-threading,代碼行數:23,代碼來源:JoinableFutureContextTest.java

示例5: testAzureOcrSearchReturnNotNull

import org.junit.Assert; //導入方法依賴的package包/類
public void testAzureOcrSearchReturnNotNull() {
    try {
        URL url = new URL("https://i.ytimg.com/vi/0E4PWHTS4BA/hqdefault.jpg");
        String key = System.getenv("AZURE_KEY");
        IAzureOcrResult res = OpticalCharacterRecognitionSearch
                .getAzureServices(key)
                .imageSearchBuildQuery()
                .setImage(url)
                .build()
                .search();
        org.junit.Assert.assertNotNull(res);
    } catch (Exception e) {
        e.printStackTrace();
        Assert.assertTrue(false);
    }
}
 
開發者ID:Augugrumi,項目名稱:libris,代碼行數:17,代碼來源:OpticalCharacterRecognitionSearchTest.java

示例6: testHeadMap

import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void testHeadMap() throws Exception {
    for (int i = 0; i < 100; i++) {
        map.put(i, String.valueOf(i));
    }
    SortedMap<Integer, String> headMap = map.headMap(74);
    Assert.assertEquals(74, headMap.size());
    for (int i = 0; i < 74; i++) {
        Assert.assertTrue(headMap.containsKey(i));
    }
    Assert.assertFalse(headMap.containsKey(74));

    SortedMap<Integer, String> headHeadMap = headMap.headMap(53);
    Assert.assertEquals(53, headHeadMap.size());
    for (int i = 0; i < 53; i++) {
        Assert.assertTrue(headHeadMap.containsKey(i));
    }
    Assert.assertFalse(headHeadMap.containsKey(53));

}
 
開發者ID:MottoX,項目名稱:SkipList,代碼行數:21,代碼來源:SkipListMapTest.java

示例7: testInternalRename2

import org.junit.Assert; //導入方法依賴的package包/類
@Test(expected=AccessControlException.class) 
public void testInternalRename2() throws IOException {
  Assert.assertTrue("linkTODir2 should be a dir", 
      fcView.getFileStatus(new Path("/internalDir/linkToDir2")).isDirectory());
  fcView.rename(new Path("/internalDir/linkToDir2"),
      new Path("/internalDir/dir1"));
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:8,代碼來源:ViewFsBaseTest.java

示例8: testGetPath1

import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void testGetPath1() {
    Config.setContextPath4Test("/appName");

    System.out.println(PathUtil.getPath(""));

    Assert.assertTrue(PathUtil.getPath("").equals(
            Config.getContextPath() + "/"));
    Assert.assertTrue(PathUtil.getPath("/").equals(
            Config.getContextPath() + "/"));
    Assert.assertTrue(PathUtil.getPath("index").equals(
            Config.getContextPath() + "/index"));
    Assert.assertTrue(PathUtil.getPath("/index").equals(
            Config.getContextPath() + "/index"));
}
 
開發者ID:wittyLuzhishen,項目名稱:EasyPackage,代碼行數:16,代碼來源:PathUtilTest.java

示例9: testGetValue03

import org.junit.Assert; //導入方法依賴的package包/類
/**
 * Tests that a valid property is resolved.
 */
@Test
public void testGetValue03() {
    ListELResolver resolver = new ListELResolver();
    ELContext context = new ELContextImpl();

    List<String> list = new ArrayList<String>();
    list.add("key");
    Object result = resolver.getValue(context, list, new Integer(0));

    Assert.assertEquals("key", result);
    Assert.assertTrue(context.isPropertyResolved());
}
 
開發者ID:sunmingshuai,項目名稱:apache-tomcat-7.0.73-with-comment,代碼行數:16,代碼來源:TestListELResolver.java

示例10: test40_startContainerWithPorts

import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void test40_startContainerWithPorts() throws DockerJSONException {
    container = ContainerUtils.newStartInstance(container.getName(), null, null, false);
    dockerCloudUnitClient.startContainer(container);
    Assert.assertTrue((dockerCloudUnitClient.findContainer(container).getNetworkSettings().getPorts().toString()
            .contains("22")));

}
 
開發者ID:oncecloud,項目名稱:devops-cstack,代碼行數:9,代碼來源:ContainerCommandTests.java

示例11: testEncodeRequest

import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void testEncodeRequest() {
  boolean status = true;
  try {
    commonMock();
    TcpOutputStream os = HighwayCodec.encodeRequest(0, invocation, operationProtobuf, null);
    Assert.assertNotNull(os);
    Assert.assertArrayEquals(TcpParser.TCP_MAGIC, os.getBuffer().getBytes(0, 7));
  } catch (Exception e) {
    status = false;
  }
  Assert.assertTrue(status);
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:14,代碼來源:TestHighwayCodec.java

示例12: test_getKeys

import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void test_getKeys() {
	Set<String> sets = new HashSet<String>();

	sets.clear();
	Configuration configuration = Configuration.from("{}");
	System.out.println(JSON.toJSONString(configuration.getKeys()));
	Assert.assertTrue(configuration.getKeys().isEmpty());

	sets.clear();
	configuration = Configuration.from("[]");
	System.out.println(JSON.toJSONString(configuration.getKeys()));
	Assert.assertTrue(configuration.getKeys().isEmpty());

	sets.clear();
	configuration = Configuration.from("[0]");
	System.out.println(JSON.toJSONString(configuration.getKeys()));
	Assert.assertTrue(configuration.getKeys().contains("[0]"));

	sets.clear();
	configuration = Configuration.from("[1,2]");
	System.out.println(JSON.toJSONString(configuration.getKeys()));
	Assert.assertTrue(configuration.getKeys().contains("[0]"));
	Assert.assertTrue(configuration.getKeys().contains("[1]"));

	sets.clear();
	configuration = Configuration.from("[[[0]]]");
	System.out.println(JSON.toJSONString(configuration.getKeys()));
	Assert.assertTrue(configuration.getKeys().contains("[0][0][0]"));

	sets.clear();
	configuration = Configuration
			.from("{\"a\":{\"b\":{\"c\":[0],\"B\": \"B\"},\"A\": \"A\"}}");
	System.out.println(JSON.toJSONString(configuration.getKeys()));
	Assert.assertTrue(JSON.toJSONString(configuration.getKeys()).equals(
			"[\"a.b.B\",\"a.b.c[0]\",\"a.A\"]"));
}
 
開發者ID:yaogdu,項目名稱:datax,代碼行數:38,代碼來源:ConfigurationTest.java

示例13: test327

import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void test327() throws Throwable {
    if (debug)
        System.out.format("%n%s%n", "RegressionTest0.test327");
    Column column2 = new Column(",", "");
    column2.setEstimatedRowCount((int) (byte) 0);
    column2.setPrimaryKey(true);
    column2.setKeywordSingleton();
    String str8 = column2.getDataTypeName();
    String str9 = column2.getLongName();
    Assert.assertNull(str8);
    Assert.assertTrue("'" + str9 + "' != '" + ",." + "'", str9.equals(",."));
}
 
開發者ID:janmotl,項目名稱:linkifier,代碼行數:14,代碼來源:RegressionTest.java

示例14: getPublicRooms

import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void getPublicRooms() throws IOException {

	// Collect rooms
	Map rooms = client.getPublicRooms("test");

	// Make sure they were collected properly
	Assert.assertTrue(rooms.size() == 2);
	Assert.assertNotNull(rooms.get("ID1"));
	Assert.assertNotNull(rooms.get("ID2"));
}
 
開發者ID:Gurgy,項目名稱:Cypher,代碼行數:12,代碼來源:ClientTest.java

示例15: testGetPattern

import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void testGetPattern() {
	WebviewIndexSwitcher<?> s = new WebviewIndexSwitcher<>(getBasicContextSwitcher(0));
	Pattern p = s.getPattern();
	Assert.assertNotNull(p);
	Assert.assertTrue(p.matcher("WEBVIEW[1]").matches());
	Assert.assertTrue(p.matcher("WEBVIEW[-1]").matches());
	Assert.assertFalse(p.matcher("WEBVIEW[]").matches());
}
 
開發者ID:xinufo,項目名稱:teemo,代碼行數:10,代碼來源:WebviewIndexSwitcherTest.java


注:本文中的org.junit.Assert.assertTrue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。