本文整理了Java中org.testng.Assert.fail()
方法的一些代码示例,展示了Assert.fail()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.fail()
方法的具体详情如下:
包路径:org.testng.Assert
类名称:Assert
方法名:fail
[英]Fails a test with no message.
[中]没有消息的测试失败。
代码示例来源:origin: prestodb/presto
@Test(groups = {LDAP, SIMBA_JDBC, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT)
public void shouldFailQueryForLdapWithoutSsl()
{
try {
DriverManager.getConnection(getLdapUrl() + ";SSL=0", ldapUserName, ldapUserPassword);
fail();
}
catch (SQLException exception) {
assertEquals(exception.getMessage(), INVALID_SSL_PROPERTY);
}
}
代码示例来源:origin: prestodb/presto
protected void expectQueryToFail(String user, String password, String message)
{
try {
executeLdapQuery(NATION_SELECT_ALL_QUERY, user, password);
fail();
}
catch (SQLException exception) {
assertEquals(exception.getMessage(), message);
}
}
代码示例来源:origin: prestodb/presto
public static void assertContains(MaterializedResult all, MaterializedResult expectedSubset)
{
for (MaterializedRow row : expectedSubset.getMaterializedRows()) {
if (!all.getMaterializedRows().contains(row)) {
fail(format("expected row missing: %s\nAll %s rows:\n %s\nExpected subset %s rows:\n %s\n",
row,
all.getMaterializedRows().size(),
Joiner.on("\n ").join(Iterables.limit(all, 100)),
expectedSubset.getMaterializedRows().size(),
Joiner.on("\n ").join(Iterables.limit(expectedSubset, 100))));
}
}
}
代码示例来源:origin: cbeust/testng
@Test
public void test() {
switch (dataTest.s) {
case "FOO":
Assert.assertFalse(dataTest.b);
break;
case "foo":
Assert.assertTrue(dataTest.b);
break;
default:
Assert.fail("Unknown value");
}
}
代码示例来源:origin: prestodb/presto
@Test
public void testNonexistentType()
{
try {
TypeManager typeManager = new TypeRegistry();
typeManager.getType(parseTypeSignature("not a real type"));
fail("Expect to throw IllegalArgumentException");
}
catch (IllegalArgumentException e) {
assertTrue(e.getMessage().matches("Unknown type.*"));
}
catch (Throwable t) {
fail("Expect to throw IllegalArgumentException, got " + t.getClass());
}
}
代码示例来源:origin: apache/pulsar
@Test
public void testManagedLedgerWithoutAutoCreate() throws Exception {
ManagedLedgerConfig config = new ManagedLedgerConfig().setCreateIfMissing(false);
try {
factory.open("testManagedLedgerWithoutAutoCreate", config);
fail("should have thrown ManagedLedgerNotFoundException");
} catch (ManagedLedgerNotFoundException e) {
// Expected
}
assertFalse(factory.getManagedLedgers().containsKey("testManagedLedgerWithoutAutoCreate"));
}
代码示例来源:origin: prestodb/presto
public void assertInvalidFunction(String projection, ErrorCode errorCode)
{
try {
assertFunction(projection, UNKNOWN, null);
fail("Expected error " + errorCode + " from " + projection);
}
catch (PrestoException e) {
assertEquals(e.getErrorCode(), errorCode);
}
}
代码示例来源:origin: prestodb/presto
@Test(expectedExceptions = SQLException.class, expectedExceptionsMessageRegExp = ".* does not exist")
public void testBadQuery()
throws Exception
{
try (Connection connection = createConnection("test", "tiny")) {
try (Statement statement = connection.createStatement()) {
try (ResultSet ignored = statement.executeQuery("SELECT * FROM bad_table")) {
fail("expected exception");
}
}
}
}
代码示例来源:origin: linkedin/parseq
public void testCancelledRecover(int expectedNumberOfTasks) {
Task<Integer> cancelled = getCancelledTask().map("strlen", String::length).recover(e -> -1);
try {
runAndWait("AbstractTaskTest.testCancelledRecover", cancelled);
fail("should have failed");
} catch (Exception ex) {
assertTrue(cancelled.isFailed());
assertTrue(Exceptions.isCancellation(cancelled.getError()));
}
assertEquals(countTasks(cancelled.getTrace()), expectedNumberOfTasks);
}
代码示例来源:origin: prestodb/presto
private void assertCallFails(@Language("SQL") String sql, String message)
{
tester.reset();
try {
assertUpdate(sql);
fail("expected exception");
}
catch (RuntimeException e) {
assertFalse(tester.wasCalled());
assertEquals(e.getMessage(), message);
}
}
代码示例来源:origin: apache/incubator-gobblin
protected DistributeJobResult getResultFromUserContent() {
DistributeJobResult rst = super.getResultFromUserContent();
Assert.assertTrue(!rst.isEarlyStopped());
String jobName = this.jobPlanningProps.getProperty(ConfigurationKeys.JOB_NAME_KEY);
try {
Assert.assertFalse(this.jobsMapping.getPlanningJobId(jobName).isPresent());
} catch (Exception e) {
Assert.fail(e.toString());
}
IntegrationJobFactorySuite.completed.set(true);
return rst;
}
代码示例来源:origin: prestodb/presto
private void assertAllocationFails(Consumer<Void> allocationFunction, String expectedPattern)
{
try {
allocationFunction.accept(null);
fail("Expected exception");
}
catch (IllegalArgumentException e) {
assertTrue(Pattern.matches(expectedPattern, e.getMessage()),
"\nExpected (re) :" + expectedPattern + "\nActual :" + e.getMessage());
}
}
代码示例来源:origin: prestodb/presto
@Test
public void testExecuteStatementDoesNotExist()
{
try {
QUERY_PREPARER.prepareQuery(TEST_SESSION, "execute my_query");
fail("expected exception");
}
catch (PrestoException e) {
assertEquals(e.getErrorCode(), NOT_FOUND.toErrorCode());
}
}
代码示例来源:origin: prestodb/presto
protected static Map asMap(List keyList, List valueList)
{
if (keyList.size() != valueList.size()) {
fail("keyList should have same size with valueList");
}
Map map = new HashMap<>();
for (int i = 0; i < keyList.size(); i++) {
if (map.put(keyList.get(i), valueList.get(i)) != null) {
fail("keyList should have same size with valueList");
}
}
return map;
}
}
代码示例来源:origin: prestodb/presto
@Test(groups = {LDAP, PRESTO_JDBC, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT)
public void shouldFailQueryForLdapWithoutSsl()
{
try {
DriverManager.getConnection("jdbc:presto://" + prestoServer(), ldapUserName, ldapUserPassword);
fail();
}
catch (SQLException exception) {
assertEquals(exception.getMessage(), "Authentication using username/password requires SSL to be enabled");
}
}
代码示例来源:origin: prestodb/presto
@Test
public void createTableWhenTableIsAlreadyCreated()
{
String createTableSql = "CREATE TABLE nation as SELECT * FROM tpch.tiny.nation";
queryRunner.execute(createTableSql);
try {
queryRunner.execute(createTableSql);
fail("Expected exception to be thrown here!");
}
catch (RuntimeException ex) { // it has to RuntimeException as FailureInfo$FailureException is private
assertTrue(ex.getMessage().equals("line 1:1: Destination table 'blackhole.default.nation' already exists"));
}
finally {
assertThatQueryReturnsValue("DROP TABLE nation", true);
}
}
代码示例来源:origin: swagger-api/swagger-core
@Test(description = "it should filter away secret parameters")
public void filterAwaySecretParameters() throws IOException {
final OpenAPI openAPI = getOpenAPI(RESOURCE_PATH);
final RemoveInternalParamsFilter filter = new RemoveInternalParamsFilter();
final OpenAPI filtered = new SpecFilter().filter(openAPI, filter, null, null, null);
if (filtered.getPaths() != null) {
for (Map.Entry<String, PathItem> entry : filtered.getPaths().entrySet()) {
final Operation get = entry.getValue().getGet();
if (get != null) {
for (Parameter param : get.getParameters()) {
final String description = param.getDescription();
if (StringUtils.isNotBlank(description)) {
assertFalse(description.startsWith("secret"));
}
}
}
}
} else {
fail("paths should not be null");
}
}
代码示例来源:origin: prestodb/presto
public static void assertInvalidPath(String path)
{
try {
tokenizePath(path);
fail("Expected PrestoException");
}
catch (PrestoException e) {
assertEquals(e.getErrorCode(), INVALID_FUNCTION_ARGUMENT.toErrorCode());
}
}
代码示例来源:origin: prestodb/presto
@Test
public void testBadTable()
{
try {
new QualifiedTablePrefix("catalog", null, "table");
fail();
}
catch (RuntimeException e) {
// ok
}
}
代码示例来源:origin: prestodb/presto
protected static void assertQueryReturnsEmptyResult(QueryRunner queryRunner, Session session, @Language("SQL") String sql)
{
try {
MaterializedResult results = queryRunner.execute(session, sql).toTestTypes();
assertNotNull(results);
assertEquals(results.getRowCount(), 0);
}
catch (RuntimeException ex) {
fail("Execution of query failed: " + sql, ex);
}
}
内容来源于网络,如有侵权,请联系作者删除!