org.junit.jupiter.api.extension.ExtendWith Java Examples
The following examples show how to use
org.junit.jupiter.api.extension.ExtendWith.
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: P4ChangeListDecoratorTest.java From p4ic4idea with Apache License 2.0 | 6 votes |
/** * Validate that when offline and no corresponding P4 changelist, an IDE change list is not * decorated. */ @ExtendWith(TemporaryFolderExtension.class) @Test void offlineNoP4ChangeDecorateChangeListWithDefault(TemporaryFolder tmp) { // Setup offline mode ClientConfigRoot root = vcs.addClientConfigRoot(tmp, "client"); assertNotNull(root.getClientRootDir()); vcs.goOffline(root); assertFalse(vcs.registry.isOnline(root.getClientConfig().getClientServerRef())); P4ChangelistId defaultP4Changelist = vcs.addDefaultChangelist(root); MockLocalChangeList changeList = vcs.addIdeChangelist("new change", "a test change", false); P4ChangeListDecorator decorator = new P4ChangeListDecorator(vcs.getMockProject()); MockColoredTreeCellRenderer renderer = new MockColoredTreeCellRenderer(); decorator.decorateChangeList(changeList, renderer, false, false, false); assertEmpty(renderer.appendedText); }
Example #2
Source File: AllureCucumber2JvmTest.java From allure-java with Apache License 2.0 | 6 votes |
@AllureFeatures.Links @ExtendWith(SystemPropertyExtension.class) @SystemProperty(name = "allure.link.issue.pattern", value = "https://example.org/issue/{}") @SystemProperty(name = "allure.link.tms.pattern", value = "https://example.org/tms/{}") @Test void shouldAddLinks() { final AllureResults results = runFeature("features/tags.feature"); final List<TestResult> testResults = results.getTestResults(); assertThat(testResults) .flatExtracting(TestResult::getLinks) .extracting(Link::getName, Link::getType, Link::getUrl) .contains( tuple("OAT-4444", "tms", "https://example.org/tms/OAT-4444"), tuple("BUG-22400", "issue", "https://example.org/issue/BUG-22400") ); }
Example #3
Source File: AllureCucumber5JvmTest.java From allure-java with Apache License 2.0 | 6 votes |
@AllureFeatures.Links @ExtendWith(SystemPropertyExtension.class) @SystemProperty(name = "allure.link.issue.pattern", value = "https://example.org/issue/{}") @SystemProperty(name = "allure.link.tms.pattern", value = "https://example.org/tms/{}") @Test void shouldAddLinks() { final AllureResultsWriterStub writer = new AllureResultsWriterStub(); runFeature(writer, "features/tags.feature"); final List<TestResult> testResults = writer.getTestResults(); assertThat(testResults) .flatExtracting(TestResult::getLinks) .extracting(Link::getName, Link::getType, Link::getUrl) .contains( tuple("OAT-4444", "tms", "https://example.org/tms/OAT-4444"), tuple("BUG-22400", "issue", "https://example.org/issue/BUG-22400") ); }
Example #4
Source File: AllureCucumberJvmTest.java From allure-java with Apache License 2.0 | 6 votes |
@AllureFeatures.Links @ExtendWith(SystemPropertyExtension.class) @SystemProperty(name = "allure.link.issue.pattern", value = "https://example.org/issue/{}") @SystemProperty(name = "allure.link.tms.pattern", value = "https://example.org/tms/{}") @Test void shouldAddLinks() { final AllureResults results = runFeature("features/tags.feature"); final List<TestResult> testResults = results.getTestResults(); assertThat(testResults) .flatExtracting(TestResult::getLinks) .extracting(Link::getName, Link::getType, Link::getUrl) .contains( tuple("OAT-4444", "tms", "https://example.org/tms/OAT-4444"), tuple("BUG-22400", "issue", "https://example.org/issue/BUG-22400") ); }
Example #5
Source File: AllureCucumber4JvmTest.java From allure-java with Apache License 2.0 | 6 votes |
@AllureFeatures.Links @ExtendWith(SystemPropertyExtension.class) @SystemProperty(name = "allure.link.issue.pattern", value = "https://example.org/issue/{}") @SystemProperty(name = "allure.link.tms.pattern", value = "https://example.org/tms/{}") @Test void shouldAddLinks() { final AllureResultsWriterStub writer = new AllureResultsWriterStub(); runFeature(writer, "features/tags.feature"); final List<TestResult> testResults = writer.getTestResults(); assertThat(testResults) .flatExtracting(TestResult::getLinks) .extracting(Link::getName, Link::getType, Link::getUrl) .contains( tuple("OAT-4444", "tms", "https://example.org/tms/OAT-4444"), tuple("BUG-22400", "issue", "https://example.org/issue/BUG-22400") ); }
Example #6
Source File: AllureCucumber3JvmTest.java From allure-java with Apache License 2.0 | 6 votes |
@AllureFeatures.Links @ExtendWith(SystemPropertyExtension.class) @SystemProperty(name = "allure.link.issue.pattern", value = "https://example.org/issue/{}") @SystemProperty(name = "allure.link.tms.pattern", value = "https://example.org/tms/{}") @Test void shouldAddLinks() { final AllureResults results = runFeature("features/tags.feature"); assertThat(results.getTestResults()) .flatExtracting(TestResult::getLinks) .extracting(Link::getName, Link::getType, Link::getUrl) .contains( tuple("OAT-4444", "tms", "https://example.org/tms/OAT-4444"), tuple("BUG-22400", "issue", "https://example.org/issue/BUG-22400") ); }
Example #7
Source File: HttpToggleFetcherTest.java From unleash-client-java with Apache License 2.0 | 6 votes |
@Test @ExtendWith(UnleashExceptionExtension.class) public void given_json_without_feature_field() throws Exception { stubFor(get(urlEqualTo("/api/client/features")) .withHeader("Accept", equalTo("application/json")) .willReturn(aResponse() .withStatus(200) .withHeader("Content-Type", "application/json") .withBody("{}"))); URI uri = new URI("http://localhost:"+serverMock.port() + "/api/"); UnleashConfig config = UnleashConfig.builder().appName("test").unleashAPI(uri).build(); HttpToggleFetcher httpToggleFetcher = new HttpToggleFetcher(config); httpToggleFetcher.fetchToggles(); verify(getRequestedFor(urlMatching("/api/client/features")) .withHeader("Content-Type", matching("application/json"))); }
Example #8
Source File: HttpToggleFetcherTest.java From unleash-client-java with Apache License 2.0 | 6 votes |
@Test @ExtendWith(UnleashExceptionExtension.class) public void given_empty_body() throws URISyntaxException { stubFor(get(urlEqualTo("/api/client/features")) .withHeader("Accept", equalTo("application/json")) .willReturn(aResponse() .withStatus(200) .withHeader("Content-Type", "application/json"))); URI uri = new URI("http://localhost:"+serverMock.port() + "/api/"); UnleashConfig config = UnleashConfig.builder().appName("test").unleashAPI(uri).build(); HttpToggleFetcher httpToggleFetcher = new HttpToggleFetcher(config); httpToggleFetcher.fetchToggles(); verify(getRequestedFor(urlMatching("/api/client/features")) .withHeader("Content-Type", matching("application/json"))); }
Example #9
Source File: MetamodelOptionTest.java From doma with Apache License 2.0 | 5 votes |
@TestTemplate @ExtendWith(SuccessInvocationContextProvider.class) void success(Class clazz, URL expectedResourceUrl, String generatedClassName, String[] options) throws Exception { addOption(options); addProcessor(new EntityProcessor()); addCompilationUnit(clazz); compile(); assertEqualsGeneratedSourceWithResource(expectedResourceUrl, generatedClassName); assertTrue(getCompiledResult()); }
Example #10
Source File: DaoProcessorTest.java From doma with Apache License 2.0 | 5 votes |
@TestTemplate @ExtendWith(ErrorInvocationContextProvider.class) void error(Class clazz, Message message) throws Exception { addProcessor(new DaoProcessor()); addCompilationUnit(clazz); compile(); assertFalse(getCompiledResult()); assertMessage(message); }
Example #11
Source File: DomainProcessorTest.java From doma with Apache License 2.0 | 5 votes |
@TestTemplate @ExtendWith(ErrorInvocationContextProvider.class) void error(Class clazz, Message message, String... options) throws Exception { addOption(options); addProcessor(new DomainProcessor()); addCompilationUnit(clazz); compile(); assertFalse(getCompiledResult()); assertMessage(message); }
Example #12
Source File: CustomResolverAcceptanceTest.java From junit-dataprovider with Apache License 2.0 | 5 votes |
@TestTemplate @ExtendWith(UseDataProviderExtension.class) @UseDataProvider(resolver = DataProviderStartWithTestMethodNameResolver.class) void testNumber(Number number) { // When: int count = counterOne.incrementAndGet(); // Then: assertThat(count).isEqualTo(number.intValue()); }
Example #13
Source File: CustomStringConverterAcceptanceTest.java From junit-dataprovider with Apache License 2.0 | 5 votes |
@TestTemplate @ExtendWith(UseDataProviderExtension.class) @UseDataProvider("dateTimeMetaAnnotationAndDataProviderMethodProvider") void testDateTimeAnnotationAndDataProviderMethod(Date date, int year, int month, int dayOfMonth, int hourOfDay, int minute, int second, int millis, String timeZone) { // Expect: assertThat(date).isEqualTo(date(year, month, dayOfMonth, hourOfDay, minute, second, millis, timeZone)); }
Example #14
Source File: CustomStringConverterAcceptanceTest.java From junit-dataprovider with Apache License 2.0 | 5 votes |
@TestTemplate @ExtendWith(CustomConverterDataProviderExtension.class) @CustomConverterDataProvider(value = { "2016-02-19 | 2016 | 02 | 19 | 00 | 00 | 00 | 000 | UTC", "2016-02-19T20:15:22.629 GMT | 2016 | 02 | 19 | 20 | 15 | 22 | 629 | UTC", }, splitBy = "\\|") // @formatter:off void testDateTimeDirectMetaAnnotation(Date date, int year, int month, int dayOfMonth, int hourOfDay, int minute, int second, int millis, String timeZone) { // Expect: assertThat(date).isEqualTo(date(year, month, dayOfMonth, hourOfDay, minute, second, millis, timeZone)); }
Example #15
Source File: CustomStringConverterAcceptanceTest.java From junit-dataprovider with Apache License 2.0 | 5 votes |
@TestTemplate @ExtendWith(DataProviderExtension.class) @DataProvider(value = { "2016-02-19 | 2016 | 02 | 19 | 00 | 00 | 00 | 000 | UTC", "2016-02-19T20:15:22.629 GMT | 2016 | 02 | 19 | 20 | 15 | 22 | 629 | UTC", }, splitBy = "\\|", stringConverter = DateTimeAwareStringConverter.class) // @formatter:off void testDateTimeDirectAnnotation(Date date, int year, int month, int dayOfMonth, int hourOfDay, int minute, int second, int millis, String timeZone) { // Expect: assertThat(date).isEqualTo(date(year, month, dayOfMonth, hourOfDay, minute, second, millis, timeZone)); }
Example #16
Source File: ExternalDomainProcessorTest.java From doma with Apache License 2.0 | 5 votes |
@TestTemplate @ExtendWith(ErrorInvocationContextProvider.class) void error(Class clazz, Message message, String... options) throws Exception { addOption(options); addProcessor(new ExternalDomainProcessor()); addCompilationUnit(clazz); compile(); assertFalse(getCompiledResult()); assertMessage(message); }
Example #17
Source File: ExternalDomainProcessorTest.java From doma with Apache License 2.0 | 5 votes |
@TestTemplate @ExtendWith(SuccessInvocationContextProvider.class) void success(Class clazz, URL expectedResourceUrl, String generatedClassName) throws Exception { addProcessor(new ExternalDomainProcessor()); addCompilationUnit(clazz); compile(); assertEqualsGeneratedSourceWithResource(expectedResourceUrl, generatedClassName); assertTrue(getCompiledResult()); }
Example #18
Source File: DaoProcessorTest.java From doma with Apache License 2.0 | 5 votes |
@TestTemplate @ExtendWith(SuccessInvocationContextProvider.class) void success(Class clazz, URL expectedResourceUrl, String generatedClassName, String[] options) throws Exception { addOption(options); addProcessor(new DaoProcessor()); addCompilationUnit(clazz); compile(); assertEqualsGeneratedSourceWithResource(expectedResourceUrl, generatedClassName); assertTrue(getCompiledResult()); }
Example #19
Source File: SqlTest.java From doma with Apache License 2.0 | 5 votes |
@TestTemplate @ExtendWith(ErrorInvocationContextProvider.class) void error(Class clazz, Message message, String... options) throws Exception { addOption(options); addProcessor(new DaoProcessor()); addCompilationUnit(clazz); compile(); assertFalse(getCompiledResult()); assertMessage(message); }
Example #20
Source File: MetamodelTest.java From doma with Apache License 2.0 | 5 votes |
@TestTemplate @ExtendWith(ErrorInvocationContextProvider.class) void error(Class<?> clazz, Message message, String... options) throws Exception { addOption(options); addProcessor(new EntityProcessor()); addCompilationUnit(clazz); compile(); assertFalse(getCompiledResult()); assertMessage(message); }
Example #21
Source File: MetamodelTest.java From doma with Apache License 2.0 | 5 votes |
@TestTemplate @ExtendWith(SuccessPrefixInvocationContextProvider.class) void success_prefix( Class<?> clazz, URL expectedResourceUrl, String generatedClassName, String[] options) throws Exception { addOption(options); addProcessor(new EntityProcessor()); addCompilationUnit(clazz); compile(); assertEqualsGeneratedSourceWithResource(expectedResourceUrl, generatedClassName); assertTrue(getCompiledResult()); }
Example #22
Source File: MetamodelTest.java From doma with Apache License 2.0 | 5 votes |
@TestTemplate @ExtendWith(SuccessInvocationContextProvider.class) void success(Class<?> clazz, URL expectedResourceUrl, String generatedClassName, String[] options) throws Exception { addOption(options); addProcessor(new EntityProcessor()); addCompilationUnit(clazz); compile(); assertEqualsGeneratedSourceWithResource(expectedResourceUrl, generatedClassName); assertTrue(getCompiledResult()); }
Example #23
Source File: EntityProcessorTest.java From doma with Apache License 2.0 | 5 votes |
@TestTemplate @ExtendWith(ErrorInvocationContextProvider.class) void error(Class clazz, Message message, String... options) throws Exception { addOption(options); addProcessor(new EntityProcessor()); addCompilationUnit(clazz); compile(); assertFalse(getCompiledResult()); assertMessage(message); }
Example #24
Source File: EntityProcessorTest.java From doma with Apache License 2.0 | 5 votes |
@TestTemplate @ExtendWith(SuccessInvocationContextProvider.class) void success(Class clazz, URL expectedResourceUrl, String generatedClassName, String[] options) throws Exception { addOption(options); addProcessor(new EntityProcessor()); addCompilationUnit(clazz); compile(); assertEqualsGeneratedSourceWithResource(expectedResourceUrl, generatedClassName); assertTrue(getCompiledResult()); }
Example #25
Source File: ProjectCacheStoreTest.java From p4ic4idea with Apache License 2.0 | 5 votes |
@ExtendWith(TemporaryFolderExtension.class) @Test void getSetState(TemporaryFolder tmpDir) throws PrimitiveMap.UnmarshalException { ProjectCacheStore.State state = new ProjectCacheStore.State(); ClientServerRef ref = new ClientServerRef( P4ServerName.forPortNotNull("test:1234"), "client1" ); state.clientState = Collections.singletonList(new ClientQueryCacheStore(ref).getState()); state.serverState = Collections.singletonList(new ServerQueryCacheStore(ref.getServerName()).getState()); MockFilePath fp = new MockFilePath(tmpDir.newFile("test-file.txt")); ActionStore.State actionState = ActionStore.getState( ActionStore.getSourceId(ref), new MoveFilesToChangelistAction(new P4ChangelistIdImpl(1, ref), Collections.singletonList(fp))); state.pendingActions = Collections.singletonList(actionState); Element serialized = XmlSerializer.serialize(state); ProjectCacheStore.State unmarshalled = XmlSerializer.deserialize(serialized, ProjectCacheStore.State.class); assertNotNull(unmarshalled); assertSize(1, unmarshalled.clientState); assertSize(1, unmarshalled.serverState); assertSize(1, unmarshalled.pendingActions); assertNotNull(unmarshalled.pendingActions.get(0)); ActionStore.PendingAction moveAction = ActionStore.read(unmarshalled.pendingActions.get(0)); assertThat(moveAction.clientAction, instanceOf(MoveFilesToChangelistAction.class)); }
Example #26
Source File: ConnectCommandRunnerTest.java From p4ic4idea with Apache License 2.0 | 5 votes |
@ExtendWith(TemporaryFolderExtension.class) @Test void getClientsForUser_nonExistent(TemporaryFolder tmpDir) throws IOException { idea.useInlineThreading(null); MockConfigPart part = new MockConfigPart() // By using the RSH port, it means that the connection will be kept open // (NTS connection). By keeping the connection open until explicitly // disconnected, this will indirectly be testing that the // SimpleConnectionManager closes the connection. .withServerName(server.getRshUrl()) .withUsername(server.getUser()) .withNoPassword() .withClientname("client1"); final ServerConfig serverConfig = ServerConfig.createFrom(part); final ClientConfig clientConfig = ClientConfig.createFrom(serverConfig, part); final File clientRoot = tmpDir.newFile("clientRoot"); final TestableP4RequestErrorHandler errorHandler = new TestableP4RequestErrorHandler(idea.getMockProject()); setupClient(clientConfig, tmpDir, clientRoot, errorHandler) .map((cm) -> new ConnectCommandRunner(idea.getMockProject(), cm)) .futureMap((runner, sink) -> runner.getClientsForUser(new OptionalClientServerConfig(clientConfig), new ListClientsForUserQuery("not-a-user", 50)) .whenCompleted(sink::resolve) .whenServerError(sink::reject) ) .whenCompleted((r) -> { assertThat(r, instanceOf(ListClientsForUserResult.class)); ListClientsForUserResult res = (ListClientsForUserResult) r; assertSame(serverConfig, res.getServerConfig()); assertEquals("not-a-user", res.getRequestedUser()); assertEmpty(res.getClients()); }) .whenFailed(Assertions::fail); }
Example #27
Source File: ConnectCommandRunnerTest.java From p4ic4idea with Apache License 2.0 | 5 votes |
@ExtendWith(TemporaryFolderExtension.class) @Test void fetchFiles_noFiles(TemporaryFolder tmpDir) throws IOException { idea.useInlineThreading(null); MockConfigPart part = new MockConfigPart() // By using the RSH port, it means that the connection will be kept open // (NTS connection). By keeping the connection open until explicitly // disconnected, this will indirectly be testing that the // SimpleConnectionManager closes the connection. .withServerName(server.getRshUrl()) .withUsername(server.getUser()) .withNoPassword() .withClientname("client1"); final ServerConfig serverConfig = ServerConfig.createFrom(part); final ClientConfig clientConfig = ClientConfig.createFrom(serverConfig, part); final File clientRoot = tmpDir.newFile("clientRoot"); touchFile(clientRoot, "[email protected]"); final TestableP4RequestErrorHandler errorHandler = new TestableP4RequestErrorHandler(idea.getMockProject()); setupClient(clientConfig, tmpDir, clientRoot, errorHandler) .map((cm) -> new ConnectCommandRunner(idea.getMockProject(), cm)) .futureMap((runner, sink) -> runner.perform(clientConfig, new FetchFilesAction(Collections.singletonList(VcsUtil.getFilePath(clientRoot)), null, false)) .whenCompleted(sink::resolve) .whenServerError(sink::reject) ) .whenCompleted((r) -> { // Special code is present to handle an empty sync. FetchFilesResult res = (FetchFilesResult) r; assertEquals("", res.getMessage()); assertEmpty(res.getFiles()); }) .whenFailed(Assertions::fail); }
Example #28
Source File: ConnectCommandRunnerTest.java From p4ic4idea with Apache License 2.0 | 5 votes |
@ExtendWith(TemporaryFolderExtension.class) @Test void createChangelist(TemporaryFolder tmpDir) throws IOException { idea.useInlineThreading(null); MockConfigPart part = new MockConfigPart() // By using the RSH port, it means that the connection will be kept open // (NTS connection). By keeping the connection open until explicitly // disconnected, this will indirectly be testing that the // SimpleConnectionManager closes the connection. .withServerName(server.getRshUrl()) .withUsername(server.getUser()) .withNoPassword() .withClientname("client1"); final ServerConfig serverConfig = ServerConfig.createFrom(part); final ClientConfig clientConfig = ClientConfig.createFrom(serverConfig, part); final File clientRoot = tmpDir.newFile("clientRoot"); touchFile(clientRoot, "[email protected]"); final TestableP4RequestErrorHandler errorHandler = new TestableP4RequestErrorHandler(idea.getMockProject()); setupClient(clientConfig, tmpDir, clientRoot, errorHandler) .map((cm) -> new ConnectCommandRunner(idea.getMockProject(), cm)) .futureMap((runner, sink) -> runner.perform(clientConfig, new CreateChangelistAction(clientConfig.getClientServerRef(), "simple", "local-id")) .whenCompleted(sink::resolve) .whenServerError(sink::reject) ) .whenCompleted((r) -> { assertThat(r, instanceOf(CreateChangelistResult.class)); CreateChangelistResult res = (CreateChangelistResult) r; assertSame(clientConfig, res.getClientConfig()); assertEquals(1, res.getChangelistId()); }) .whenFailed(Assertions::fail); }
Example #29
Source File: ConnectCommandRunnerTest.java From p4ic4idea with Apache License 2.0 | 5 votes |
@ExtendWith(TemporaryFolderExtension.class) @Test void createJob_error(TemporaryFolder tmpDir) throws IOException { idea.useInlineThreading(null); final ServerConfig config = ServerConfig.createFrom( new MockConfigPart() // By using the RSH port, it means that the connection will be kept open // (NTS connection). By keeping the connection open until explicitly // disconnected, this will indirectly be testing that the // SimpleConnectionManager closes the connection. .withServerName(server.getRshUrl()) .withUsername(server.getUser()) .withNoPassword() ); final MockP4RequestErrorHandler errorHandler = new MockP4RequestErrorHandler(); SimpleConnectionManager mgr = new SimpleConnectionManager( tmpDir.newFile("out"), 1000, "v1", errorHandler); ConnectCommandRunner runner = new ConnectCommandRunner(idea.getMockProject(), mgr); // Should run without needing a blockingGet, because of the inline thread handler. runner.getJobSpec(new OptionalClientServerConfig(config, null)) .mapActionAsync((jobSpec) -> // Do not set any expected details. runner.perform(new OptionalClientServerConfig(config, null), new CreateJobAction(new P4JobImpl("j", "x", null))) ) .whenCompleted((x) -> fail("Did not throw an error")) .whenServerError((ex) -> { assertNotNull(ex); assertThat(ex.getCause(), instanceOf(RequestException.class)); // FIXME add better assertions }); assertSize(1, errorHandler.getExceptions()); assertThat(errorHandler.getExceptions().get(0), instanceOf(RequestException.class)); }
Example #30
Source File: RemoteFileUtilTest.java From p4ic4idea with Apache License 2.0 | 5 votes |
@ExtendWith(TemporaryFolderExtension.class) @Test void testSplitFilePath_simple(TemporaryFolder tmpDir) { FilePath src = VcsUtil.getFilePath(tmpDir.newFile("a/test.txt")); FilePath dest = VcsUtil.getFilePath(tmpDir.newFile("b/test.txt")); P4RemoteFileImpl local = new P4RemoteFileImpl("//depot/x/y/a/test.txt", "//depot/x/y/a/test.txt", null); P4RemoteFileImpl remote = new P4RemoteFileImpl("//depot/x/y/b/test.txt", "//depot/x/y/b/test.txt", null); assertEquals( dest, RemoteFileUtil.createRelativePath(src, local, remote) ); }