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)]);
}
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());
}
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));
}
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);
}
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));
}
Aggregations