当前位置: 首页>>代码示例>>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;未经允许,请勿转载。