Java 类org.junit.Assert 实例源码

项目:java-red    文件:TestRedFuture.java   
/**
 * 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());
}
项目:store2store    文件:StoreServiceUnitTest.java   
@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());
}
项目:openjdk-jdk10    文件:ProfilingInfoTest.java   
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));
}
项目:flink-connectors    文件:IntSequenceExactlyOnceValidator.java   
@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);
}
项目:JRediClients    文件:RedissonSetCacheTest.java   
@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")));
}
项目:openjdk-systemtest    文件:TestSuite042.java   
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);
}
项目:openjdk-systemtest    文件:TestSuite054.java   
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);
}
项目:openjdk-systemtest    文件:TestSuite037.java   
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);
}
项目:linkifier    文件:RegressionTest.java   
@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);
}
项目:GitHub    文件:TypeUtilsTest.java   
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));
}
项目:linkifier    文件:RegressionTest.java   
@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);
}
项目:hashsdn-controller    文件:ValidationExceptionTest.java   
@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);
}
项目:flow-platform    文件:JobControllerTest.java   
@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());
}
项目:openjdk-systemtest    文件:TestSuite040.java   
public void testItem_0045()
{
  boolean caught;
  caught = false;
  try {
    rc_BigDecimal = new BigDecimal(new char[]{'\1', '\234', '\uFFFF', '\0', '\1', '8', '\uFFFF', '\uFFFF'}, new MathContext("precision=1 roundingMode=HALF_UP"));
  }
  catch (java.lang.NumberFormatException e) {
    caught = true;
  }
  Assert.assertEquals("91.94630872483222%", true, caught);
}
项目:GitHub    文件:JSONSerializerTest.java   
public void test_3_s() throws Exception {
    JSONSerializer serializer = new JSONSerializer();
    serializer.write(new JSONAware() {

        public String toJSONString() {
            return "null";
        }
    });

    Assert.assertEquals("null", serializer.getWriter().toString());
}
项目:openjdk-systemtest    文件:TestSuite011.java   
public void testItem_0697()
{
  boolean caught;
  caught = false;
  try {
    rc_MathContext = new MathContext("S5:FS:9C;4BQIG?=1VYKGM=<=<R;RBS3O8IHYARO1ST2SHL;6L;S5312X;O4:9:FOMG<DOTQT?6X5NE1T6OB3VCGIQ04J4M4812?");
  }
  catch (java.lang.IllegalArgumentException e) {
    caught = true;
  }
  Assert.assertEquals("91.61073825503355%", true, caught);
}
项目:linkifier    文件:RegressionTest.java   
@Test
public void test324() throws Throwable {
    if (debug)
        System.out.format("%n%s%n", "RegressionTest0.test324");
    Relationship relationship0 = new Relationship();
    Column column1 = relationship0.getPk();
    String str2 = relationship0.getSchema();
    Boolean b3 = relationship0.getDataTypeCategoryAgree();
    Column column6 = new Column(",", "");
    column6.setEstimatedRowCount((int) (byte) 0);
    Boolean b9 = column6.isBestAttemptPk();
    relationship0.setPk(column6);
    Boolean b11 = column6.isBestAttemptPk();
    Table[] table_array12 = new Table[] {};
    ArrayList<Table> arraylist_table13 = new ArrayList<Table>();
    boolean b14 = Collections.addAll(arraylist_table13, table_array12);
    List<Table> list_table15 = Optimization.optimize(arraylist_table13);
    column6.setMinLDOtherTable(arraylist_table13);
    column6.setKeywords();
    column6.setDecimalDigits((int) 'a');
    column6.setUniqueConstraint(true);
    Integer i22 = column6.getLD();
    Assert.assertNull(column1);
    Assert.assertNull(str2);
    Assert.assertNull(b3);
    Assert.assertTrue("'" + b9 + "' != '" + false + "'", b9.equals(false));
    Assert.assertTrue("'" + b11 + "' != '" + false + "'", b11.equals(false));
    Assert.assertNotNull(table_array12);
    Assert.assertTrue(b14 == false);
    Assert.assertNotNull(list_table15);
    Assert.assertNull(i22);
}
项目:openjdk-systemtest    文件:TestSuite032.java   
public void testItem_0411()
{
  boolean caught;
  caught = false;
  try {
    rc_int = (new BigDecimal("320.0E+2147483647")).intValueExact();
  }
  catch (java.lang.ArithmeticException e) {
    caught = true;
  }
  Assert.assertEquals("91.94630872483222%", true, caught);
}
项目:incubator-servicecomb-java-chassis    文件:TestConfigCenterConfigurationSource.java   
@Test
public void testCreate() throws Exception {

  ConfigCenterConfigurationSourceImpl configCenterSource = new ConfigCenterConfigurationSourceImpl();
  configCenterSource.addUpdateListener(new WatchedUpdateListener() {
    @Override
    public void updateConfiguration(WatchedUpdateResult result) {
      Assert.assertTrue(!result.getAdded().isEmpty());
    }
  });
  UpdateHandler udateHandler = Deencapsulation.getField(configCenterSource, UpdateHandler.class);
  Map<String, Object> addedItems = new HashMap<>();
  addedItems.put("testKey", "testValue");
  udateHandler.handle("create", addedItems);
}
项目:mycat-src-1.6.1-RELEASE    文件:ServerParserTest.java   
@Test
public void testIsSelectVersionComment() {
    Assert.assertEquals(ServerParseSelect.VERSION_COMMENT,
            ServerParseSelect.parse(" select @@version_comment  ", 7));
    Assert.assertEquals(ServerParseSelect.VERSION_COMMENT, ServerParseSelect.parse("SELECT @@VERSION_COMMENT", 6));
    Assert.assertEquals(ServerParseSelect.VERSION_COMMENT,
            ServerParseSelect.parse(" selECT    @@VERSION_comment  ", 7));
}
项目:nfse    文件:LoteRpsConsultaSituacaoTest.java   
@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);
}
项目:simm-lib    文件:BigDecimalUtilsTest.java   
@Test
public void sumInStream() {
  List<BigDecimal> list = Arrays.asList(new BigDecimal("1"), new BigDecimal("3"));
  Assert.assertEquals(new BigDecimal("4"), list.stream().reduce(BigDecimalUtils::sum).get());

  List<BigDecimal> list2 = Arrays.asList(new BigDecimal("1"), new BigDecimal("3"), new BigDecimal("5"));
  Assert.assertEquals(new BigDecimal("9"), list2.parallelStream().reduce(BigDecimalUtils::sum).get());
}
项目:coffee-gb    文件:LfsrTest.java   
@Test
public void testLfsrWidth7() {
    Lfsr lfsr = new Lfsr();
    int previousValue = 0;
    for (int i = 0; i < 100; i++) {
        lfsr.nextBit(true);
        Assert.assertNotEquals(previousValue, lfsr.getValue());
        previousValue = lfsr.getValue();
    }
}
项目:GitHub    文件:NativePooledByteBufferFactoryTest.java   
private void assertArrayEquals(byte[] expected, byte[] actual, int length) {
  Assert.assertTrue(expected.length >= length);
  Assert.assertTrue(actual.length >= length);
  for (int i = 0; i < length; i++) {
    Assert.assertEquals(expected[i], actual[i], i);
  }
}
项目:angel    文件:UpdateFuncTest.java   
@Test
public void testMulS() throws Exception {
  UpdateFunc func = new MulS(w2Client.getMatrixId(), 0, 3, -1.0);
  w2Client.update(func).get();

  double[] addResult = pull(w2Client, 3);
  assert(addResult.length == dim);
  for (int i = 0; i < addResult.length; i++) {
    Assert.assertEquals(addResult[i], localArray0[i] * -1.0, delta);
  }
}
项目:BachelorPraktikum    文件:SonySWR21ImporterTest.java   
/**
 * Test to see whether the plugin can be loaded.
 */
@Test
public void pluginLoad() {
    PluginManager manager = new DefaultPluginManager(Paths.get("export"));
    manager.loadPlugins();
    Assert.assertTrue(0 != manager.getPlugins().size());
}
项目:incubator-servicecomb-java-chassis    文件:TestPartToMultipartFile.java   
@Test
public void isEmptyTrue() {
  new Expectations() {
    {
      part.getSize();
      result = 0;
    }
  };

  Assert.assertTrue(multipartFile.isEmpty());
}
项目:autorest.java    文件:HttpRedirectsTests.java   
@Test
@Ignore("Not supported yet")
public void put301() throws Exception {
    client.httpRedirects().put301WithServiceResponseAsync()
        .subscribe(new Action1<ServiceResponseWithHeaders<Void, HttpRedirectsPut301Headers>>() {
            @Override
            public void call(ServiceResponseWithHeaders<Void, HttpRedirectsPut301Headers> response) {
                Assert.assertEquals(301, response.response().code());
                lock.countDown();
            }
        });
    Assert.assertTrue(lock.await(1000, TimeUnit.MILLISECONDS));
}
项目:incubator-servicecomb-java-chassis    文件:TestProducerSchemaFactory.java   
@Test
public void testGetOrCreateProducer() throws Exception {
  OperationMeta operationMeta = schemaMeta.ensureFindOperation("add");
  Assert.assertEquals("add", operationMeta.getOperationId());

  SwaggerProducerOperation producerOperation = operationMeta.getExtData(Const.PRODUCER_OPERATION);

  Object addBody = Class.forName("cse.gen.app.ms.schema.addBody").newInstance();
  ReflectUtils.setField(addBody, "x", 1);
  ReflectUtils.setField(addBody, "y", 2);
  Invocation invocation = new Invocation((Endpoint) null, operationMeta, new Object[] {addBody}) {
    @Override
    public String getInvocationQualifiedName() {
      return "";
    }
  };
  Holder<Response> holder = new Holder<>();
  producerOperation.invoke(invocation, resp -> {
    holder.value = resp;
  });
  Assert.assertEquals(3, (int) holder.value.getResult());

  invocation.setSwaggerArguments(new Object[] {1, 2});
  producerOperation.invoke(invocation, resp -> {
    holder.value = resp;
  });
  Assert.assertEquals(true, holder.value.isFailed());
  InvocationException exception = (InvocationException) holder.value.getResult();
  CommonExceptionData data = (CommonExceptionData) exception.getErrorData();
  Assert.assertEquals("Cse Internal Server Error", data.getMessage());
}
项目:CodeKatas    文件:JDK8DeckOfCardsAsSortedSetTest.java   
@Test
public void cardsBySuit()
{
    Map<Suit, SortedSet<Card>> jdk1CardsBySuit = this.jdk1Deck.getCardsBySuit();
    Map<Suit, SortedSet<Card>> jdk2CardsBySuit = this.jdk2Deck.getCardsBySuit();
    Assert.assertEquals(jdk1CardsBySuit.get(Suit.CLUBS), jdk2CardsBySuit.get(Suit.CLUBS));
}
项目:openjdk-systemtest    文件:TestSuite003.java   
public void testItem_0626()
{
  boolean caught;
  caught = false;
  try {
    rc_BigDecimal = new BigDecimal(new java.math.BigInteger("32"), new MathContext("precision=1 roundingMode=UNNECESSARY"));
  }
  catch (java.lang.ArithmeticException e) {
    caught = true;
  }
  Assert.assertEquals("89.93288590604027%", true, caught);
}
项目:redirector    文件:AppModelRestFacadeTest.java   
@Ignore("Do we still need it? We don't get this version from Zk")
@Test
public void testGetModelVersionStatsNull() throws Exception {
    setupSuccessfullyConnectingPerServiceCache(true);
    setupGetVersionThrowsException();
    testee.start();

    Assert.assertEquals(RedirectorConstants.NO_MODEL_NODE_VERSION, testee.getModelVersion());
}
项目:mybatis-generator-plugin    文件:UpsertPluginTest.java   
/**
 * 测试配置异常
 */
@Test
public void testWarnings() throws IOException, XMLParserException, InvalidConfigurationException, InterruptedException, SQLException {
    // 1. 没有使用mysql数据库
    MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/UpsertPlugin/mybatis-generator-with-error-driver.xml");
    tool.generate();
    Assert.assertEquals(tool.getWarnings().get(1), "itfsw:插件com.itfsw.mybatis.generator.plugins.UpsertPlugin插件使用前提是数据库为MySQL!");

    // 2. 普通提示
    tool = MyBatisGeneratorTool.create("scripts/UpsertPlugin/mybatis-generator.xml");
    tool.generate();
    Assert.assertEquals(tool.getWarnings().get(0), "itfsw:插件com.itfsw.mybatis.generator.plugins.UpsertPlugin插件您开启了allowMultiQueries支持,注意在jdbc url 配置中增加“allowMultiQueries=true”支持(不怎么建议使用该功能,开启多sql提交会增加sql注入的风险,请确保你所有sql都使用MyBatis书写,请不要使用statement进行sql提交)!");
}
项目:openjdk-systemtest    文件:TestSuite004.java   
public void testItem_0113()
{
  boolean caught;
  caught = false;
  try {
    rc_BigDecimal = (new BigDecimal("8507059173023461584739690778423250124.9")).divide(new BigDecimal("0"), -2147483648, 2147483647);
  }
  catch (java.lang.IllegalArgumentException e) {
    caught = true;
  }
  Assert.assertEquals("89.93288590604027%", true, caught);
}
项目:openjdk-systemtest    文件:TestSuite027.java   
public void testItem_0955()
{
  rc_BigDecimal = (new BigDecimal("179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368")).min(new BigDecimal("1.0"));
  Assert.assertEquals("1.0", rc_BigDecimal.toString());
}
项目:openjdk-systemtest    文件:TestSuite040.java   
public void testItem_0606()
{
  rc_BigDecimal = (new BigDecimal("0.0")).multiply(new BigDecimal("0.0"));
  Assert.assertEquals("0.00", rc_BigDecimal.toString());
}
项目:sats-core    文件:BMValueTest.java   
@Test
public void valueOfCompleteBundle() {
    Bundle<BMLicense> bundle = new Bundle<>(bidder.getWorld().getLicenses());
    BigDecimal value = bidder.calculateValue(bundle);
    Assert.assertTrue(bidder.getSetupType() + " value was " + value + " should be " + expextedValuedCompleteBundle, value.compareTo(expextedValuedCompleteBundle) == 0);
}
项目:openjdk-systemtest    文件:TestSuite039.java   
public void testItem_0673()
{
  rc_BigDecimal = new BigDecimal(-1.0);
  Assert.assertEquals("-1", rc_BigDecimal.toString());
}