use of org.junit.jupiter.params.ParameterizedTest in project logging-log4j2 by apache.
the class JsonTemplateLayoutConcurrentEncodeTest method test_concurrent_encode.
@ParameterizedTest
@ValueSource(strings = { "dummy", "threadLocal", "queue:supplier=java.util.concurrent.ArrayBlockingQueue.new", "queue:supplier=org.jctools.queues.MpmcArrayQueue.new" })
void test_concurrent_encode(final String recyclerFactory) throws IOException {
final Path appenderFilepath = createAppenderFilepath(recyclerFactory);
final int workerCount = 10;
final int messageLength = 1_000;
final int messageCount = 1_000;
try {
withContextFromTemplate(appenderFilepath, recyclerFactory, loggerContext -> {
final Logger logger = loggerContext.getLogger(JsonTemplateLayoutConcurrentEncodeTest.class);
runWorkers(workerCount, messageLength, messageCount, logger);
});
verifyLines(appenderFilepath, messageLength, workerCount * messageCount);
} catch (final Throwable error) {
final String message = String.format("test failure for appender pointing to file: `%s`", appenderFilepath);
throw new AssertionError(message, error);
}
Files.delete(appenderFilepath);
}
use of org.junit.jupiter.params.ParameterizedTest in project logging-log4j2 by apache.
the class AsyncAppenderExceptionHandlingTest method AsyncAppender_should_not_stop_on_appender_failures.
@ParameterizedTest
@ValueSource(strings = { FailOnceAppender.ThrowableClassName.RUNTIME_EXCEPTION, FailOnceAppender.ThrowableClassName.LOGGING_EXCEPTION, FailOnceAppender.ThrowableClassName.EXCEPTION, FailOnceAppender.ThrowableClassName.ERROR, FailOnceAppender.ThrowableClassName.THROWABLE, FailOnceAppender.ThrowableClassName.THREAD_DEATH })
void AsyncAppender_should_not_stop_on_appender_failures(String throwableClassName) {
// Create the logger.
final String throwableClassNamePropertyName = "throwableClassName";
System.setProperty(throwableClassNamePropertyName, throwableClassName);
try (final LoggerContext loggerContext = Configurator.initialize("Test", "AsyncAppenderExceptionHandlingTest.xml")) {
final Logger logger = loggerContext.getRootLogger();
// Log the 1st message, which should fail due to the FailOnceAppender.
logger.info("message #1");
// Log the 2nd message, which should succeed.
final String lastLogMessage = "message #2";
logger.info(lastLogMessage);
// Stop the AsyncAppender to drain the queued events.
Configuration configuration = loggerContext.getConfiguration();
AsyncAppender asyncAppender = configuration.getAppender("Async");
Assertions.assertNotNull(asyncAppender, "couldn't obtain the FailOnceAppender");
asyncAppender.stop();
// Verify the logged message.
final FailOnceAppender failOnceAppender = configuration.getAppender("FailOnce");
Assertions.assertNotNull(failOnceAppender, "couldn't obtain the FailOnceAppender");
Assertions.assertTrue(failOnceAppender.isFailed(), "FailOnceAppender hasn't failed yet");
final List<String> accumulatedMessages = failOnceAppender.drainEvents().stream().map(LogEvent::getMessage).map(Message::getFormattedMessage).collect(Collectors.toList());
Assertions.assertEquals(Collections.singletonList(lastLogMessage), accumulatedMessages);
} finally {
System.setProperty(throwableClassNamePropertyName, Strings.EMPTY);
}
}
use of org.junit.jupiter.params.ParameterizedTest in project okhttp by square.
the class HpackRoundTripTest method testRoundTrip.
@ParameterizedTest
@ArgumentsSource(StoriesTestProvider.class)
public void testRoundTrip(Story story) throws Exception {
Assumptions.assumeFalse(story == Story.MISSING, "Test stories missing, checkout git submodule");
Story story2 = story.clone();
// Mutate cases in base class.
for (Case caze : story2.getCases()) {
hpackWriter.writeHeaders(caze.getHeaders());
caze.setWire(bytesOut.readByteString());
}
testDecoder(story2);
}
use of org.junit.jupiter.params.ParameterizedTest in project spring-security by spring-projects.
the class NimbusReactiveOpaqueTokenIntrospectorTests method handleNonJsonContentType.
@ParameterizedTest(name = "{displayName} when Content-Type={0}")
@ValueSource(strings = { MediaType.APPLICATION_CBOR_VALUE, MediaType.TEXT_MARKDOWN_VALUE, MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_OCTET_STREAM_VALUE })
public void handleNonJsonContentType(String type) {
WebClient client = mockResponse(ACTIVE_RESPONSE, type);
ReactiveOpaqueTokenIntrospector introspectionClient = new NimbusReactiveOpaqueTokenIntrospector(INTROSPECTION_URL, client);
assertThatExceptionOfType(OAuth2IntrospectionException.class).isThrownBy(() -> introspectionClient.introspect("sometokenhere").block());
}
use of org.junit.jupiter.params.ParameterizedTest in project storm by apache.
the class TopologyIntegrationTest method testBasicTopology.
@ParameterizedTest
@ValueSource(strings = { "true", "false" })
public void testBasicTopology(boolean useLocalMessaging) throws Exception {
try (LocalCluster cluster = new LocalCluster.Builder().withSimulatedTime().withSupervisors(4).withDaemonConf(Collections.singletonMap(Config.STORM_LOCAL_MODE_ZMQ, !useLocalMessaging)).build()) {
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("1", new TestWordSpout(true), 3);
builder.setBolt("2", new TestWordCounter(), 4).fieldsGrouping("1", new Fields("word"));
builder.setBolt("3", new TestGlobalCount()).globalGrouping("1");
builder.setBolt("4", new TestAggregatesCounter()).globalGrouping("2");
StormTopology topology = builder.createTopology();
Map<String, Object> stormConf = new HashMap<>();
stormConf.put(Config.TOPOLOGY_WORKERS, 2);
stormConf.put(Config.TOPOLOGY_TESTING_ALWAYS_TRY_SERIALIZE, true);
List<FixedTuple> testTuples = Arrays.asList("nathan", "bob", "joey", "nathan").stream().map(value -> new FixedTuple(new Values(value))).collect(Collectors.toList());
MockedSources mockedSources = new MockedSources(Collections.singletonMap("1", testTuples));
CompleteTopologyParam completeTopologyParams = new CompleteTopologyParam();
completeTopologyParams.setMockedSources(mockedSources);
completeTopologyParams.setStormConf(stormConf);
Map<String, List<FixedTuple>> results = Testing.completeTopology(cluster, topology, completeTopologyParams);
assertThat(Testing.readTuples(results, "1"), containsInAnyOrder(new Values("nathan"), new Values("nathan"), new Values("bob"), new Values("joey")));
assertThat(Testing.readTuples(results, "2"), containsInAnyOrder(new Values("nathan", 1), new Values("nathan", 2), new Values("bob", 1), new Values("joey", 1)));
assertThat(Testing.readTuples(results, "3"), contains(new Values(1), new Values(2), new Values(3), new Values(4)));
assertThat(Testing.readTuples(results, "4"), contains(new Values(1), new Values(2), new Values(3), new Values(4)));
}
}
Aggregations