Search in sources :

Example 56 with ValueSource

use of org.junit.jupiter.params.provider.ValueSource in project jmeter by apache.

the class SecurityProviderLoaderTest method addSecurityProviderWithPositionTest.

@ParameterizedTest
@ValueSource(ints = { 0, 1, 2, 3 })
void addSecurityProviderWithPositionTest(int position) {
    removeAllDummyProviders();
    int providersCountBefore = Security.getProviders().length;
    SecurityProviderLoader.addSecurityProvider(DummyProvider.class.getName() + ":" + position);
    Provider[] providersAfter = Security.getProviders();
    Provider provider = Security.getProvider(DummyProvider.PROVIDER_NAME);
    Assert.assertEquals(providersCountBefore + 1, providersAfter.length);
    Assert.assertNotNull(provider);
    Assert.assertEquals(DummyProvider.class, provider.getClass());
    Assert.assertEquals(provider, providersAfter[expectedInsertPosition(position, providersAfter)]);
}
Also used : Provider(java.security.Provider) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 57 with ValueSource

use of org.junit.jupiter.params.provider.ValueSource in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class PageImplTest method testAlternateLanguageLinks.

@ParameterizedTest(name = PageImpl.PN_STYLE_RENDER_ALTERNATE_LANGUAGE_LINKS + " = {0}")
@ValueSource(strings = { "true", "false" })
public void testAlternateLanguageLinks(String renderProperty) {
    context.registerAdapter(Resource.class, SeoTags.class, (Function<Resource, SeoTags>) resource -> {
        SeoTags seoTags = mock(SeoTags.class, "seoTags of " + resource.getPath());
        Map<Locale, String> expectedAlternates = ImmutableMap.of(Locale.ENGLISH, "http://foo.bar/content/en/templated-page", Locale.GERMAN, "http://foo.bar/content/de/templated-page");
        when(seoTags.getAlternateLanguages()).thenReturn(expectedAlternates);
        return seoTags;
    });
    boolean renderAlternateLanguages = Boolean.parseBoolean(renderProperty);
    Page page = getPageUnderTest(PAGE, PageImpl.PN_STYLE_RENDER_ALTERNATE_LANGUAGE_LINKS, renderProperty);
    Map<Locale, String> alternateLanguageLinks = page.getAlternateLanguageLinks();
    if (renderAlternateLanguages) {
        assertEquals(2, alternateLanguageLinks.size());
        assertEquals("http://foo.bar/content/en/templated-page", page.getAlternateLanguageLinks().get(Locale.ENGLISH));
        assertEquals("http://foo.bar/content/de/templated-page", page.getAlternateLanguageLinks().get(Locale.GERMAN));
    } else {
        assertTrue(alternateLanguageLinks.isEmpty());
    }
    // assert that the returned object is cached by the instance
    assertSame(alternateLanguageLinks, page.getAlternateLanguageLinks());
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) ClientLibrary(com.adobe.granite.ui.clientlibs.ClientLibrary) Arrays(java.util.Arrays) Constants(org.osgi.framework.Constants) MockPersistenceStrategy(com.adobe.cq.wcm.core.components.testing.MockPersistenceStrategy) SimpleDateFormat(java.text.SimpleDateFormat) Page(com.adobe.cq.wcm.core.components.models.Page) HashMap(java.util.HashMap) Function(java.util.function.Function) Mockito.lenient(org.mockito.Mockito.lenient) HashSet(java.util.HashSet) Mockito.doThrow(org.mockito.Mockito.doThrow) Calendar(java.util.Calendar) NavigationItem(com.adobe.cq.wcm.core.components.models.NavigationItem) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) Locale(java.util.Locale) Utils.testJSONExport(com.adobe.cq.wcm.core.components.Utils.testJSONExport) Map(java.util.Map) Utils.getTestExporterJSONPath(com.adobe.cq.wcm.core.components.Utils.getTestExporterJSONPath) SeoTags(com.adobe.aem.wcm.seo.SeoTags) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) ParseException(java.text.ParseException) MockHtmlLibraryManager(com.adobe.cq.wcm.core.components.testing.MockHtmlLibraryManager) MockProductInfoProvider(com.adobe.cq.wcm.core.components.testing.MockProductInfoProvider) ValueSource(org.junit.jupiter.params.provider.ValueSource) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) ImmutableMap(com.google.common.collect.ImmutableMap) CoreMatchers.hasItems(org.hamcrest.CoreMatchers.hasItems) Utils(com.adobe.cq.wcm.core.components.testing.Utils) Set(java.util.Set) Resource(org.apache.sling.api.resource.Resource) AemContextExtension(io.wcm.testing.mock.aem.junit5.AemContextExtension) Mockito.when(org.mockito.Mockito.when) Version(org.osgi.framework.Version) MockContextAwareConfig(org.apache.sling.testing.mock.caconfig.MockContextAwareConfig) Test(org.junit.jupiter.api.Test) Mockito(org.mockito.Mockito) List(java.util.List) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) HtmlPageItemsConfig(com.adobe.cq.wcm.core.components.config.HtmlPageItemsConfig) HtmlPageItem(com.adobe.cq.wcm.core.components.models.HtmlPageItem) Assertions(org.junit.jupiter.api.Assertions) Collections(java.util.Collections) Mockito.mock(org.mockito.Mockito.mock) Locale(java.util.Locale) SeoTags(com.adobe.aem.wcm.seo.SeoTags) Resource(org.apache.sling.api.resource.Resource) Page(com.adobe.cq.wcm.core.components.models.Page) HashMap(java.util.HashMap) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 58 with ValueSource

use of org.junit.jupiter.params.provider.ValueSource in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class LinkHandlerTest method testResourceExternalLinkWithInvalidTargets.

@ParameterizedTest
@ValueSource(strings = { "_self", "_invalid" })
void testResourceExternalLinkWithInvalidTargets(String target) {
    Resource linkResource = context.create().resource(page, "link", PN_LINK_URL, "http://myhost", PN_LINK_TARGET, target);
    Optional<Link> link = underTest.getLink(linkResource);
    // invalid target or _self target should be stripped away
    assertValidLink(link.get(), "http://myhost");
    assertNull(link.map(Link::getReference).orElse(null));
}
Also used : Resource(org.apache.sling.api.resource.Resource) Link(com.adobe.cq.wcm.core.components.commons.link.Link) LinkTestUtils.assertValidLink(com.adobe.cq.wcm.core.components.internal.link.LinkTestUtils.assertValidLink) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 59 with ValueSource

use of org.junit.jupiter.params.provider.ValueSource in project jetcd by coreos.

the class WatchErrorTest method testWatchOnError.

@ParameterizedTest
@ValueSource(strings = { "test-namespace/", "" })
public void testWatchOnError(String ns) {
    final Client client = ns != null && ns.length() == 0 ? TestUtil.client(cluster).namespace(bytesOf(ns)).build() : TestUtil.client(cluster).build();
    final ByteSequence key = randomByteSequence();
    final List<Throwable> events = Collections.synchronizedList(new ArrayList<>());
    try (Watcher watcher = client.getWatchClient().watch(key, TestUtil::noOpWatchResponseConsumer, events::add)) {
        cluster.cluster().stop();
        await().atMost(15, TimeUnit.SECONDS).untilAsserted(() -> assertThat(events).isNotEmpty());
    }
    assertThat(events).allMatch(EtcdException.class::isInstance);
}
Also used : Watcher(io.etcd.jetcd.Watch.Watcher) Client(io.etcd.jetcd.Client) EtcdException(io.etcd.jetcd.common.exception.EtcdException) TestUtil.randomByteSequence(io.etcd.jetcd.impl.TestUtil.randomByteSequence) ByteSequence(io.etcd.jetcd.ByteSequence) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 60 with ValueSource

use of org.junit.jupiter.params.provider.ValueSource in project dhis2-core by dhis2.

the class UserAssignmentTests method shouldBeEnabledOnProgramStage.

@ParameterizedTest
@ValueSource(strings = { "WITHOUT_REGISTRATION", "WITH_REGISTRATION" })
public void shouldBeEnabledOnProgramStage(String programType) {
    // arrange
    String programId = programActions.get("?filter=programStages:ge:1&filter=programType:eq:" + programType).extractString("programs.id[0]");
    String programStageId = programActions.get(programId).extractString("programStages.id[0]");
    // act - enabling user assignment
    ApiResponse response = programActions.programStageActions.enableUserAssignment(programStageId, true);
    // assert
    ResponseValidationHelper.validateObjectUpdate(response, 200);
    response = programActions.programStageActions.get(programStageId);
    response.validate().statusCode(200).body(userAssignmentProperty, equalTo(true));
    // act - disabling user assignment
    response = programActions.programStageActions.enableUserAssignment(programStageId, false);
    // assert
    ResponseValidationHelper.validateObjectUpdate(response, 200);
    response = programActions.programStageActions.get(programStageId);
    response.validate().statusCode(200).body(userAssignmentProperty, equalTo(false));
}
Also used : ApiResponse(org.hisp.dhis.dto.ApiResponse) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)266 ValueSource (org.junit.jupiter.params.provider.ValueSource)266 HashSet (java.util.HashSet)23 HistogramTestUtils.constructDoubleHistogram (org.HdrHistogram.HistogramTestUtils.constructDoubleHistogram)23 ArrayList (java.util.ArrayList)22 HashMap (java.util.HashMap)20 ApiResponse (org.hisp.dhis.dto.ApiResponse)15 UpdateModel (com.synopsys.integration.alert.update.model.UpdateModel)13 File (java.io.File)13 List (java.util.List)13 OffsetDateTime (java.time.OffsetDateTime)10 Map (java.util.Map)10 TimeUnit (java.util.concurrent.TimeUnit)10 TopicPartition (org.apache.kafka.common.TopicPartition)9 ListenerSubscribeMessage (io.nem.symbol.sdk.infrastructure.ListenerSubscribeMessage)8 UnresolvedAddress (io.nem.symbol.sdk.model.account.UnresolvedAddress)8 ZooKeeper (org.apache.zookeeper.ZooKeeper)8 JsonObject (com.google.gson.JsonObject)7 IOException (java.io.IOException)7 CountDownLatch (java.util.concurrent.CountDownLatch)7