本文整理了Java中org.testng.Assert.assertNull()
方法的一些代码示例,展示了Assert.assertNull()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.assertNull()
方法的具体详情如下:
包路径:org.testng.Assert
类名称:Assert
方法名:assertNull
[英]Asserts that an object is null. If it is not, an AssertionError, with the given message, is thrown.
[中]断言对象为空。如果不是,则抛出带有给定消息的AssertionError。
代码示例来源: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
private static void assertColumnList(List<com.amazonaws.services.glue.model.Column> actual, List<Column> expected)
{
if (expected == null) {
assertNull(actual);
}
assertEquals(actual.size(), expected.size());
for (int i = 0; i < expected.size(); i++) {
assertColumn(actual.get(i), expected.get(i));
}
}
代码示例来源:origin: prestodb/presto
@Test
public void testBuildExpressionNullOrEmptyValues()
{
assertNull(buildGlueExpression(PARTITION_KEYS, ImmutableList.of()));
assertNull(buildGlueExpression(PARTITION_KEYS, null));
}
代码示例来源:origin: prestodb/presto
@Test
public void testExecuteUpdateWithInsert()
throws Exception
{
try (Connection connection = createConnection("blackhole", "blackhole")) {
try (Statement statement = connection.createStatement()) {
assertEquals(statement.executeUpdate("INSERT INTO test_table VALUES (1), (2)"), 2);
assertNull(statement.getResultSet());
assertEquals(statement.getUpdateCount(), 2);
assertEquals(statement.getLargeUpdateCount(), 2);
}
}
}
代码示例来源:origin: prestodb/presto
@Test
public void testCreateGroupedStateEmpty()
{
GeometryState state = factory.createGroupedState();
assertNull(state.getGeometry());
assertTrue(state.getEstimatedSize() > 0, String.format("Estimated memory size was %d", state.getEstimatedSize()));
}
代码示例来源: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: swagger-api/swagger-core
private void checkType(Schema property, Class<?> cls, String type, String format) {
assertTrue(cls.isInstance(property));
assertEquals(property.getType(), type);
if (format == null) {
assertNull(property.getFormat());
} else {
assertEquals(property.getFormat(), format);
}
}
代码示例来源:origin: prestodb/presto
@Test
public void testAddColumn()
MaterializedResult materializedRows = computeActual("SELECT x, a FROM test_add_column ORDER BY x");
assertEquals(materializedRows.getMaterializedRows().get(0).getField(0), 123);
assertNull(materializedRows.getMaterializedRows().get(0).getField(1));
assertEquals(materializedRows.getMaterializedRows().get(1).getField(0), 234);
assertEquals(materializedRows.getMaterializedRows().get(1).getField(1), 111L);
materializedRows = computeActual("SELECT x, a, b FROM test_add_column ORDER BY x");
assertEquals(materializedRows.getMaterializedRows().get(0).getField(0), 123);
assertNull(materializedRows.getMaterializedRows().get(0).getField(1));
assertNull(materializedRows.getMaterializedRows().get(0).getField(2));
assertEquals(materializedRows.getMaterializedRows().get(1).getField(0), 234);
assertEquals(materializedRows.getMaterializedRows().get(1).getField(1), 111L);
assertNull(materializedRows.getMaterializedRows().get(1).getField(2));
assertEquals(materializedRows.getMaterializedRows().get(2).getField(0), 345);
assertEquals(materializedRows.getMaterializedRows().get(2).getField(1), 222L);
assertUpdate("DROP TABLE test_add_column_a");
assertUpdate("DROP TABLE test_add_column_ab");
assertFalse(getQueryRunner().tableExists(getSession(), "test_add_column"));
assertFalse(getQueryRunner().tableExists(getSession(), "test_add_column_a"));
assertFalse(getQueryRunner().tableExists(getSession(), "test_add_column_ab"));
代码示例来源: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: prestodb/presto
private void assertSetNull(int sqlType, int expectedSqlType)
throws SQLException
{
try (Connection connection = createConnection();
PreparedStatement statement = connection.prepareStatement("SELECT ?")) {
statement.setNull(1, sqlType);
try (ResultSet rs = statement.executeQuery()) {
assertTrue(rs.next());
assertNull(rs.getObject(1));
assertTrue(rs.wasNull());
assertFalse(rs.next());
assertEquals(rs.getMetaData().getColumnType(1), expectedSqlType);
}
}
}
代码示例来源:origin: prestodb/presto
@Test
public void testExecuteUpdateWithCreateTable()
throws Exception
{
try (Connection connection = createConnection("blackhole", "blackhole")) {
try (Statement statement = connection.createStatement()) {
assertEquals(statement.executeUpdate("CREATE TABLE test_execute_create (x bigint)"), 0);
assertNull(statement.getResultSet());
assertEquals(statement.getUpdateCount(), 0);
assertEquals(statement.getLargeUpdateCount(), 0);
}
}
}
代码示例来源:origin: swagger-api/swagger-core
@Test(description = "it should generate a JSON with read-only from pojo, #1161")
public void readOnlyJsonGeneration() throws IOException {
Map<String, Schema> models = ModelConverters.getInstance().read(ReadOnlyModel.class);
Schema model = models.get("ReadOnlyModel");
Schema id = (Schema) model.getProperties().get("id");
assertTrue(id.getReadOnly());
Schema readWriteId = (Schema) model.getProperties().get("readWriteId");
assertNull(readWriteId.getReadOnly());
}
代码示例来源: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 assertSourceFinished(LocalExchangeSource source)
{
assertTrue(source.isFinished());
LocalExchangeBufferInfo bufferInfo = source.getBufferInfo();
assertEquals(bufferInfo.getBufferedPages(), 0);
assertEquals(bufferInfo.getBufferedBytes(), 0);
assertTrue(source.waitForReading().isDone());
assertNull(source.removePage());
assertTrue(source.waitForReading().isDone());
assertTrue(source.isFinished());
}
代码示例来源:origin: prestodb/presto
private static void assertColumnList(List<Column> actual, List<com.amazonaws.services.glue.model.Column> expected)
{
if (expected == null) {
assertNull(actual);
}
assertEquals(actual.size(), expected.size());
for (int i = 0; i < expected.size(); i++) {
assertColumn(actual.get(i), expected.get(i));
}
}
代码示例来源:origin: prestodb/presto
@Test
public void testUriWithSslEnabled()
throws SQLException
{
PrestoDriverUri parameters = createDriverUri("presto://localhost:8080/blackhole?SSL=true");
assertUriPortScheme(parameters, 8080, "https");
Properties properties = parameters.getProperties();
assertNull(properties.getProperty(SSL_TRUST_STORE_PATH.getKey()));
assertNull(properties.getProperty(SSL_TRUST_STORE_PASSWORD.getKey()));
}
代码示例来源:origin: linkedin/parseq
@Test
public void testTaskCancellationAfterCompleted() throws InterruptedException {
final AtomicReference<Throwable> cancelActionValue = new AtomicReference<>();
Task<?> completed = Task.value(10);
completed.addListener(p -> {
if (p.isFailed() && Exceptions.isCancellation(p.getError())) {
cancelActionValue.set(p.getError().getCause());
}
} );
runAndWait("TestTaskCancellation.testTaskCancellationAfterCompleted", completed);
Exception cancelReason = new Exception();
assertFalse(completed.cancel(cancelReason));
assertNull(cancelActionValue.get());
}
代码示例来源:origin: swagger-api/swagger-core
@Test
public void findMethodTest() throws NoSuchMethodException {
final Method methodToFind1 = Child.class.getMethod("parametrizedMethod1", Integer.class);
final Method method1 = ReflectionUtils.findMethod(methodToFind1, Parent.class);
Assert.assertNotNull(method1);
Assert.assertEquals(method1.getParameterTypes()[0], Number.class);
final Method methodToFind2 = Child.class.getMethod("parametrizedMethod4", Long.class);
final Method method2 = ReflectionUtils.findMethod(methodToFind2, Parent.class);
Assert.assertNull(method2);
}
代码示例来源:origin: swagger-api/swagger-core
@Test(description = "it should deserialize a BooleanSchema")
public void deserializeBooleanSchema() throws IOException {
final String json = "{\"type\":\"boolean\",\"default\":false}";
final Schema p = m.readValue(json, Schema.class);
assertEquals(p.getType(), "boolean");
assertNull(p.getFormat());
assertEquals(p.getClass(), BooleanSchema.class);
assertEquals(((BooleanSchema) p).getDefault(), Boolean.FALSE);
assertEquals(m.writeValueAsString(p), json);
}
代码示例来源:origin: AsyncHttpClient/async-http-client
@Test
public void testRequestTimeout() throws IOException {
try (AsyncHttpClient client = asyncHttpClient()) {
Future<Response> responseFuture = client.prepareGet(getTargetUrl()).setRequestTimeout(100).execute();
Response response = responseFuture.get(2000, TimeUnit.MILLISECONDS);
assertNull(response);
} catch (InterruptedException e) {
fail("Interrupted.", e);
} catch (ExecutionException e) {
assertTrue(e.getCause() instanceof TimeoutException);
checkTimeoutMessage(e.getCause().getMessage(), true);
} catch (TimeoutException e) {
fail("Timeout.", e);
}
}
内容来源于网络,如有侵权,请联系作者删除!