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


Java Assertions.fail方法代码示例

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


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

示例1: failingStoreTests

import org.assertj.core.api.Assertions; //导入方法依赖的package包/类
@Test(dataProvider = "failingStoreTests", timeOut = 30_000)
public void failingStoreTests(FailingStoreTest storeTest) throws Exception {
    String storeName = storeTest.getClass().getSimpleName();

    // execute and check in the same store execution, no final snapshot
    try (StoreManager storeManager = createStoreManager(storeTest, storeName)) {
        Store store = storeManager.getStore();
        storeTest.provision(store);
        try {
            storeTest.execute(store);
            Assertions.fail("Test %s didn't failed", storeTest.getClass().getName());
        } catch (Exception e) {
            System.out.println(String.format("Test %s failed as expected, with message: %s", store.getClass().getName(), e.getMessage()));
        }

        //TODO check that store has not been modified
    }
}
 
开发者ID:Axway,项目名称:iron,代码行数:19,代码来源:AbstractStoreTests.java

示例2: isAWellDefinedUtilityClass

import org.assertj.core.api.Assertions; //导入方法依赖的package包/类
public UtilityClassAssertions isAWellDefinedUtilityClass() {
	Assertions.assertThat(Modifier.isFinal(actual.getModifiers())).describedAs("A utility class should be marked as final.").isTrue();
	Assertions.assertThat(actual.getDeclaredConstructors().length).describedAs("A utility class should only have one constructor, but this class has " + actual.getDeclaredConstructors().length).isEqualTo(1);

	try {
		Constructor<?> constructor = actual.getDeclaredConstructor();
		if (constructor.isAccessible() || !Modifier.isPrivate(constructor.getModifiers())) {
			Assertions.fail("The constructor is not private.");
		}

		constructor.setAccessible(true);
		constructor.newInstance();
		constructor.setAccessible(false);

		for (Method method : actual.getMethods()) {
			if (!Modifier.isStatic(method.getModifiers()) && method.getDeclaringClass().equals(actual)) {
				Assertions.fail("A utility class should not have instance methods, but found: " + method);
			}
		}
	}
	catch (Exception e) {
		Assertions.fail("An error occurred while inspecting the class.");
	}

	return this;
}
 
开发者ID:PatternFM,项目名称:tokamak,代码行数:27,代码来源:UtilityClassAssertions.java

示例3: assertGithubRepositoryFindByName

import org.assertj.core.api.Assertions; //导入方法依赖的package包/类
public static GitRepositoryConfig assertGithubRepositoryFindByName(RepositoryConfig repositoryConfig, String repoName) {
    GitHubProjects github = repositoryConfig.getGithub();
    assertThat(github).describedAs("github").isNotNull();

    List<GithubOrganisation> organisations = github.getOrganisations();
    assertThat(organisations).describedAs("github organisations").isNotNull();
    for (GithubOrganisation organisation : organisations) {
        List<GitRepositoryConfig> repositories = organisation.getRepositories();
        for (GitRepositoryConfig repository : repositories) {
            if (repoName.equals(repository.getName())) {
                return repository;
            }
        }
    }
    Assertions.fail("Could not find github repository called " + repoName + " in project: " + github);
    return null;
}
 
开发者ID:fabric8-updatebot,项目名称:updatebot,代码行数:18,代码来源:Tests.java

示例4: snitchErrorShouldThrowSnitchingException

import org.assertj.core.api.Assertions; //导入方法依赖的package包/类
@Test
public void snitchErrorShouldThrowSnitchingException() throws IOException {
    String uri = "http://cereebro.io";
    String json = "{ \"error\" : true }";
    metadata.put(CereebroMetadata.KEY_SNITCH_URI, uri);
    metadata.put(CereebroMetadata.KEY_SNITCH_SYSTEM_FRAGMENT_JSON, json);
    Mockito.when(objectMapperMock.readValue(json, SystemFragment.class)).thenThrow(new IOException("unit test"));
    ServiceInstanceSnitch snitch = new ServiceInstanceSnitch(objectMapperMock, serviceInstanceMock);
    try {
        snitch.snitch();
        Assertions.fail("Expected IOException");
    } catch (SnitchingException e) {
        Assertions.assertThat(e.getSnitchUri()).isEqualTo(URI.create(uri));
    }
}
 
开发者ID:cereebro,项目名称:cereebro,代码行数:16,代码来源:ServiceInstanceSnitchTest.java

示例5: withError

import org.assertj.core.api.Assertions; //导入方法依赖的package包/类
public ResultAssertions withError(Integer http, String code, String message) {
	for (ErrorRepresentation error : actual.getErrors()) {
		if (actual.getResponseCode().equals(http) && error.getCode().equals(code) && error.getMessage().equals(message)) {
			return this;
		}
	}

	String errors = actual.getErrors().stream().map(error -> error.toString()).collect(Collectors.joining(","));
	Assertions.fail("Unable to find an error with http response code '" + http + "', code '" + code + "' and message '" + message + "'. Errors are: " + errors);
	return this;
}
 
开发者ID:PatternFM,项目名称:tokamak,代码行数:12,代码来源:ResultAssertions.java

示例6: withError

import org.assertj.core.api.Assertions; //导入方法依赖的package包/类
public ResultAssertions withError(String code, String message, Class<? extends ReportableException> exception) {
    for (Reportable error : actual.getErrors()) {
        if (error.getCode().equals(code) && error.getMessage().equals(message) && error.getException().equals(exception)) {
            return this;
        }
    }

    String errors = actual.getErrors().stream().map(error -> error.toString()).collect(Collectors.joining(","));
    Assertions.fail("Unable to find an error with code '" + code + "', message '" + message + "' and class '" + exception.getCanonicalName() + "'. Errors are: " + errors);
    return this;
}
 
开发者ID:PatternFM,项目名称:tokamak,代码行数:12,代码来源:ResultAssertions.java

示例7: failSoftly

import org.assertj.core.api.Assertions; //导入方法依赖的package包/类
private void failSoftly(String logLine){
	if (softly == null) {
		LOGGER.error(logLine);
		Assertions.fail(logLine);
	} else {
		softly.assertThat(logLine).isEmpty();
	}
}
 
开发者ID:xtf-cz,项目名称:xtf,代码行数:9,代码来源:LogChecker.java

示例8: samlRequestIsBase64EncodedAuthnRequest

import org.assertj.core.api.Assertions; //导入方法依赖的package包/类
@Test
public void samlRequestIsBase64EncodedAuthnRequest() {
    when(authnRequestFactory.build(any(), eq(defaultEntityId))).thenReturn(authnRequest);
    RequestResponseBody requestResponseBody = generateRequest();
    try {
        Base64.getDecoder().decode(requestResponseBody.getSamlRequest());
    } catch (IllegalArgumentException e) {
        Assertions.fail("Expected samlRequest to be Base64 encoded");
    }
}
 
开发者ID:alphagov,项目名称:verify-service-provider,代码行数:11,代码来源:GenerateAuthnRequestResourceTest.java

示例9: testExpiringConcurrentCachingFetcherWrapper

import org.assertj.core.api.Assertions; //导入方法依赖的package包/类
public void testExpiringConcurrentCachingFetcherWrapper() {

    final int maxTimeMs = 500;

    final AtomicInteger count = new AtomicInteger(0);

    final Fetcher<Integer> expire = Fetchers.getExpiringMultiConcurrentFetcher(maxTimeMs,
      () -> count.incrementAndGet());

    try {

      Assertions.assertThat(expire.fetch()).isEqualTo(1);
      Assertions.assertThat(expire.fetch()).isEqualTo(1);
      Assertions.assertThat(expire.fetch()).isEqualTo(1);
      Assertions.assertThat(expire.fetch()).isEqualTo(1);

      Thread.sleep(maxTimeMs + 5);

      Assertions.assertThat(expire.fetch()).isEqualTo(2);
      Assertions.assertThat(expire.fetch()).isEqualTo(2);
      Assertions.assertThat(expire.fetch()).isEqualTo(2);
      Assertions.assertThat(expire.fetch()).isEqualTo(2);

      Thread.sleep(maxTimeMs + 5);

      Assertions.assertThat(expire.fetch()).isEqualTo(3);
      Assertions.assertThat(expire.fetch()).isEqualTo(3);
      Assertions.assertThat(expire.fetch()).isEqualTo(3);
      Assertions.assertThat(expire.fetch()).isEqualTo(3);
      Assertions.assertThat(expire.fetch()).isEqualTo(3);

      Thread.sleep(maxTimeMs * 5);

      Assertions.assertThat(expire.fetch()).isEqualTo(4);
      Assertions.assertThat(expire.fetch()).isEqualTo(4);
      Assertions.assertThat(expire.fetch()).isEqualTo(4);

    }
    catch (FetcherException | InterruptedException e) {
      Assertions.fail(e.getMessage());
    }

  }
 
开发者ID:lieuu,项目名称:fetcher-framework,代码行数:44,代码来源:ExpiringMultiConcurrentFetcherTest.java

示例10: testExpiringCachingFetcherWrapper

import org.assertj.core.api.Assertions; //导入方法依赖的package包/类
@Test
public void testExpiringCachingFetcherWrapper() {

  final AtomicInteger count = new AtomicInteger(0);

  final Fetcher<Integer> cachingFetcher = Fetchers.getExpiringCachingFetcher(
    () -> count.incrementAndGet(), 50);

  try {

    Thread.sleep(200);

    Assertions.assertThat(cachingFetcher.fetch()).isEqualTo(1);

    Thread.sleep(200);

    Assertions.assertThat(cachingFetcher.fetch()).isEqualTo(2);

    Thread.sleep(200);

    Assertions.assertThat(cachingFetcher.fetch()).isEqualTo(3);

    Thread.sleep(200);

    Assertions.assertThat(cachingFetcher.fetch()).isEqualTo(4);
    Assertions.assertThat(cachingFetcher.fetch()).isEqualTo(4);

  }
  catch (FetcherException | InterruptedException e) {
    Assertions.fail(e.getMessage());
  }

}
 
开发者ID:lieuu,项目名称:fetcher-framework,代码行数:34,代码来源:ExpiringCachingFetcherTest.java


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