本文整理汇总了Java中org.junit.Assert类的典型用法代码示例。如果您正苦于以下问题:Java Assert类的具体用法?Java Assert怎么用?Java Assert使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Assert类属于org.junit包,在下文中一共展示了Assert类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testPessimisticProvidePostResolveFailure
import org.junit.Assert; //导入依赖的package包/类
/**
* Test the completion and callback invocation of {@link RedFutureHub}
* pessimistic union of provided futures that later were failed
*/
@Test
public void testPessimisticProvidePostResolveFailure() throws Throwable {
AtomicBoolean reachedSuccessBlock = new AtomicBoolean(false);
AtomicBoolean reachedFailureBlock = new AtomicBoolean(false);
AtomicBoolean reachedFinallyBlock = new AtomicBoolean(false);
RedFutureHub hub = RedFuture.hub();
OpenRedFuture future1 = hub.provideFuture();
OpenRedFuture future2 = hub.provideFuture();
OpenRedFutureOf<Object> futureOf = hub.provideFutureOf();
RedFuture union = hub.unitePessimistically();
union.addSuccessCallback(() -> reachedSuccessBlock.set(true));
union.addFailureCallback(throwable -> reachedFailureBlock.set(true));
union.addFinallyCallback(() -> reachedFinallyBlock.set(true));
Assert.assertFalse(reachedFinallyBlock.get());
Assert.assertFalse(reachedSuccessBlock.get());
Assert.assertFalse(reachedFailureBlock.get());
future1.resolve();
future2.fail(new TestException());
futureOf.resolve(new Object());
Assert.assertTrue(reachedFinallyBlock.get());
Assert.assertTrue(reachedSuccessBlock.get());
Assert.assertFalse(reachedFailureBlock.get());
}
示例2: testDeleteAllWithError
import org.junit.Assert; //导入依赖的package包/类
@Test
public void testDeleteAllWithError(){
testStore.shouldThrowError(true);
models.clear();
List<TestModel> list = new ArrayList<>();
list.add(new TestModel(1));
list.add(new TestModel(2));
list.add(new TestModel(3));
memoryStore.insertOrUpdate(list);
TestSubscriber<Integer> observer = new TestSubscriber<>();
disposables.add(testStore.deleteAll()
.subscribeOn(Schedulers.io())
.subscribeWith(observer));
observer.awaitTerminalEvent(5, SECONDS);
observer.assertError(Throwable.class);
observer.assertErrorMessage("deleteAll.error");
testStore.shouldThrowError(false); // disable error
Assert.assertEquals(3, models.size());
}
示例3: xmlDeveSerGeradoCorretamente
import org.junit.Assert; //导入依赖的package包/类
@Test
public void xmlDeveSerGeradoCorretamente() throws IOException{
String xmlTest = IOUtils.toString(getClass().getClassLoader().getResourceAsStream("loteRpsConsultaSituacao.xml"));
LoteRpsConsultaSituacao consultaSituacaoLote = new LoteRpsConsultaSituacao("AP1057893n16X103sfhF4RPm", FabricaDeObjetosFake.getRpsPrestador());
String xml = consultaSituacaoLote.converterParaXml();
Assert.assertEquals(xml, xmlTest);
}
示例4: testNullSeen
import org.junit.Assert; //导入依赖的package包/类
private void testNullSeen(String snippet) {
ProfilingInfo info = profile(snippet, 1);
Assert.assertEquals(TriState.FALSE, info.getNullSeen(1));
continueProfiling(snippet, "ABC");
Assert.assertEquals(TriState.FALSE, info.getNullSeen(1));
continueProfiling(snippet, new Object());
Assert.assertEquals(TriState.FALSE, info.getNullSeen(1));
if (TriState.TRUE == info.getNullSeen(1)) {
// See the javadoc comment for ProfilingInfoTest.
continueProfiling(snippet, (Object) null);
Assert.assertEquals(TriState.TRUE, info.getNullSeen(1));
continueProfiling(snippet, 0.0);
Assert.assertEquals(TriState.TRUE, info.getNullSeen(1));
continueProfiling(snippet, new Object());
Assert.assertEquals(TriState.TRUE, info.getNullSeen(1));
}
resetProfile(snippet);
Assert.assertEquals(TriState.FALSE, info.getNullSeen(1));
}
示例5: restoreState
import org.junit.Assert; //导入依赖的package包/类
@Override
public void restoreState(List<Tuple2<Integer, BitSet>> state) throws Exception {
if (state.isEmpty()) {
Assert.fail("Function was restored without state - no checkpoint completed before.");
}
if (state.size() > 1) {
Assert.fail("Function was restored with multiple states. unexpected scale-in");
}
Tuple2<Integer, BitSet> s = state.get(0);
this.numElementsSoFar = s.f0;
this.duplicateChecker.clear();
this.duplicateChecker.or(s.f1);
log.debug("IntSequenceExactlyOnceValidator was restored with {} elements", numElementsSoFar);
}
示例6: testContains
import org.junit.Assert; //导入依赖的package包/类
@Test
public void testContains() throws InterruptedException {
RSetCache<TestObject> set = redisson.getSetCache("set");
set.add(new TestObject("1", "2"));
set.add(new TestObject("1", "2"));
set.add(new TestObject("2", "3"), 1, TimeUnit.SECONDS);
set.add(new TestObject("3", "4"));
set.add(new TestObject("5", "6"));
Thread.sleep(1000);
Assert.assertFalse(set.contains(new TestObject("2", "3")));
Assert.assertTrue(set.contains(new TestObject("1", "2")));
Assert.assertFalse(set.contains(new TestObject("1", "9")));
}
示例7: testItem_0172
import org.junit.Assert; //导入依赖的package包/类
public void testItem_0172()
{
boolean caught;
caught = false;
try {
rc_BigDecimal = new BigDecimal(new char[]{'8', '\1', '\1', '\uFFFF', '8', '8', '\uFFFF', '\uFFFF', '8', '\uFFFF', '\234', '8', '8', '\234', '8', '\234', '\0', '\uFFFF', '\234', '\1', '\1', '\uFFFF', '\1', '8', '\uFFFF', '\uFFFF', '\1', '\234', '8', '8', '\1', '\1', '\234', '\0', '\1', '\uFFFF', '\0', '\uFFFF', '\0', '\234', '\uFFFF', '\uFFFF', '\234', '\234', '\1', '8', '\234', '\uFFFF', '8', '8', '\234', '\1', '\1', '8', '\0', '8', '\1', '\uFFFF', '\uFFFF', '\234', '\uFFFF', '\234', '\1', '\234', '\1', '\0', '\234', '\1', '\234', '\234', '\1', '\1', '\1', '\1', '8', '\0', '\uFFFF', '\1', '\234', '8', '\234', '\1', '\uFFFF', '\0', '8', '\234', '8', '\1', '\234', '\0', '\uFFFF', '8', '\0', '\0', '\0', '8', '8', '\1', '\234', '8'}, new MathContext("precision=2147483647 roundingMode=HALF_EVEN"));
}
catch (java.lang.NumberFormatException e) {
caught = true;
}
Assert.assertEquals("91.94630872483222%", true, caught);
}
示例8: testItem_0251
import org.junit.Assert; //导入依赖的package包/类
public void testItem_0251()
{
boolean caught;
caught = false;
try {
rc_BigDecimal = (new BigDecimal("-9000000000000.0")).pow(-1, new MathContext("precision=0 roundingMode=HALF_EVEN"));
}
catch (java.lang.ArithmeticException e) {
caught = true;
}
Assert.assertEquals("91.94630872483222%", true, caught);
}
示例9: testItem_0432
import org.junit.Assert; //导入依赖的package包/类
public void testItem_0432()
{
boolean caught;
caught = false;
try {
rc_BigDecimal = (new BigDecimal("0")).setScale(0, 2147483647);
}
catch (java.lang.IllegalArgumentException e) {
caught = true;
}
Assert.assertEquals("91.94630872483222%", true, caught);
}
示例10: test122
import org.junit.Assert; //导入依赖的package包/类
@Test
public void test122() throws Throwable {
if (debug)
System.out.format("%n%s%n", "RegressionTest0.test122");
Table table2 = new Table("", ",");
List<String> list_str3 = table2.getTokenizedLowerCaseTrimmedName();
DatabaseMetaData databaseMetaData4 = null;
try {
table2.getPrimaryKeys(databaseMetaData4, ",", "", ",");
Assert.fail("Expected exception of type java.lang.NullPointerException");
} catch (NullPointerException e) {
}
Assert.assertNull(list_str3);
}
示例11: testItem_0623
import org.junit.Assert; //导入依赖的package包/类
public void testItem_0623()
{
boolean caught;
caught = false;
try {
rc_BigDecimal = new BigDecimal("@W0Y<7W?8EY16NT;[email protected]@UQH5R?<3?LNRD<EH1OJ=XW:MTM9F5WV34");
}
catch (java.lang.NumberFormatException e) {
caught = true;
}
Assert.assertEquals("91.94630872483222%", true, caught);
}
示例12: test_cast_to_SqlDate_sql_Date
import org.junit.Assert; //导入依赖的package包/类
public void test_cast_to_SqlDate_sql_Date() throws Exception {
long millis = System.currentTimeMillis();
JSONObject json = new JSONObject();
json.put("date", new java.sql.Date(millis));
Assert.assertEquals(new java.sql.Date(millis), json.getObject("date", java.sql.Date.class));
}
示例13: test007
import org.junit.Assert; //导入依赖的package包/类
@Test
public void test007() throws Throwable {
if (debug)
System.out.format("%n%s%n", "RegressionTest0.test007");
Relationship relationship0 = new Relationship();
Column column1 = relationship0.getPk();
Chen chen2 = null;
try {
relationship0.setMediumFeatures(chen2);
Assert.fail("Expected exception of type java.lang.NullPointerException");
} catch (NullPointerException e) {
}
Assert.assertNull(column1);
}
示例14: testEqual5
import org.junit.Assert; //导入依赖的package包/类
@Test
public void testEqual5() throws Exception {
ValidationException.ExceptionMessageWithStackTrace exp = new ValidationException.ExceptionMessageWithStackTrace(
null, "string2");
ValidationException.ExceptionMessageWithStackTrace exp2 =
new ValidationException.ExceptionMessageWithStackTrace(
"string1", "string2");
Assert.assertNotEquals(exp, exp2);
}
示例15: should_get_job_zip_success
import org.junit.Assert; //导入依赖的package包/类
@Test
public void should_get_job_zip_success() throws Exception {
stubDemo();
Node rootForFlow = createRootFlow("flow1", "yml/flow.yaml");
Job job = jobService.createFromFlowYml(rootForFlow.getPath(), JobCategory.TAG, null, mockUser);
job.putEnv(GitEnvs.FLOW_GIT_BRANCH, "master");
job.setStatus(JobStatus.SUCCESS);
jobDao.update(job);
List<NodeResult> nodeResultList = nodeResultService.list(job, true);
for (NodeResult nodeResult : nodeResultList) {
nodeResult.setCmdId("xxxx");
nodeResultService.update(nodeResult);
}
MvcResult mvcResult = this.mockMvc.perform(
get(String.format("/jobs/%s/%s/log/download", job.getNodeName(), job.getNumber()))
).andExpect(status().isOk()).andReturn();
String response = mvcResult.getResponse().getContentAsString();
Assert.assertNotNull(response);
Path zipLog = Paths
.get(workspace.toString(), job.getNodeName(), "log", job.getId().toString(),
job.getId().toString() + ".zip");
File zipFile = new File(zipLog.toString());
Assert.assertEquals(true, zipFile.exists());
}