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