org.junit.jupiter.api.TestInfo Java Examples
The following examples show how to use
org.junit.jupiter.api.TestInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractDownloaderTest.java From hedera-mirror-node with Apache License 2.0 | 7 votes |
@BeforeEach void beforeEach(TestInfo testInfo) { System.out.println("Before test: " + testInfo.getTestMethod().get().getName()); initProperties(); s3AsyncClient = new MirrorImporterConfiguration( null, commonDownloaderProperties, new MetricsExecutionInterceptor(meterRegistry)) .s3CloudStorageClient(); networkAddressBook = new NetworkAddressBook(mirrorProperties); downloader = getDownloader(); fileCopier = FileCopier.create(Utility.getResource("data").toPath(), s3Path) .from(getTestDataDir()) .to(commonDownloaderProperties.getBucketName(), downloaderProperties.getStreamType().getPath()); validPath = downloaderProperties.getValidPath(); s3 = S3Mock.create(S3_MOCK_PORT, s3Path.toString()); s3.start(); }
Example #2
Source File: ZookeeperUpgradeST.java From strimzi-kafka-operator with Apache License 2.0 | 6 votes |
@Test void testKafkaClusterUpgrade(TestInfo testinfo) { List<TestKafkaVersion> sortedVersions = TestKafkaVersion.getKafkaVersions(); for (int x = 0; x < sortedVersions.size() - 1; x++) { TestKafkaVersion initialVersion = sortedVersions.get(x); TestKafkaVersion newVersion = sortedVersions.get(x + 1); runVersionChange(initialVersion, newVersion, 3, 3, testinfo); } // ############################## // Validate that continuous clients finished successfully // ############################## ClientUtils.waitTillContinuousClientsFinish(producerName, consumerName, NAMESPACE, continuousClientsMessageCount); // ############################## }
Example #3
Source File: TestBotTests.java From skara with GNU General Public License v2.0 | 6 votes |
@Test void noTestCommentShouldDoNothing(TestInfo testInfo) throws IOException { try (var credentials = new HostCredentials(testInfo); var tmp = new TemporaryDirectory()) { var upstreamHostedRepo = credentials.getHostedRepository(); var personalHostedRepo = credentials.getHostedRepository(); var pr = personalHostedRepo.createPullRequest(upstreamHostedRepo, "master", "master", "Title", List.of("body")); var comments = pr.comments(); assertEquals(0, comments.size()); var storage = tmp.path().resolve("storage"); var ci = new InMemoryContinuousIntegration(); var bot = new TestBot(ci, "0", List.of(), List.of(), "", storage, upstreamHostedRepo); var runner = new TestBotRunner(); runner.runPeriodicItems(bot); comments = pr.comments(); assertEquals(0, comments.size()); } }
Example #4
Source File: ClusterTest.java From aeron with Apache License 2.0 | 6 votes |
@Test @Timeout(40) public void shouldStopLeaderAndRestartAsFollower(final TestInfo testInfo) { cluster = startThreeNodeStaticCluster(NULL_VALUE); try { final TestNode originalLeader = cluster.awaitLeader(); cluster.stopNode(originalLeader); cluster.awaitLeader(originalLeader.index()); final TestNode follower = cluster.startStaticNode(originalLeader.index(), false); awaitElectionClosed(follower); assertEquals(FOLLOWER, follower.role()); } catch (final Throwable ex) { cluster.dumpData(testInfo); LangUtil.rethrowUnchecked(ex); } }
Example #5
Source File: ClusterTest.java From aeron with Apache License 2.0 | 6 votes |
@Test @Timeout(30) public void shouldStopFollowerAndRestartFollower(final TestInfo testInfo) { cluster = startThreeNodeStaticCluster(NULL_VALUE); try { cluster.awaitLeader(); TestNode follower = cluster.followers().get(0); awaitElectionClosed(follower); cluster.stopNode(follower); Tests.sleep(1_000); // wait until existing replay can be cleaned up by conductor. follower = cluster.startStaticNode(follower.index(), false); awaitElectionClosed(follower); assertEquals(FOLLOWER, follower.role()); } catch (final Throwable ex) { cluster.dumpData(testInfo); LangUtil.rethrowUnchecked(ex); } }
Example #6
Source File: JobTest.java From component-runtime with Apache License 2.0 | 6 votes |
@Test void respectMaxRecordsSize(final TestInfo info, @TempDir final Path temporaryFolder) { final String testName = info.getTestMethod().get().getName(); final String plugin = testName + ".jar"; final File jar = pluginGenerator.createChainPlugin(temporaryFolder.toFile(), plugin); try (final ComponentManager manager = newTestManager(jar)) { Job .components() .component("countdown", "lifecycle://countdown?__version=1&start=5") .component("square", "lifecycle://square?__version=1") .connections() .from("countdown") .to("square") .build() .property("streaming.maxRecords", "2") .run(); final LocalPartitionMapper mapper = LocalPartitionMapper.class.cast(manager.findMapper("lifecycle", "countdown", 1, emptyMap()).get()); assertEquals(asList("start", "produce(4)", "produce(3)", "stop"), ((Supplier<List<String>>) mapper.getDelegate()).get()); } }
Example #7
Source File: HttpTestBase.java From hono with Eclipse Public License 2.0 | 6 votes |
/** * Sets up the fixture. * * @param testInfo Meta info about the test being run. */ @BeforeEach public void setUp(final TestInfo testInfo) { testStartTimeMillis = System.currentTimeMillis(); logger.info("running {}", testInfo.getDisplayName()); logger.info("using HTTP adapter [host: {}, http port: {}, https port: {}]", IntegrationTestSupport.HTTP_HOST, IntegrationTestSupport.HTTP_PORT, IntegrationTestSupport.HTTPS_PORT); deviceCert = SelfSignedCertificate.create(UUID.randomUUID().toString()); httpClient = new CrudHttpClient(VERTX, new HttpClientOptions(defaultOptions)); httpClientWithClientCert = new CrudHttpClient(VERTX, new HttpClientOptions(defaultOptions) .setKeyCertOptions(deviceCert.keyCertOptions())); tenantId = helper.getRandomTenantId(); deviceId = helper.getRandomDeviceId(tenantId); authorization = getBasicAuth(tenantId, deviceId, PWD); }
Example #8
Source File: PrefixedIntegrationTest.java From exonum-java-binding with Apache License 2.0 | 6 votes |
@BeforeEach void initializeDatabase(TestInfo info) throws CloseFailuresException { // Create the database cleaner = new Cleaner(info.getDisplayName()); db = TemporaryDb.newInstance(); cleaner.add(db::close); // Initialize the test index try (Cleaner initCleaner = new Cleaner()) { Fork fork = db.createFork(initCleaner); String fullName = namespace + "." + entryName; // Initialize the index ProofEntryIndex<String> e1 = fork.getProofEntry(IndexAddress.valueOf(fullName), string()); String value = "V1"; e1.set(value); // Merge into the DB db.merge(fork); } }
Example #9
Source File: DitaDocumentationGeneratorTest.java From component-runtime with Apache License 2.0 | 6 votes |
@Test void generateDitaConds(@TempDir final File temporaryFolder, final TestInfo info) throws IOException { final File output = new File(temporaryFolder, info.getTestMethod().get().getName() + ".zip"); new DitaDocumentationGenerator(new File[] { copyBinaries("org.talend.test.activeif", temporaryFolder, info.getTestMethod().get().getName()) }, Locale.ROOT, log, output, true, true).run(); assertTrue(output.exists()); final Map<String, String> files = new HashMap<>(); try (final ZipInputStream zip = new ZipInputStream(new FileInputStream(output))) { ZipEntry nextEntry; while ((nextEntry = zip.getNextEntry()) != null) { files.put(nextEntry.getName(), IO.slurp(zip)); } } try (final BufferedReader reader = resource("generateDitaConds_activeif.xml")) { assertEquals(formatXml(reader.lines().collect(joining("\n"))), formatXml(files.get("generateDitaConds/test/activeif.dita"))); } }
Example #10
Source File: CloudFoundryAcceptanceTest.java From spring-cloud-app-broker with Apache License 2.0 | 5 votes |
@AfterEach public void tearDown(TestInfo testInfo) { blockingSubscribe(cloudFoundryService.getOrCreateDefaultOrg() .map(OrganizationSummary::getId) .flatMap(orgId -> cloudFoundryService.getOrCreateDefaultSpace() .map(SpaceSummary::getId) .flatMap(spaceId -> cleanup(orgId, spaceId)))); }
Example #11
Source File: CacheTest.java From centraldogma with Apache License 2.0 | 5 votes |
@ParameterizedTest(name = "history [{index}: {0}]") @EnumSource(ClientType.class) void history(ClientType clientType, TestInfo testInfo) { final String project = normalizedDisplayName(testInfo); final CentralDogma client = clientType.client(dogma); client.createProject(project).join(); client.createRepository(project, REPO_FOO).join(); final PushResult res1 = client.push(project, REPO_FOO, HEAD, "Add a file", Change.ofTextUpsert("/foo.txt", "bar")).join(); final Map<String, Double> meters1 = metersSupplier.get(); // Get the history in various combination of from/to revisions. final List<Commit> history1 = client.getHistory(project, REPO_FOO, HEAD, new Revision(-2), "/**").join(); final List<Commit> history2 = client.getHistory(project, REPO_FOO, HEAD, INIT, "/**").join(); final List<Commit> history3 = client.getHistory(project, REPO_FOO, res1.revision(), new Revision(-2), "/**").join(); final List<Commit> history4 = client.getHistory(project, REPO_FOO, res1.revision(), INIT, "/**").join(); // and they should all same. assertThat(history1).isEqualTo(history2); assertThat(history1).isEqualTo(history3); assertThat(history1).isEqualTo(history4); final Map<String, Double> meters2 = metersSupplier.get(); // Should miss once and hit 3 times. assertThat(missCount(meters2)).isEqualTo(missCount(meters1) + 1); assertThat(hitCount(meters2)).isEqualTo(hitCount(meters1) + 3); }
Example #12
Source File: ClusterTest.java From aeron with Apache License 2.0 | 5 votes |
@Test @Timeout(30) public void shouldStopLeaderAndFollowersThenRestartAllWithSnapshot(final TestInfo testInfo) { cluster = startThreeNodeStaticCluster(NULL_VALUE); try { final TestNode leader = cluster.awaitLeader(); cluster.takeSnapshot(leader); cluster.awaitSnapshotCount(cluster.node(0), 1); cluster.awaitSnapshotCount(cluster.node(1), 1); cluster.awaitSnapshotCount(cluster.node(2), 1); cluster.stopAllNodes(); cluster.restartAllNodes(false); cluster.awaitLeader(); assertEquals(2, cluster.followers().size()); cluster.awaitSnapshotLoadedForService(cluster.node(0)); cluster.awaitSnapshotLoadedForService(cluster.node(1)); cluster.awaitSnapshotLoadedForService(cluster.node(2)); } catch (final Throwable ex) { cluster.dumpData(testInfo); LangUtil.rethrowUnchecked(ex); } }
Example #13
Source File: ITestSeparator.java From enmasse with Apache License 2.0 | 5 votes |
@BeforeEach default void beforeEachTest(TestInfo testInfo) { TimeMeasuringSystem.setTestName(testInfo.getTestClass().get().getName(), testInfo.getDisplayName()); TimeMeasuringSystem.startOperation(SystemtestsOperation.TEST_EXECUTION); testSeparatorLogger.info(String.join("", Collections.nCopies(100, separatorChar))); testSeparatorLogger.info(String.format("%s.%s-STARTED", testInfo.getTestClass().get().getName(), testInfo.getDisplayName())); }
Example #14
Source File: SpecializedLoggerTest.java From microprofile-sandbox with Apache License 2.0 | 5 votes |
/** * Demonstrate a simple log statement that uses a formatted/parameterised message. * * @param info Test information. */ @Test public void testMethodCallToGetData(TestInfo info) { log.debug(e -> { e.name = getTestName(info); return "A log message"; }); Utils.assertLogCount(log, 1); }
Example #15
Source File: ClusterTest.java From aeron with Apache License 2.0 | 5 votes |
@Test @Timeout(40) public void shouldRecoverQuicklyAfterKillingFollowersThenRestartingOne(final TestInfo testInfo) { cluster = startThreeNodeStaticCluster(NULL_VALUE); try { final TestNode leader = cluster.awaitLeader(); final TestNode follower = cluster.followers().get(0); final TestNode follower2 = cluster.followers().get(1); cluster.connectClient(); cluster.sendMessages(10); cluster.stopNode(follower); cluster.stopNode(follower2); while (leader.role() != FOLLOWER) { Tests.sleep(1_000); cluster.sendMessages(1); } cluster.startStaticNode(follower2.index(), true); cluster.awaitLeader(); } catch (final Throwable ex) { cluster.dumpData(testInfo); LangUtil.rethrowUnchecked(ex); } }
Example #16
Source File: SpecializedLoggerTest.java From microprofile-sandbox with Apache License 2.0 | 5 votes |
@BeforeEach public void beforeEach(TestInfo info) { // Reset the Logging level before each test. Utils.setLoggerLevel(Level.DEBUG); log = LoggerFactory.getLogger(info.getDisplayName(), new SpecializedLogEventSupplier()); }
Example #17
Source File: LoggerTest.java From microprofile-sandbox with Apache License 2.0 | 5 votes |
/** * Demonstrate a simple log statement that uses a formatted/parameterised message. * * @param info Test information. */ @Test public void testFormattedString(TestInfo info) { log.debug(e -> String.format("Message parameter one [%s] and [%s]", "val1", "val2")); Utils.assertLogCount(log, 1); }
Example #18
Source File: FormatAcceptanceTest.java From junit-dataprovider with Apache License 2.0 | 5 votes |
@TestTemplate @UseDataProvider void testDivide(int dividend, int divisor, int result, TestInfo testInfo) { // Expect: assertThat(dividend / divisor).isEqualTo(result); assertThat(testInfo.getDisplayName()) .endsWith(String.format("dividend=%d, divisor=%d, result=%d", dividend, divisor, result)); }
Example #19
Source File: MirrorBotTests.java From skara with GNU General Public License v2.0 | 5 votes |
@Test void mirrorMasterBranch(TestInfo testInfo) throws IOException { try (var temp = new TemporaryDirectory()) { var host = TestHost.createNew(List.of(new HostUser(0, "duke", "J. Duke"))); var fromDir = temp.path().resolve("from.git"); var fromLocalRepo = Repository.init(fromDir, VCS.GIT); var fromHostedRepo = new TestHostedRepository(host, "test", fromLocalRepo); var toDir = temp.path().resolve("to.git"); var toLocalRepo = Repository.init(toDir, VCS.GIT); var gitConfig = toDir.resolve(".git").resolve("config"); Files.write(gitConfig, List.of("[receive]", "denyCurrentBranch = ignore"), StandardOpenOption.APPEND); var toHostedRepo = new TestHostedRepository(host, "test-mirror", toLocalRepo); var newFile = fromDir.resolve("this-file-cannot-exist.txt"); Files.writeString(newFile, "Hello world\n"); fromLocalRepo.add(newFile); var newHash = fromLocalRepo.commit("An additional commit", "duke", "[email protected]"); var fromCommits = fromLocalRepo.commits().asList(); assertEquals(1, fromCommits.size()); assertEquals(newHash, fromCommits.get(0).hash()); var toCommits = toLocalRepo.commits().asList(); assertEquals(0, toCommits.size()); var storage = temp.path().resolve("storage"); var bot = new MirrorBot(storage, fromHostedRepo, toHostedRepo); TestBotRunner.runPeriodicItems(bot); toCommits = toLocalRepo.commits().asList(); assertEquals(1, toCommits.size()); assertEquals(newHash, toCommits.get(0).hash()); } }
Example #20
Source File: DitaDocumentationGeneratorTest.java From component-runtime with Apache License 2.0 | 5 votes |
@ParameterizedTest @CsvSource( value = { "nolayout,NoLayout.dita", "nodatasetdatastore,NoDatasetDatastore.dita", "allbasic,AllBasic.dita", "alladvanced,AllAdvanced.dita", "simplemixed,SimpleMixed.dita", "hidden,Hidden.dita" }) void generateDitaAdvanced(final String _package, final String expectedFile, @TempDir final File temporaryFolder, final TestInfo info) throws IOException { final File output = new File(temporaryFolder, info.getTestMethod().get().getName() + ".zip"); new DitaDocumentationGenerator(new File[] { copyBinaries("org.talend.test.dita." + _package, temporaryFolder, info.getTestMethod().get().getName()) }, Locale.ROOT, log, output, true, true).run(); assertTrue(output.exists()); final Map<String, String> files = new HashMap<>(); try (final ZipInputStream zip = new ZipInputStream(new FileInputStream(output))) { ZipEntry nextEntry; while ((nextEntry = zip.getNextEntry()) != null) { files.put(nextEntry.getName(), IO.slurp(zip)); } } try (final BufferedReader reader = resource(expectedFile)) { assertEquals(formatXml(reader.lines().collect(joining("\n"))), formatXml(files.get("generateDitaAdvanced/dita/" + expectedFile).trim())); } assertEquals(3, files.size()); // folders assertEquals("", files.get("generateDitaAdvanced/dita/")); assertEquals("", files.get("generateDitaAdvanced/")); }
Example #21
Source File: AsciidocDocumentationGeneratorTest.java From component-runtime with Apache License 2.0 | 5 votes |
@Test void generateAdocWithConditions(@TempDir final File temporaryFolder, final TestInfo info) throws IOException { final File output = new File(temporaryFolder, info.getTestMethod().get().getName() + ".asciidoc"); new AsciidocDocumentationGenerator( new File[] { copyBinaries("org.talend.test.activeif", temporaryFolder, info.getTestMethod().get().getName()) }, output, null, 2, null, null, null, null, log, findWorkDir(), "1.0", Locale.ROOT).run(); assertTrue(output.exists()); try (final BufferedReader reader = new BufferedReader(new FileReader(output))) { assertEquals("//component_start:activeif\n" + "\n" + "== activeif\n" + "\n" + "//configuration_start\n" + "\n" + "=== Configuration\n" + "\n" + "[cols=\"d,d,m,a,e,d\",options=\"header\"]\n" + "|===\n" + "|Display Name|Description|Default Value|Enabled If|Configuration Path|Configuration Type\n" + "|configuration|configuration configuration|-|Always enabled|configuration|-\n" + "|advanced|advanced configuration|false|Always enabled|configuration.advanced|-\n" + "|advancedOption|advancedOption configuration|-|All of the following conditions are met:\n" + "\n" + "- `advanced` is equal to `false`\n" + "- `query` is empty\n" + "|configuration.advancedOption|-\n" + "|query|query configuration|-|All of the following conditions are met:\n" + "\n" + "- `toggle` is equal to `true`\n" + "- `type` is equal to `mysql` or `oracle`\n" + "|configuration.query|-\n" + "|toggle|toggle configuration|false|Always enabled|configuration.toggle|-\n" + "|token|token configuration|-|`toggle` is equal to `true`|configuration.token|-\n" + "|type|type configuration|-|Always enabled|configuration.type|-\n" + "|===\n" + "\n" + "//configuration_end\n" + "\n" + "//component_end:activeif\n", reader.lines().collect(joining("\n"))); } }
Example #22
Source File: BeforeAllTest.java From flyway-test-extensions with Apache License 2.0 | 5 votes |
@Test public void additionalCountWithoutAny(TestInfo testName) throws Exception { int res = countCustomer(); assertThat("Customer count before add ", res, is(customerCount)); addCustomer("additionalCountWithoutAny"); res = countCustomer(); assertThat("Count of customer after add ", res, is(customerCount + 1)); }
Example #23
Source File: CoapTestBase.java From hono with Eclipse Public License 2.0 | 5 votes |
/** * Sets up the fixture. * * @param testInfo The test meta data. * @throws UnknownHostException if the CoAP adapter's host name cannot be resolved. */ @BeforeEach public void setUp(final TestInfo testInfo) throws UnknownHostException { logger.info("running {}", testInfo.getDisplayName()); logger.info("using CoAP adapter [host: {}, coap port: {}, coaps port: {}]", IntegrationTestSupport.COAP_HOST, IntegrationTestSupport.COAP_PORT, IntegrationTestSupport.COAPS_PORT); coapAdapterSecureAddress = new InetSocketAddress(Inet4Address.getByName(IntegrationTestSupport.COAP_HOST), IntegrationTestSupport.COAPS_PORT); tenantId = helper.getRandomTenantId(); deviceId = helper.getRandomDeviceId(tenantId); }
Example #24
Source File: ClusterTest.java From aeron with Apache License 2.0 | 5 votes |
@Test @Timeout(20) public void shouldCloseClientOnTimeout(final TestInfo testInfo) { cluster = startThreeNodeStaticCluster(NULL_VALUE); try { final TestNode leader = cluster.awaitLeader(); final AeronCluster client = cluster.connectClient(); final ConsensusModule.Context context = leader.consensusModule().context(); assertEquals(0, context.timedOutClientCounter().get()); assertFalse(client.isClosed()); Tests.sleep(NANOSECONDS.toMillis(context.sessionTimeoutNs())); while (!client.isClosed()) { Tests.sleep(1); client.pollEgress(); } assertEquals(1, context.timedOutClientCounter().get()); } catch (final Throwable ex) { cluster.dumpData(testInfo); LangUtil.rethrowUnchecked(ex); } }
Example #25
Source File: SpringJUnitJupiterConstructorInjectionTests.java From java-technology-stack with MIT License | 5 votes |
SpringJUnitJupiterConstructorInjectionTests(ApplicationContext applicationContext, @Autowired Person dilbert, @Autowired Dog dog, @Value("${enigma}") Integer enigma, TestInfo testInfo) { this.applicationContext = applicationContext; this.dilbert = dilbert; this.dog = dog; this.enigma = enigma; this.testInfo = testInfo; }
Example #26
Source File: AbstractITClientTest.java From influxdb-client-java with MIT License | 5 votes |
@BeforeEach void initInfluxDBClientClient(TestInfo testInfo) throws Exception { influxDB_IP = getInfluxDb2Ip(); influxDB_URL = getInfluxDb2Url(); LOG.log(Level.FINEST, "InfluxDB URL: {0}", influxDB_URL); boolean basic_auth = testInfo.getTags().contains("basic_auth"); if (!basic_auth) { influxDBClient = InfluxDBClientFactory.create(influxDB_URL, "my-token".toCharArray()); } else { influxDBClient = InfluxDBClientFactory.create(influxDB_URL, "my-user", "my-password".toCharArray()); } }
Example #27
Source File: LoggerTest.java From microprofile-sandbox with Apache License 2.0 | 5 votes |
/** * Demonstrate the simplest log statement. * * @param info Test information */ @Test public void testSimplestStatement(TestInfo info) { log.debug(e -> "A simple log message"); Utils.assertLogCount(log, 1); }
Example #28
Source File: TestInfoTest.java From Mastering-Software-Testing-with-JUnit-5 with MIT License | 5 votes |
@Test @DisplayName("My test") @Tag("my-tag") void test1(TestInfo testInfo) { System.out.println(testInfo.getDisplayName()); System.out.println(testInfo.getTags()); System.out.println(testInfo.getTestClass()); System.out.println(testInfo.getTestMethod()); }
Example #29
Source File: BaseMetadataTest.java From helidon-build-tools with Apache License 2.0 | 5 votes |
/** * Prepare for each test. * * @param info The test info. * @param baseUrl The base url to use. * @throws IOException If an error occurs. */ protected void prepareEach(TestInfo info, String baseUrl) throws IOException { final String testClassName = info.getTestClass().orElseThrow().getSimpleName(); final String testName = info.getTestMethod().orElseThrow().getName(); Log.info("%n--- %s $(bold %s) -------------------------------------------%n", testClassName, testName); Config.setUserHome(TestFiles.targetDir().resolve("alice")); final UserConfig userConfig = Config.userConfig(); userConfig.clearCache(); userConfig.clearPlugins(); Plugins.reset(false); useBaseUrl(baseUrl); cacheDir = userConfig.cacheDir(); latestFile = cacheDir.resolve(LATEST_FILE_NAME); logged = CapturingLogWriter.install(); }
Example #30
Source File: RepositoryManagerWrapperTest.java From centraldogma with Apache License 2.0 | 5 votes |
@Test void get(TestInfo testInfo) { final String name = TestUtil.normalizedDisplayName(testInfo); final Repository repo = m.create(name, Author.SYSTEM); final Repository repo2 = m.get(name); // Check if the reference is same. assertThat(repo).isSameAs(repo2); }