本文整理匯總了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();
}
}
示例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"));
}
示例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);
}
示例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());
}
示例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);
}
}
示例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));
}
示例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"));
}
示例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"));
}
示例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());
}
示例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")));
}
示例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);
}
示例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\"]"));
}
示例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(",."));
}
示例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"));
}
示例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());
}