本文整理了Java中org.testng.Assert.assertNotNull()
方法的一些代码示例,展示了Assert.assertNotNull()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.assertNotNull()
方法的具体详情如下:
包路径:org.testng.Assert
类名称:Assert
方法名:assertNotNull
[英]Asserts that an object isn't null. If it is, an AssertionError is thrown.
[中]断言对象不是null。如果是,则抛出断言错误。
代码示例来源:origin: spring-projects/spring-framework
@Test
@Transactional(propagation = Propagation.NOT_SUPPORTED)
void autowiringFromConfigClass() {
assertNotNull(employee, "The employee should have been autowired.");
assertEquals(employee.getName(), "John Smith");
assertNotNull(pet, "The pet should have been autowired.");
assertEquals(pet.getName(), "Fido");
}
代码示例来源:origin: spring-projects/spring-framework
@Test
@Transactional(propagation = Propagation.NOT_SUPPORTED)
void verifyAnnotationAutowiredFields() {
assertInTransaction(false);
assertNull(nonrequiredLong, "The nonrequiredLong field should NOT have been autowired.");
assertNotNull(pet, "The pet field should have been autowired.");
assertEquals(pet.getName(), "Fido", "pet's name.");
}
代码示例来源:origin: prestodb/presto
@Test
public void testNonExistingHomeFolder()
throws Exception
{
File historyFile = new File("/?", ".history");
assertFalse(historyFile.canRead(), "historyFile is readable");
assertFalse(historyFile.canWrite(), "historyFile is writable");
MemoryHistory result = Console.getHistory(historyFile);
assertNotNull(result, "result is null");
assertFalse(result instanceof FileHistory, "result type is FileHistory");
}
}
代码示例来源:origin: apache/incubator-pinot
@Override
protected List<PeriodicTask> setupControllerPeriodicTasks() {
PinotHelixResourceManager helixResourceManager = getHelixResourceManager();
Assert.assertNotNull(helixResourceManager);
Assert.assertNotNull(helixResourceManager.getHelixAdmin());
Assert.assertNotNull(helixResourceManager.getHelixZkManager());
Assert.assertNotNull(helixResourceManager.getHelixClusterName());
Assert.assertNotNull(helixResourceManager.getPropertyStore());
_controllerPeriodicTasks = super.setupControllerPeriodicTasks();
Assert.assertNotNull(_controllerPeriodicTasks);
Assert.assertEquals(_controllerPeriodicTasks.size(), NUM_PERIODIC_TASKS);
return _controllerPeriodicTasks;
}
代码示例来源:origin: prestodb/presto
@Test
public void testSvmRegressor()
{
Model model = new SvmRegressor();
model.train(getDataset());
Slice serialized = ModelUtils.serialize(model);
Model deserialized = ModelUtils.deserialize(serialized);
assertNotNull(deserialized, "deserialization failed");
assertTrue(deserialized instanceof SvmRegressor, "deserialized model is not a svm");
}
代码示例来源:origin: swagger-api/swagger-core
@Test(description = "it should override the property name")
public void overridePropertyName() {
final Map<String, Schema> schemas = readAll(ModelWithAltPropertyName.class);
final Map<String, Schema> properties = schemas.get("sample_model").getProperties();
assertNull(properties.get("id"));
assertNotNull(properties.get("the_id"));
}
代码示例来源:origin: prestodb/presto
private static void assertOutputBuffers(OutputBuffers outputBuffers)
{
assertNotNull(outputBuffers);
assertTrue(outputBuffers.getVersion() > 0);
assertTrue(outputBuffers.isNoMoreBufferIds());
Map<OutputBufferId, Integer> buffers = outputBuffers.getBuffers();
assertEquals(buffers.size(), 4);
for (int partition = 0; partition < 4; partition++) {
assertEquals(buffers.get(new OutputBufferId(partition)), Integer.valueOf(partition));
}
}
}
代码示例来源:origin: prestodb/presto
private static void assertMinMax(StringStatistics actualStringStatistics, Slice expectedMin, Slice expectedMax)
{
if (expectedMax == null && expectedMin == null) {
assertNull(actualStringStatistics);
return;
}
assertNotNull(actualStringStatistics);
assertEquals(actualStringStatistics.getMin(), expectedMin);
assertEquals(actualStringStatistics.getMax(), expectedMax);
}
代码示例来源:origin: cbeust/testng
public void verifyNewConfigurationBefore() throws SecurityException, NoSuchMethodException
{
Method method = MTest1.class.getMethod("newBefore");
IConfigurationAnnotation configuration =
(IConfigurationAnnotation) m_finder.findAnnotation(method, IBeforeSuite.class);
Assert.assertNotNull(configuration);
Assert.assertTrue(configuration.getBeforeSuite());
// Default values
Assert.assertTrue(configuration.getEnabled());
Assert.assertTrue(configuration.getInheritGroups());
Assert.assertFalse(configuration.getAlwaysRun());
}
代码示例来源:origin: prestodb/presto
private static void assertWarnings(SQLWarning warning, Set<WarningEntry> currentWarnings)
{
assertNotNull(warning);
int previousSize = currentWarnings.size();
addWarnings(currentWarnings, warning);
assertTrue(currentWarnings.size() >= previousSize);
}
代码示例来源:origin: prestodb/presto
private void testReadWrite(Random random, int records, Function<List<Block>, PrestoThriftPageResult> convert)
{
// generate columns data
List<Block> inputBlocks = new ArrayList<>(columns.size());
for (ColumnDefinition column : columns) {
inputBlocks.add(generateColumn(column, random, records));
}
// convert column data to thrift ("write step")
PrestoThriftPageResult batch = convert.apply(inputBlocks);
// convert thrift data to page/blocks ("read step")
Page page = batch.toPage(columns.stream().map(ColumnDefinition::getType).collect(toImmutableList()));
// compare the result with original input
assertNotNull(page);
assertEquals(page.getChannelCount(), columns.size());
for (int i = 0; i < columns.size(); i++) {
Block actual = page.getBlock(i);
Block expected = inputBlocks.get(i);
assertBlock(actual, expected, columns.get(i));
}
}
代码示例来源:origin: swagger-api/swagger-core
@Test
public void getRepeatableAnnotationsArrayTest() {
Tag[] annotations = ReflectionUtils.getRepeatableAnnotationsArray(InheritingClass.class, Tag.class);
Assert.assertNotNull(annotations);
Assert.assertTrue(annotations.length == 1);
Assert.assertNotNull(annotations[0]);
Assert.assertEquals("inherited tag", annotations[0].name());
}
代码示例来源:origin: spring-projects/spring-framework
@Test
void autowiringFromConfigClass() {
assertNotNull(employee, "The employee should have been autowired.");
assertEquals(employee.getName(), "John Smith");
assertNotNull(pet, "The pet should have been autowired.");
assertEquals(pet.getName(), "Fido");
}
代码示例来源:origin: prestodb/presto
@Test
public void testFromValueSetNone()
{
PrestoThriftValueSet thriftValueSet = fromValueSet(ValueSet.none(JSON));
assertNotNull(thriftValueSet.getEquatableValueSet());
assertTrue(thriftValueSet.getEquatableValueSet().isWhiteList());
assertTrue(thriftValueSet.getEquatableValueSet().getValues().isEmpty());
}
代码示例来源:origin: swagger-api/swagger-core
@Test
public void getAnnotationTest() throws NoSuchMethodException {
final Method method = Child.class.getMethod("annotationHolder");
Assert.assertNotNull(ReflectionUtils.getAnnotation(method, Schema.class));
Assert.assertNull(ReflectionUtils.getAnnotation(method, ApiResponse.class));
}
代码示例来源:origin: prestodb/presto
private static void assertRemovePage(LocalExchangeSource source, Page expectedPage)
{
assertTrue(source.waitForReading().isDone());
Page actualPage = source.removePage();
assertNotNull(actualPage);
assertEquals(actualPage.getChannelCount(), expectedPage.getChannelCount());
PageAssertions.assertPageEquals(TYPES, actualPage, expectedPage);
}
代码示例来源:origin: prestodb/presto
@Test
public void testFromValueSetNone()
{
PrestoThriftValueSet thriftValueSet = fromValueSet(ValueSet.none(HYPER_LOG_LOG));
assertNotNull(thriftValueSet.getAllOrNoneValueSet());
assertFalse(thriftValueSet.getAllOrNoneValueSet().isAll());
}
}
代码示例来源:origin: cbeust/testng
public void verifyNewConfigurationAfter() throws SecurityException, NoSuchMethodException
{
Method method = MTest1.class.getMethod("newAfter");
IConfigurationAnnotation configuration =
(IConfigurationAnnotation) m_finder.findAnnotation(method, IAfterSuite.class);
Assert.assertNotNull(configuration);
Assert.assertTrue(configuration.getAfterSuite());
// Default values
Assert.assertTrue(configuration.getEnabled());
Assert.assertTrue(configuration.getInheritGroups());
Assert.assertFalse(configuration.getAlwaysRun());
}
代码示例来源:origin: prestodb/presto
private static void assertLearnClassifer(Accumulator accumulator)
{
accumulator.addInput(getPage());
BlockBuilder finalOut = accumulator.getFinalType().createBlockBuilder(null, 1);
accumulator.evaluateFinal(finalOut);
Block block = finalOut.build();
Slice slice = accumulator.getFinalType().getSlice(block, 0);
Model deserialized = ModelUtils.deserialize(slice);
assertNotNull(deserialized, "deserialization failed");
assertTrue(deserialized instanceof Classifier, "deserialized model is not a classifier");
}
代码示例来源:origin: killbill/killbill
private void verifyAuditLogsForTag(final List<AuditLog> auditLogs, final AuditLevel level) {
if (AuditLevel.NONE.equals(level)) {
Assert.assertEquals(auditLogs.size(), 0);
return;
}
Assert.assertEquals(auditLogs.size(), 1);
Assert.assertEquals(auditLogs.get(0).getUserToken(), internalCallContext.getUserToken().toString());
Assert.assertEquals(auditLogs.get(0).getChangeType(), ChangeType.INSERT);
Assert.assertEquals(auditLogs.get(0).getComment(), internalCallContext.getComments());
Assert.assertEquals(auditLogs.get(0).getReasonCode(), internalCallContext.getReasonCode());
Assert.assertEquals(auditLogs.get(0).getUserName(), internalCallContext.getCreatedBy());
Assert.assertNotNull(auditLogs.get(0).getCreatedDate());
}
}
内容来源于网络,如有侵权,请联系作者删除!