类org.junit.jupiter.params.provider.EnumSource.Mode源码实例Demo

下面列出了怎么用org.junit.jupiter.params.provider.EnumSource.Mode的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: armeria   文件: Http1EmptyRequestTest.java
@ParameterizedTest
@EnumSource(value = HttpMethod.class, mode = Mode.EXCLUDE, names = "UNKNOWN")
void emptyRequest(HttpMethod method) throws Exception {
    try (ServerSocket ss = new ServerSocket(0)) {
        final int port = ss.getLocalPort();

        final WebClient client = WebClient.of("h1c://127.0.0.1:" + port);
        client.execute(HttpRequest.of(method, "/")).aggregate();

        try (Socket s = ss.accept()) {
            final BufferedReader in = new BufferedReader(
                    new InputStreamReader(s.getInputStream(), StandardCharsets.US_ASCII));
            assertThat(in.readLine()).isEqualTo(method.name() + " / HTTP/1.1");
            assertThat(in.readLine()).startsWith("host: 127.0.0.1:");
            assertThat(in.readLine()).startsWith("user-agent: armeria/");
            if (hasContent(method)) {
                assertThat(in.readLine()).isEqualTo("content-length: 0");
            }
            assertThat(in.readLine()).isEmpty();
        }
    }
}
 
源代码2 项目: armeria   文件: HttpClientRequestPathTest.java
@ParameterizedTest
@EnumSource(value = SessionProtocol.class, mode = Mode.EXCLUDE, names = { "HTTP", "HTTPS", "PROXY"})
void default_withRetryClient(SessionProtocol protocol) {
    final HttpRequest request = HttpRequest.of(HttpMethod.GET, server2.uri(protocol) + "/retry");
    final WebClient client = WebClient.builder()
                                      .decorator(RetryingClient.newDecorator(RetryRule.failsafe()))
                                      .factory(ClientFactory.insecure())
                                      .build();
    try (ClientRequestContextCaptor captor = Clients.newContextCaptor()) {
        client.execute(request).aggregate().join();
        final ClientRequestContext ctx = captor.get();
        assertThat(ctx.sessionProtocol()).isEqualTo(protocol);
        for (RequestLogAccess child : ctx.log().partial().children()) {
            assertThat(child.partial().sessionProtocol()).isEqualTo(protocol);
        }
    }
}
 
源代码3 项目: vividus   文件: SftpCommandTests.java
@ParameterizedTest
@EnumSource(value = SftpCommand.class, mode = Mode.EXCLUDE, names = {"PUT", "PUT_FROM_FILE"})
void shouldNotSupportTwoParameters(SftpCommand command)
{
    shouldNotSupportUnexpectedParameters(command, "Command %s doesn't support two parameters",
            PARAM_1, PARAM_2);
}
 
源代码4 项目: vividus   文件: CookieStoreProviderTests.java
@ParameterizedTest
@EnumSource(names = "SCENARIO", mode = Mode.EXCLUDE)
void shouldNotClearCookieStoreAfterScenario(CookieStoreLevel cookieStoreLevel)
{
    CookieStoreProvider cookieStoreProvider = createProviderWithCookie(cookieStoreLevel);
    cookieStoreProvider.resetScenarioCookies();
    assertEquals(List.of(COOKIE), cookieStoreProvider.getCookieStore().getCookies());
}
 
源代码5 项目: vividus   文件: CookieStoreProviderTests.java
@ParameterizedTest
@EnumSource(names = "STORY", mode = Mode.EXCLUDE)
void shouldNotClearCookieStoreAfterStory(CookieStoreLevel cookieStoreLevel)
{
    CookieStoreProvider cookieStoreProvider = createProviderWithCookie(cookieStoreLevel);
    cookieStoreProvider.resetStoryCookies();
    assertEquals(List.of(COOKIE), cookieStoreProvider.getCookieStore().getCookies());
}
 
源代码6 项目: vividus   文件: BddVariableContextTests.java
@ParameterizedTest
@EnumSource(value = VariableScope.class, mode = Mode.EXCLUDE, names = {"NEXT_BATCHES", "GLOBAL"})
void testPutVariable(VariableScope variableScope)
{
    bddVariableContext.setTestContext(new SimpleTestContext());
    Variables variables = new Variables();
    when(variablesFactory.createVariables()).thenReturn(variables);
    bddVariableContext.putVariable(variableScope, VARIABLE_KEY, VALUE);
    verifyScopedVariable(variableScope, variables);
    assertThat(logger.getLoggingEvents(), equalTo(List.of(
            info(SAVE_MESSAGE_TEMPLATE, VALUE, variableScope, VARIABLE_KEY))));
}
 
源代码7 项目: ari-proxy   文件: AriCommandTypeTest.java
@ParameterizedTest
@EnumSource(value = AriCommandType.class, mode = Mode.EXCLUDE, names = {"COMMAND_NOT_CREATING_A_NEW_RESOURCE"})
void ensureInvalidUriAndBodyResultInAFailure(AriCommandType type) {
	assertAll(
			String.format("Extractors for type=%s", type),
			() -> assertThat(type.extractResourceIdFromUri(INVALID_COMMAND_URI).get(), instanceOf(Failure.class)),
			() -> assertThat(type.extractResourceIdFromBody(INVALID_COMMAND_BODY).get(), instanceOf(Failure.class))
	);
}
 
源代码8 项目: ari-proxy   文件: AriEventProcessingTest.java
@ParameterizedTest
@EnumSource(value = AriMessageType.class, mode = Mode.EXCLUDE, names = {"STASIS_START", "STASIS_END"})
void verifyNoMetricsAreGatheredForTheSpecifiedEventTypes(AriMessageType type) {
	final Seq<MetricsGatherer> decision = AriEventProcessing
			.determineMetricsGatherer(type);

	assertThat(
			((IncreaseCounter) decision.get(0).withCallContextSupplier(() -> "CALL_CONTEXT")).getName(),
			is(type.name())
	);
}
 
源代码9 项目: armeria   文件: HttpClientRequestPathTest.java
@ParameterizedTest
@EnumSource(value = HttpMethod.class, mode = Mode.EXCLUDE, names = "UNKNOWN")
void default_withAbsolutePath(HttpMethod method) {
    final HttpRequest request = HttpRequest.of(method, server2.httpUri() + "/simple-client");
    final HttpResponse response = WebClient.of().execute(request);
    assertThat(response.aggregate().join().status()).isEqualTo(OK);
}
 
源代码10 项目: armeria   文件: HttpClientRequestPathTest.java
@ParameterizedTest
@EnumSource(value = SessionProtocol.class, mode = Mode.EXCLUDE, names = "PROXY")
void default_withScheme(SessionProtocol protocol) {
    final HttpRequest request = HttpRequest.of(HttpMethod.GET, server2.uri(protocol) + "/simple-client");
    try (ClientRequestContextCaptor captor = Clients.newContextCaptor()) {
        final WebClient client = WebClient.builder().factory(ClientFactory.insecure()).build();
        final HttpResponse response = client.execute(request);
        final ClientRequestContext ctx = captor.get();
        assertThat(ctx.sessionProtocol()).isEqualTo(protocol);
        assertThat(response.aggregate().join().status()).isEqualTo(OK);
    }
}
 
源代码11 项目: armeria   文件: AbstractPooledHttpServiceTest.java
@ParameterizedTest
@EnumSource(value = HttpMethod.class, mode = Mode.EXCLUDE, names = {"CONNECT", "UNKNOWN"})
void implemented(HttpMethod method) {
    final AggregatedHttpResponse response = client.execute(HttpRequest.of(method, "/implemented"))
                                                  .aggregate().join();
    assertThat(response.status()).isEqualTo(HttpStatus.OK);
    // HEAD responses content stripped out by framework.
    if (method != HttpMethod.HEAD) {
        assertThat(response.contentUtf8()).isEqualTo(method.name().toLowerCase());
    }
}
 
源代码12 项目: cloudbreak   文件: FreeIpaCreationHandlerTest.java
@ParameterizedTest
@EnumSource(value = PollingResult.class, names = "SUCCESS", mode = Mode.EXCLUDE)
public void testIfFreeIpaPollingServiceReturnsWithUnsuccessfulResultThenCreationFailedEventShouldBeSent(PollingResult pollingResult) {
    EnvironmentDto environmentDto = someEnvironmentWithFreeIpaCreation();
    Environment environment = mock(Environment.class);

    when(environment.getCloudPlatform()).thenReturn(environmentDto.getCloudPlatform());
    when(environment.isCreateFreeIpa()).thenReturn(environmentDto.getFreeIpaCreation().getCreate());

    Pair<PollingResult, Exception> result = mock(Pair.class);

    when(result.getKey()).thenReturn(pollingResult);

    when(environmentService.findEnvironmentById(environmentDto.getId())).thenReturn(Optional.of(environment));
    when(supportedPlatforms.supportedPlatformForFreeIpa(environmentDto.getCloudPlatform())).thenReturn(true);
    when(connectors.getDefault(any())).thenReturn(mock(CloudConnector.class));
    when(freeIpaPollingService.pollWithTimeout(
            any(FreeIpaCreationRetrievalTask.class),
            any(FreeIpaPollerObject.class),
            anyLong(),
            anyInt(),
            anyInt()))
            .thenReturn(result);

    victim.accept(new Event<>(environmentDto));

    verify(eventBus).notify(anyString(), any(Event.class));

    verify(environmentService, times(1)).findEnvironmentById(anyLong());
    verify(environmentService, times(1)).findEnvironmentById(environmentDto.getId());
    verify(supportedPlatforms, times(1)).supportedPlatformForFreeIpa(anyString());
    verify(supportedPlatforms, times(1)).supportedPlatformForFreeIpa(environmentDto.getCloudPlatform());
    verify(freeIpaPollingService, times(1)).pollWithTimeout(
            any(FreeIpaCreationRetrievalTask.class),
            any(FreeIpaPollerObject.class),
            anyLong(),
            anyInt(),
            anyInt());
}
 
源代码13 项目: vividus   文件: VividusLabelTests.java
@ParameterizedTest
@EnumSource(names = {"SEVERITY", "EPIC", "FEATURE"}, mode = Mode.INCLUDE)
void shouldNotCreateLink(VividusLabel vividusLabel)
{
    assertEquals(Optional.empty(), vividusLabel.createLink("any"));
}
 
源代码14 项目: vividus   文件: SftpCommandTests.java
@ParameterizedTest
@EnumSource(value = SftpCommand.class, mode = Mode.EXCLUDE, names = "PWD")
void shouldNotSupportZeroParameters(SftpCommand command)
{
    shouldNotSupportUnexpectedParameters(command, "Command %s requires parameter(s)");
}
 
源代码15 项目: vividus   文件: SftpCommandTests.java
@ParameterizedTest
@EnumSource(value = SftpCommand.class, mode = Mode.INCLUDE, names = { "PWD", "PUT" })
void shouldNotSupportSingleParameter(SftpCommand command)
{
    shouldNotSupportUnexpectedParameters(command, "Command %s doesn't support single parameter", PARAM_1);
}
 
源代码16 项目: ari-proxy   文件: AriMessageTypeTest.java
@ParameterizedTest
@EnumSource(value = AriMessageType.class, mode = Mode.INCLUDE, names = { "APPLICATION_REPLACED" })
void ensureMessageTypesWithoutAnExtractorResultInANone(AriMessageType type) {
	assertThat(type.extractResourceIdFromBody(mock(JsonNode.class)), is(None()));
}
 
源代码17 项目: salespoint   文件: QuantityUnitTests.java
@ParameterizedTest(name = " 0 {0} is not compatible with unit") // #163
@EnumSource(value = Metric.class, names = "UNIT", mode = Mode.EXCLUDE)
void zeroMetricIsNotCompatibleWithAnyOther(Metric metric) {
	assertThat(Quantity.of(0, metric).isCompatibleWith(Metric.UNIT)).isFalse();
}
 
 类所在包
 类方法
 同包方法