org.junit.jupiter.params.provider.EnumSource Java Examples
The following examples show how to use
org.junit.jupiter.params.provider.EnumSource.
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: RepositoryTests.java From skara with GNU General Public License v2.0 | 6 votes |
@ParameterizedTest @EnumSource(VCS.class) void testMergeBase(VCS vcs) throws IOException { try (var dir = new TemporaryDirectory()) { var r = Repository.init(dir.path(), vcs); var readme = dir.path().resolve("README"); Files.write(readme, List.of("Hello, readme!")); r.add(readme); var hash1 = r.commit("Add README", "duke", "[email protected]"); Files.write(readme, List.of("Another line"), WRITE, APPEND); r.add(readme); var hash2 = r.commit("Modify README", "duke", "[email protected]"); r.checkout(hash1, false); Files.write(readme, List.of("A conflicting line"), WRITE, APPEND); r.add(readme); var hash3 = r.commit("Branching README modification", "duke", "[email protected]"); assertEquals(hash1, r.mergeBase(hash2, hash3)); } }
Example #2
Source File: RepositoryTests.java From skara with GNU General Public License v2.0 | 6 votes |
@ParameterizedTest @EnumSource(VCS.class) void testFetchRemote(VCS vcs) throws IOException { try (var dir = new TemporaryDirectory()) { var upstream = Repository.init(dir.path(), vcs); var readme = dir.path().resolve("README"); Files.write(readme, List.of("Hello, readme!")); upstream.add(readme); upstream.commit("Add README", "duke", "[email protected]"); try (var dir2 = new TemporaryDirectory()) { var downstream = Repository.init(dir2.path(), vcs); // note: forcing unix path separators for URI var upstreamURI = URI.create("file:///" + dir.toString().replace('\\', '/')); downstream.addRemote("upstream", upstreamURI.toString()); downstream.addRemote("foobar", "file:///this/path/does/not/exist"); downstream.fetchRemote("upstream"); } } }
Example #3
Source File: JCheckTests.java From skara with GNU General Public License v2.0 | 6 votes |
@ParameterizedTest @EnumSource(VCS.class) void checksForCommit(VCS vcs) throws Exception { try (var dir = new TemporaryDirectory()) { var repoPath = dir.path().resolve("repo"); var repo = CheckableRepository.create(repoPath, vcs); var readme = repoPath.resolve("README"); Files.write(readme, List.of("Hello, readme!")); repo.add(readme); var first = repo.commit("Add README", "duke", "[email protected]"); var censusPath = dir.path().resolve("census"); Files.createDirectories(censusPath); CensusCreator.populateCensusDirectory(censusPath); var census = Census.parse(censusPath); var checks = JCheck.checksFor(repo, census, first); var checkNames = checks.stream() .map(Check::name) .collect(Collectors.toSet()); assertEquals(Set.of("whitespace", "reviewers"), checkNames); } }
Example #4
Source File: RepositoryTests.java From skara with GNU General Public License v2.0 | 6 votes |
@ParameterizedTest @EnumSource(VCS.class) void testTag(VCS vcs) throws IOException { try (var dir = new TemporaryDirectory()) { var r = Repository.init(dir.path(), vcs); var readme = dir.path().resolve("README"); Files.write(readme, List.of("Hello, world!")); r.add(readme); var first = r.commit("Added README", "duke", "[email protected]"); r.tag(first, "test", "Tagging test", "duke", "[email protected]"); var defaultTag = r.defaultTag().orElse(null); var nonDefaultTags = r.tags().stream() .filter(tag -> !tag.equals(defaultTag)) .map(Tag::toString) .collect(Collectors.toList()); assertEquals(List.of("test"), nonDefaultTags); } }
Example #5
Source File: RepositoryTests.java From skara with GNU General Public License v2.0 | 6 votes |
@ParameterizedTest @EnumSource(VCS.class) void testCommitMetadataWithReverse(VCS vcs) throws IOException { try (var dir = new TemporaryDirectory()) { var r = Repository.init(dir.path(), vcs); var readme = dir.path().resolve("README"); Files.write(readme, List.of("Hello, world!")); r.add(readme); var first = r.commit("Added README", "duke", "[email protected]"); Files.write(readme, List.of("One more line"), WRITE, APPEND); r.add(readme); var second = r.commit("Modified README", "duke", "[email protected]"); var metadata = r.commitMetadata(); assertEquals(2, metadata.size()); assertEquals(second, metadata.get(0).hash()); assertEquals(first, metadata.get(1).hash()); metadata = r.commitMetadata(true); assertEquals(2, metadata.size()); assertEquals(first, metadata.get(0).hash()); assertEquals(second, metadata.get(1).hash()); } }
Example #6
Source File: WebhookTest.java From camel-k-runtime with Apache License 2.0 | 6 votes |
@ParameterizedTest() @EnumSource(WebhookAction.class) public void testRegistrationFailure(WebhookAction action) throws Exception { ApplicationRuntime runtime = new ApplicationRuntime(); runtime.setProperties( "camel.component.webhook.configuration.webhook-auto-register", "false", "camel.k.customizer.webhook.enabled", "true", "camel.k.customizer.webhook.action", action.name()); runtime.getCamelContext().addComponent( "dummy", new DummyWebhookComponent( () -> { throw new RuntimeException("dummy error"); }, () -> { throw new RuntimeException("dummy error"); }) ); runtime.addListener(new ContextConfigurer()); runtime.addListener(RoutesConfigurer.forRoutes("classpath:webhook.js")); Assertions.assertThrows(FailedToCreateRouteException.class, runtime::run); }
Example #7
Source File: RepositoryTests.java From skara with GNU General Public License v2.0 | 6 votes |
@ParameterizedTest @EnumSource(VCS.class) void testCommitMetadata(VCS vcs) throws IOException { try (var dir = new TemporaryDirectory()) { var r = Repository.init(dir.path(), vcs); var readme = dir.path().resolve("README"); Files.write(readme, List.of("Hello, world!")); r.add(readme); var first = r.commit("Added README", "duke", "[email protected]"); Files.write(readme, List.of("One more line"), WRITE, APPEND); r.add(readme); var second = r.commit("Modified README", "duke", "[email protected]"); var metadata = r.commitMetadata(); assertEquals(2, metadata.size()); assertEquals(second, metadata.get(0).hash()); assertEquals(List.of("Modified README"), metadata.get(0).message()); assertEquals(first, metadata.get(1).hash()); assertEquals(List.of("Added README"), metadata.get(1).message()); } }
Example #8
Source File: WebrevTests.java From skara with GNU General Public License v2.0 | 6 votes |
@ParameterizedTest @EnumSource(VCS.class) void simple(VCS vcs) throws IOException { try (var repoFolder = new TemporaryDirectory(); var webrevFolder = new TemporaryDirectory()) { var repo = Repository.init(repoFolder.path(), vcs); var file = repoFolder.path().resolve("x.txt"); Files.writeString(file, "1\n2\n3\n", StandardCharsets.UTF_8); repo.add(file); var hash1 = repo.commit("Commit", "a", "[email protected]"); Files.writeString(file, "1\n2\n3\n4\n", StandardCharsets.UTF_8); repo.add(file); var hash2 = repo.commit("Commit 2", "a", "[email protected]"); new Webrev.Builder(repo, webrevFolder.path()).generate(hash1, hash2); assertContains(webrevFolder.path().resolve("x.txt"), "1\n2\n3\n4\n"); assertContains(webrevFolder.path().resolve("index.html"), "<td>1 lines changed; 1 ins; 0 del; 0 mod; 3 unchg</td>"); } }
Example #9
Source File: WebrevTests.java From skara with GNU General Public License v2.0 | 6 votes |
@ParameterizedTest @EnumSource(VCS.class) void middle(VCS vcs) throws IOException { try (var repoFolder = new TemporaryDirectory(); var webrevFolder = new TemporaryDirectory()) { var repo = Repository.init(repoFolder.path(), vcs); var file = repoFolder.path().resolve("x.txt"); Files.writeString(file, "1\n2\n3\n4\n5\n6\n7\n8\n9\n", StandardCharsets.UTF_8); repo.add(file); var hash1 = repo.commit("Commit", "a", "[email protected]"); Files.writeString(file, "1\n2\n3\n4\n5\n5.1\n5.2\n6\n7\n8\n9\n", StandardCharsets.UTF_8); repo.add(file); var hash2 = repo.commit("Commit 2", "a", "[email protected]"); new Webrev.Builder(repo, webrevFolder.path()).generate(hash1, hash2); assertContains(webrevFolder.path().resolve("index.html"), "<td>2 lines changed; 2 ins; 0 del; 0 mod; 9 unchg</td>"); } }
Example #10
Source File: WebrevTests.java From skara with GNU General Public License v2.0 | 6 votes |
@ParameterizedTest @EnumSource(VCS.class) void emptySourceHunk(VCS vcs) throws IOException { try (var repoFolder = new TemporaryDirectory(); var webrevFolder = new TemporaryDirectory()) { var repo = Repository.init(repoFolder.path(), vcs); var file = repoFolder.path().resolve("x.txt"); Files.writeString(file, "1\n2\n3\n", StandardCharsets.UTF_8); repo.add(file); var hash1 = repo.commit("Commit", "a", "[email protected]"); Files.writeString(file, "0\n1\n2\n3\n", StandardCharsets.UTF_8); repo.add(file); var hash2 = repo.commit("Commit 2", "a", "[email protected]"); new Webrev.Builder(repo, webrevFolder.path()).generate(hash1, hash2); assertContains(webrevFolder.path().resolve("index.html"), "<td>1 lines changed; 1 ins; 0 del; 0 mod; 3 unchg</td>"); } }
Example #11
Source File: WebrevTests.java From skara with GNU General Public License v2.0 | 6 votes |
@ParameterizedTest @EnumSource(VCS.class) void removeBinaryFile(VCS vcs) throws IOException { try (var tmp = new TemporaryDirectory()) { var repo = Repository.init(tmp.path().resolve("repo"), vcs); var binaryFile = repo.root().resolve("x.jpg"); byte[] contents = {0x1, 0x2, 0x3, 0x4, 0x5, 0x0, 0x2, 0x3, 0x4, 0x5}; Files.write(binaryFile, contents); repo.add(binaryFile); var hash1 = repo.commit("Added binary file", "a", "[email protected]"); repo.remove(binaryFile); var hash2 = repo.commit("Removed binary file", "a", "[email protected]"); new Webrev.Builder(repo, tmp.path().resolve("webrev")).generate(hash1, hash2); } }
Example #12
Source File: RepositoryTests.java From skara with GNU General Public License v2.0 | 6 votes |
@ParameterizedTest @EnumSource(VCS.class) void testIsClean(VCS vcs) throws IOException { try (var dir = new TemporaryDirectory()) { var r = Repository.init(dir.path(), vcs); assertTrue(r.isClean()); var readme = dir.path().resolve("README"); Files.write(readme, List.of("Hello, world!")); assertFalse(r.isClean()); r.add(readme); assertFalse(r.isClean()); r.commit("Added README", "duke", "[email protected]"); assertTrue(r.isClean()); Files.delete(readme); assertFalse(r.isClean()); Files.write(readme, List.of("Hello, world!")); assertTrue(r.isClean()); } }
Example #13
Source File: RepositoryTests.java From skara with GNU General Public License v2.0 | 6 votes |
@ParameterizedTest @EnumSource(VCS.class) void testNonCheckedOutRepositoryIsHealthy(VCS vcs) throws IOException { try (var dir1 = new TemporaryDirectory(); var dir2 = new TemporaryDirectory()) { var r1 = Repository.init(dir1.path(), vcs); var readme = dir1.path().resolve("README"); Files.write(readme, List.of("Hello, readme!")); r1.add(readme); var hash = r1.commit("Add README", "duke", "[email protected]"); r1.tag(hash, "tag", "tagging", "duke", "[email protected]"); var r2 = Repository.init(dir2.path(), vcs); r2.fetch(r1.root().toUri(), r1.defaultBranch().name()); assertTrue(r2.isHealthy()); } }
Example #14
Source File: RepositoryTests.java From skara with GNU General Public License v2.0 | 6 votes |
@ParameterizedTest @EnumSource(VCS.class) void testRemoteBranches(VCS vcs) throws IOException { try (var dir = new TemporaryDirectory()) { var upstream = Repository.init(dir.path().resolve("upstream"), vcs); var readme = upstream.root().resolve("README"); Files.writeString(readme, "Hello\n"); upstream.add(readme); var head = upstream.commit("Added README", "duke", "[email protected]"); var fork = Repository.init(dir.path().resolve("fork"), vcs); fork.addRemote("upstream", upstream.root().toUri().toString()); var refs = fork.remoteBranches("upstream"); assertEquals(1, refs.size()); var ref = refs.get(0); assertEquals(head, ref.hash()); assertEquals(upstream.defaultBranch().name(), ref.name()); } }
Example #15
Source File: RepositoryTests.java From skara with GNU General Public License v2.0 | 6 votes |
@ParameterizedTest @EnumSource(VCS.class) void testCheckout(VCS vcs) throws IOException { try (var dir = new TemporaryDirectory()) { var r = Repository.init(dir.path(), vcs); var readme = dir.path().resolve("README"); Files.write(readme, List.of("Hello, readme!")); r.add(readme); var head1 = r.commit("Add README", "duke", "[email protected]"); assertEquals(head1, r.head()); Files.write(readme, List.of("Another line"), WRITE, APPEND); r.add(readme); var head2 = r.commit("Add one more line", "duke", "[email protected]"); assertEquals(head2, r.head()); r.checkout(head1, false); assertEquals(head1, r.head()); r.checkout(head2, false); assertEquals(head2, r.head()); } }
Example #16
Source File: RepositoryTests.java From skara with GNU General Public License v2.0 | 6 votes |
@ParameterizedTest @EnumSource(VCS.class) void testCleanIgnored(VCS vcs) throws IOException { try (var dir = new TemporaryDirectory()) { var r = Repository.init(dir.path(), vcs); r.clean(); var readme = dir.path().resolve("README"); Files.write(readme, List.of("Hello, readme!")); Files.write(dir.path().resolve(".gitignore"), List.of("*.txt")); Files.write(dir.path().resolve(".hgignore"), List.of(".*txt")); r.add(readme); var hash1 = r.commit("Add README", "duke", "[email protected]"); var ignored = dir.path().resolve("ignored.txt"); Files.write(ignored, List.of("Random text")); r.clean(); assertFalse(Files.exists(ignored)); } }
Example #17
Source File: RepositoryTests.java From skara with GNU General Public License v2.0 | 6 votes |
@ParameterizedTest @EnumSource(VCS.class) void testContains(VCS vcs) throws IOException { try (var dir = new TemporaryDirectory()) { var r = Repository.init(dir.path(), vcs); assertTrue(r.isClean()); var f = dir.path().resolve("README"); Files.writeString(f, "Hello\n"); r.add(f); var initial = r.commit("Initial commit", "duke", "[email protected]"); assertTrue(r.contains(r.defaultBranch(), initial)); Files.writeString(f, "Hello again\n"); r.add(f); var second = r.commit("Second commit", "duke", "[email protected]"); assertTrue(r.contains(r.defaultBranch(), initial)); } }
Example #18
Source File: WebrevTests.java From skara with GNU General Public License v2.0 | 6 votes |
@ParameterizedTest @EnumSource(VCS.class) void addBinaryFile(VCS vcs) throws IOException { try (var tmp = new TemporaryDirectory()) { var repo = Repository.init(tmp.path().resolve("repo"), vcs); var readme = repo.root().resolve("README"); Files.writeString(readme, "Hello\n"); repo.add(readme); var hash1 = repo.commit("Added readme", "a", "a@a"); var binaryFile = repo.root().resolve("x.jpg"); byte[] contents = {0x1, 0x2, 0x3, 0x4, 0x5, 0x0, 0x2, 0x3, 0x4, 0x5}; Files.write(binaryFile, contents); repo.add(binaryFile); var hash2 = repo.commit("Added binary file", "a", "[email protected]"); new Webrev.Builder(repo, tmp.path().resolve("webrev")).generate(hash1, hash2); } }
Example #19
Source File: WebrevTests.java From skara with GNU General Public License v2.0 | 6 votes |
@ParameterizedTest @EnumSource(VCS.class) void removedHeader(VCS vcs) throws IOException { try (var repoFolder = new TemporaryDirectory(); var webrevFolder = new TemporaryDirectory()) { var repo = Repository.init(repoFolder.path(), vcs); var file = repoFolder.path().resolve("x.txt"); Files.writeString(file, "1\n2\n3\n4\n5\n6\n7\n8\n9\n", StandardCharsets.UTF_8); repo.add(file); var hash1 = repo.commit("Commit", "a", "[email protected]"); Files.writeString(file, "5\n6\n7\n8\n9\n", StandardCharsets.UTF_8); repo.add(file); var hash2 = repo.commit("Commit 2", "a", "[email protected]"); new Webrev.Builder(repo, webrevFolder.path()).generate(hash1, hash2); assertContains(webrevFolder.path().resolve("index.html"), "<td>4 lines changed; 0 ins; 4 del; 0 mod; 1 unchg</td>"); } }
Example #20
Source File: JCheckTests.java From skara with GNU General Public License v2.0 | 5 votes |
@ParameterizedTest @EnumSource(VCS.class) void checkRemoval(VCS vcs) throws Exception { try (var dir = new TemporaryDirectory()) { var repoPath = dir.path().resolve("repo"); var repo = CheckableRepository.create(repoPath, vcs); var file = repoPath.resolve("file.txt"); Files.write(file, List.of("Hello, file!")); repo.add(file); var first = repo.commit("Add file", "duke", "[email protected]"); Files.delete(file); repo.remove(file); var second = repo.commit("Remove file", "duke", "[email protected]"); var censusPath = dir.path().resolve("census"); Files.createDirectories(censusPath); CensusCreator.populateCensusDirectory(censusPath); var census = Census.parse(censusPath); var visitor = new TestVisitor(); try (var issues = JCheck.check(repo, census, CommitMessageParsers.v1, first.hex() + ".." + second.hex(), Map.of(), Set.of())) { for (var issue : issues) { issue.accept(visitor); } } assertEquals(Set.of("org.openjdk.skara.jcheck.TooFewReviewersIssue"), visitor.issueNames()); } }
Example #21
Source File: RepositoryTests.java From skara with GNU General Public License v2.0 | 5 votes |
@ParameterizedTest @EnumSource(VCS.class) void testNonEmptyRepositoryIsHealthy(VCS vcs) throws IOException { try (var dir = new TemporaryDirectory()) { var r = Repository.init(dir.path(), vcs); var readme = dir.path().resolve("README"); Files.write(readme, List.of("Hello, readme!")); r.add(readme); r.commit("Add README", "duke", "[email protected]"); assertTrue(r.isHealthy()); } }
Example #22
Source File: RepositoryTests.java From skara with GNU General Public License v2.0 | 5 votes |
@ParameterizedTest @EnumSource(VCS.class) void testSubmodulesOnEmptyRepo(VCS vcs) throws IOException { try (var dir = new TemporaryDirectory()) { var repo = Repository.init(dir.path(), vcs); assertEquals(List.of(), repo.submodules()); } }
Example #23
Source File: RepositoryTests.java From skara with GNU General Public License v2.0 | 5 votes |
@ParameterizedTest @EnumSource(VCS.class) void testBranchesOnNonEmptyRepository(VCS vcs) throws IOException { try (var dir = new TemporaryDirectory()) { var r = Repository.init(dir.path(), vcs); var readme = dir.path().resolve("README"); Files.write(readme, List.of("Hello, readme!")); r.add(readme); r.commit("Add README", "duke", "[email protected]"); assertEquals(List.of(r.defaultBranch()), r.branches()); } }
Example #24
Source File: RepositoryTests.java From skara with GNU General Public License v2.0 | 5 votes |
@ParameterizedTest @EnumSource(VCS.class) void testRangeExclusive(VCS vcs) throws IOException { try (var dir = new TemporaryDirectory()) { var repo = Repository.init(dir.path(), vcs); var range = repo.rangeExclusive(new Hash("01234"), new Hash("56789")); if (vcs == VCS.GIT) { assertEquals("01234..56789", range); } else if (vcs == VCS.HG) { assertEquals("01234:56789-01234", range); } else { fail("Unexpected vcs: " + vcs); } } }
Example #25
Source File: RepositoryTests.java From skara with GNU General Public License v2.0 | 5 votes |
@ParameterizedTest @EnumSource(VCS.class) void testRangeSingle(VCS vcs) throws IOException { try (var dir = new TemporaryDirectory()) { var repo = Repository.init(dir.path(), vcs); var range = repo.range(new Hash("0123456789")); if (vcs == VCS.GIT) { assertEquals("0123456789^!", range); } else if (vcs == VCS.HG) { assertEquals("0123456789", range); } else { fail("Unexpected vcs: " + vcs); } } }
Example #26
Source File: RepositoryTests.java From skara with GNU General Public License v2.0 | 5 votes |
@ParameterizedTest @EnumSource(VCS.class) void testReset(VCS vcs) throws IOException { assumeTrue(vcs == VCS.GIT); // FIXME reset is not yet implemented for HG try (var dir = new TemporaryDirectory()) { var repo = Repository.init(dir.path(), vcs); assertTrue(repo.isClean()); var f = dir.path().resolve("README"); Files.writeString(f, "Hello\n"); repo.add(f); var initial = repo.commit("Initial commit", "duke", "[email protected]"); Files.writeString(f, "Hello again\n"); repo.add(f); var second = repo.commit("Second commit", "duke", "[email protected]"); assertEquals(second, repo.head()); assertEquals(2, repo.commits().asList().size()); repo.reset(initial, true); assertEquals(initial, repo.head()); assertEquals(1, repo.commits().asList().size()); } }
Example #27
Source File: RepositoryTests.java From skara with GNU General Public License v2.0 | 5 votes |
@ParameterizedTest @EnumSource(VCS.class) void testDefaultBranch(VCS vcs) throws IOException { try (var dir = new TemporaryDirectory()) { var r = Repository.init(dir.path(), vcs); var expected = vcs == VCS.GIT ? "master" : "default"; assertEquals(expected, r.defaultBranch().name()); } }
Example #28
Source File: RepositoryTests.java From skara with GNU General Public License v2.0 | 5 votes |
@ParameterizedTest @EnumSource(VCS.class) void testFiles(VCS vcs) throws IOException { try (var dir = new TemporaryDirectory()) { var r = Repository.init(dir.path(), vcs); assertTrue(r.isClean()); var f = dir.path().resolve("README"); Files.writeString(f, "Hello\n"); r.add(f); var initial = r.commit("Initial commit", "duke", "[email protected]"); var entries = r.files(initial); assertEquals(1, entries.size()); var entry = entries.get(0); assertEquals(Path.of("README"), entry.path()); assertTrue(entry.type().isRegularNonExecutable()); var f2 = dir.path().resolve("CONTRIBUTING"); Files.writeString(f2, "Hello\n"); r.add(f2); var second = r.commit("Second commit", "duke", "[email protected]"); entries = r.files(second); assertEquals(2, entries.size()); assertTrue(entries.stream().allMatch(e -> e.type().isRegularNonExecutable())); var paths = entries.stream().map(FileEntry::path).collect(Collectors.toSet()); assertTrue(paths.contains(Path.of("README"))); assertTrue(paths.contains(Path.of("CONTRIBUTING"))); entries = r.files(second, Path.of("README")); assertEquals(1, entries.size()); entry = entries.get(0); assertEquals(Path.of("README"), entry.path()); assertTrue(entry.type().isRegularNonExecutable()); } }
Example #29
Source File: RepositoryTests.java From skara with GNU General Public License v2.0 | 5 votes |
@ParameterizedTest @EnumSource(VCS.class) void testPaths(VCS vcs) throws IOException { try (var dir = new TemporaryDirectory()) { var r = Repository.init(dir.path(), vcs); var remote = vcs == VCS.GIT ? "origin" : "default"; r.setPaths(remote, "http://pull", "http://push"); assertEquals("http://pull", r.pullPath(remote)); assertEquals("http://push", r.pushPath(remote)); } }
Example #30
Source File: RepositoryStorageTests.java From skara with GNU General Public License v2.0 | 5 votes |
@ParameterizedTest @EnumSource(VCS.class) void multiple(VCS vcs) throws IOException { var tmpDir = Files.createTempDirectory("repositorystorage"); var repository = Repository.init(tmpDir, vcs); var storage = stringStorage(repository); assertEquals(Set.of(), storage.current()); storage.put(Set.of("hello", "there")); assertEquals(Set.of("hello", "there"), storage.current()); }