当前位置: 首页>>代码示例>>Java>>正文


Java Assert.assertNotNull方法代码示例

本文整理汇总了Java中org.junit.Assert.assertNotNull方法的典型用法代码示例。如果您正苦于以下问题:Java Assert.assertNotNull方法的具体用法?Java Assert.assertNotNull怎么用?Java Assert.assertNotNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.junit.Assert的用法示例。


在下文中一共展示了Assert.assertNotNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testFail

import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void testFail() {
    completer.fail(new Object());

    ArgumentCaptor<Status> statusCaptor = ArgumentCaptor.forClass(Status.class);
    ArgumentCaptor<String> reasonCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> detailCaptor = ArgumentCaptor.forClass(String.class);
    Mockito.verify(sender, Mockito.atLeastOnce()).send(Mockito.any(), statusCaptor.capture(), reasonCaptor.capture(), detailCaptor.capture());

    Status status = statusCaptor.getAllValues().get(0);
    Assert.assertNotNull(status);
    Assert.assertEquals(Status.FAIL, status);

    String reason = reasonCaptor.getAllValues().get(0);
    Assert.assertNull(reason);

    String detail = detailCaptor.getAllValues().get(0);
    Assert.assertNull(detail);
}
 
开发者ID:EsikAntony,项目名称:camunda-task-dispatcher,代码行数:20,代码来源:JmsExternalTaskCompleterTest.java

示例2: should_create_agent_and_send_webhook_if_agent_status_changed

import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void should_create_agent_and_send_webhook_if_agent_status_changed() throws Throwable {
    // given: mock agent webhook callback
    String webhook = "http://localhost:8088/agent/callback";
    stubFor(post(urlEqualTo("/agent/callback")).willReturn(aResponse().withStatus(200)));

    // when:
    AgentPath agentPath = new AgentPath("default", "hello-agent");
    agentService.create(agentPath, webhook);

    // then:
    Agent loaded = agentService.find(agentPath);
    Assert.assertNotNull(loaded);
    Assert.assertEquals(agentPath, loaded.getPath());
    Assert.assertEquals(webhook, loaded.getWebhook());
    Assert.assertEquals(AgentStatus.OFFLINE, loaded.getStatus());

    // when: mock agent status changed
    agentService.saveWithStatus(loaded, AgentStatus.IDLE);
    Thread.sleep(1000); // wait for webhook callback

    // then: check webhook is send or not
    CountMatchingStrategy strategy = new CountMatchingStrategy(CountMatchingStrategy.EQUAL_TO, 1);
    verify(strategy, postRequestedFor(urlEqualTo("/agent/callback")));
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:26,代码来源:AgentServiceTest.java

示例3: testCREATE

import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void testCREATE() throws Exception {


    NamespacedList nmsp = new NamespacedList();
    Set<Value> values  = new LinkedHashSet<>();
    values.add(new Value("test"));
    values.add(new Value("test1"));
    values.add(new Value("test2"));
    values.add(new Value("test3"));
    nmsp.setRet(values);
    List<NamespacedList> namespaceList = new ArrayList<NamespacedList>();
    namespaceList.add(nmsp);
    Namespaces mainNmsp = new Namespaces();
    mainNmsp.setNamespaces(namespaceList);
    final String result = serializeIt(mainNmsp, true);
    System.out.println(result);
    Assert.assertNotNull(result);
}
 
开发者ID:Comcast,项目名称:redirector,代码行数:20,代码来源:NamespaceTest.java

示例4: encodeDecodeBlockHashResponseMessage

import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void encodeDecodeBlockHashResponseMessage() {
    long id = 42;
    byte[] hash = new byte[32];
    Random random = new Random();
    random.nextBytes(hash);

    BlockHashResponseMessage message = new BlockHashResponseMessage(id, hash);

    byte[] encoded = message.getEncoded();

    Message result = Message.create(encoded);

    Assert.assertNotNull(result);
    Assert.assertArrayEquals(encoded, result.getEncoded());
    Assert.assertEquals(MessageType.BLOCK_HASH_RESPONSE_MESSAGE, result.getMessageType());

    BlockHashResponseMessage newMessage = (BlockHashResponseMessage) result;

    Assert.assertEquals(id, newMessage.getId());
    Assert.assertArrayEquals(hash, newMessage.getHash());
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:23,代码来源:MessageTest.java

示例5: test306

import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void test306() throws Throwable {
    if (debug)
        System.out.format("%n%s%n", "RegressionTest0.test306");
    Table table2 = new Table("", ",");
    table2.setTrimmedName("hi!");
    String str5 = table2.getLowerCaseTrimmedName();
    Table[] table_array6 = new Table[] {};
    ArrayList<Table> arraylist_table7 = new ArrayList<Table>();
    boolean b8 = Collections.addAll(arraylist_table7, table_array6);
    List<Table> list_table9 = Optimization.optimize(arraylist_table7);
    Connection connection10 = null;
    List<Table> list_table12 = Schema.getExpensiveFeatures(arraylist_table7, connection10, "");
    table2.isJunctionTable(list_table12);
    List<Table> list_table14 = Optimization.optimize(list_table12);
    double d15 = Accuracy.getPkRecall(list_table14);
    List<Table> list_table16 = Optimization.optimize(list_table14);
    Assert.assertNull(str5);
    Assert.assertNotNull(table_array6);
    Assert.assertTrue(b8 == false);
    Assert.assertNotNull(list_table9);
    Assert.assertNotNull(list_table12);
    Assert.assertNotNull(list_table14);
    Assert.assertEquals(d15, Double.NaN, 0);
    Assert.assertNotNull(list_table16);
}
 
开发者ID:janmotl,项目名称:linkifier,代码行数:27,代码来源:RegressionTest.java

示例6: assertSortRequest

import org.junit.Assert; //导入方法依赖的package包/类
private void assertSortRequest(FeatureFileSortRequest request, ArgumentMatcher payloadMatcher) throws Exception {
    ResultActions actions = mvc()
            .perform(post(URL_SORT).content(getObjectMapper().writeValueAsString(request))
                    .contentType(EXPECTED_CONTENT_TYPE))
            .andExpect(status().isOk())
            .andExpect(content().contentType(EXPECTED_CONTENT_TYPE))
            .andExpect(jsonPath(JPATH_PAYLOAD).value(payloadMatcher))
            .andExpect(jsonPath(JPATH_STATUS).value(ResultStatus.OK.name()));
    actions.andDo(MockMvcResultHandlers.print());

    final ResponseResult<String> res = getObjectMapper()
            .readValue(actions.andReturn().getResponse().getContentAsByteArray(),
                    getTypeFactory().constructParametrizedType(ResponseResult.class, ResponseResult.class,
                            String.class));

    Assert.assertNotNull(res.getPayload());
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:18,代码来源:ToolsControllerTest.java

示例7: testEagerAdapter

import org.junit.Assert; //导入方法依赖的package包/类
public void testEagerAdapter() {
  final Context context = getContext();
  final Resources res = context.getResources();
  final String[] uris = res.getStringArray(R.array.local_uri_test);
  Assert.assertNotNull(uris);
  SimpleAdapter<Uri> simpleAdapter = LocalResourceSimpleAdapter
      .getEagerAdapter(context, R.array.local_uri_test);
  checkSimpleAdapterData(simpleAdapter, uris.length);
  Assert.assertFalse(simpleAdapter.isLazy());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:LocalResourceSimpleAdapterTest.java

示例8: testFindEmpty

import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void testFindEmpty() {
  when(appService.findAll(any(Pageable.class))).thenReturn(new ArrayList<App>());
  Pageable pageable = new PageRequest(0, 10);
  List<AppDTO> appDTOs = appController.find(null, pageable);
  Assert.assertNotNull(appDTOs);
  Assert.assertEquals(0, appDTOs.size());

  appDTOs = appController.find("", pageable);
  Assert.assertNotNull(appDTOs);
  Assert.assertEquals(0, appDTOs.size());
}
 
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:13,代码来源:ControllerExceptionTest.java

示例9: checkIfTitleIsDisplayed

import org.junit.Assert; //导入方法依赖的package包/类
/**
 * Test that the toolbar title is set correctly
 * @throws Exception
 */
@Test
public void checkIfTitleIsDisplayed() throws Exception{
  Assert.assertNotNull(solo.waitForActivity(MapbookActivity.class, 2000));
  final ActionBar actionBar = mActivityRule.getActivity().getSupportActionBar();
  Assert.assertNotNull(actionBar);
  Assert.assertTrue(solo.waitForText( solo.getString(R.string.title)));
}
 
开发者ID:Esri,项目名称:mapbook-android,代码行数:12,代码来源:MapbookTest.java

示例10: shouldGetPodcast

import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void shouldGetPodcast() throws IOException, JSONException {
    Podcast podcast;
    try (InputStream stream = getResource("podcasts/podcast-1.html")) {
        PodcastLayoutContent content = parser.parse(0, stream, "UTF-8", RESPONSE_URL);
        podcast = content.getPodcast();
    }
    Assert.assertNotNull(podcast);
    try (InputStream resource = getResource("podcasts/podcast-1.podcast.json")) {
        String json = IOUtils.toString(resource, "UTF-8");
        assertEquals(new JSONObject(json), podcast.toJson());
    }
}
 
开发者ID:kalikov,项目名称:lighthouse,代码行数:14,代码来源:PodcastLayoutParserTest.java

示例11: testValidMessageConstruction

import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void testValidMessageConstruction() {
    String line = ":[email protected] PRIVMSG #mrbean :hey man";
    Message msg = new Message().createMessage(line);
    Assert.assertNotNull(msg);
    Assert.assertEquals(msg.getAuthor(), "andrew");
    Assert.assertEquals(msg.getChannel(), "mrbean");
    Assert.assertEquals(msg.getContent(), "hey man");
}
 
开发者ID:agapic,项目名称:Twitch-Streamer,代码行数:10,代码来源:MessageTest.java

示例12: test_error2

import org.junit.Assert; //导入方法依赖的package包/类
public void test_error2() throws Exception {
    Exception error = null;
    try {
        Assert.assertEquals(null, JSON.parseObject("{}", MyException.class).getMessage());
    } catch (Exception ex) {
        error = ex;
    }
    Assert.assertNotNull(error);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:ThrowableDeserializerTest.java

示例13: test179

import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void test179() throws Throwable {
    if (debug)
        System.out.format("%n%s%n", "RegressionTest0.test179");
    Column column2 = new Column(",", "");
    column2.setEstimatedRowCount((int) (byte) 0);
    List<String> list_str5 = column2.getTokenizedLowerCaseTrimmedName();
    column2.setDecimalDigits((int) ' ');
    column2.setTableContainsLob(false);
    String str10 = column2.getName();
    Assert.assertNotNull(list_str5);
    Assert.assertTrue("'" + str10 + "' != '" + "" + "'", str10.equals(""));
}
 
开发者ID:janmotl,项目名称:linkifier,代码行数:14,代码来源:RegressionTest.java

示例14: test

import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void test() throws Exception {

  TracerTestImpl tracer = new TracerTestImpl();

  TraceClientFilter tcf = new TraceClientFilter();
  tcf.setTracer(tracer);

  MultivaluedMap<String, Object> headerAccess = new MultivaluedHashMap<>();

  ClientRequestContext requestContext = Mockito.mock(ClientRequestContext.class);
  Mockito.when(requestContext.getUri()).thenReturn(new URI("https://example.com:7110/some/path"));
  Mockito.when(requestContext.getMethod()).thenReturn("GET");
  Mockito.when(requestContext.getHeaders()).thenReturn(headerAccess);
  Mockito.when(requestContext.getEntityAnnotations()).thenReturn(new Annotation[]{});
  tcf.filter(requestContext);
  Assert.assertNotNull(tracer.getCurrentSpan());

  ClientResponseContext responseContext = Mockito.mock(ClientResponseContext.class);
  tcf.filter(requestContext, responseContext);
  Assert.assertNull(tracer.getCurrentSpan());

  Span span = tracer.getCapturedSpan();
  Assert.assertEquals("service", span.getService());
  Assert.assertEquals("example.com:7110", span.getResource());
  Assert.assertEquals("GET /some/path", span.getOperation());
  Assert.assertEquals(Long.parseUnsignedLong((String)headerAccess.getFirst(TracerImpl.TRACE_ID)), span.getTraceId());
  Assert.assertEquals(Long.parseUnsignedLong((String)headerAccess.getFirst(TracerImpl.SPAN_ID)), span.getSpanId());
}
 
开发者ID:chonton,项目名称:apm-client,代码行数:30,代码来源:TraceClientFilterTest.java

示例15: test_create_error

import org.junit.Assert; //导入方法依赖的package包/类
public void test_create_error() throws Exception {
    Exception error = null;
    try {
        JSON.parseObject("{\"id\":1001,\"name\":\"wenshao\",\"obj\":{\"$ref\":123}}", Entity.class);
    } catch (JSONException ex) {
        error = ex;
    }
    Assert.assertNotNull(error);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:JSONCreatorTest3.java


注:本文中的org.junit.Assert.assertNotNull方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。