/** * @param commandAndArgs the command and its arguments. This method is dumb, be careful of not * using arguments that shouldn't be split on a space (like "commit -m 'separate words') */ public void runCommand(String commandAndArgs) throws Exception { runCommand(false, commandAndArgs); }
/** * runs the command, does not fail fast, check {@link CLIContext#exitCode} for the exit code and * {@link GeogigCLI#exception} for any caught exception */ public void runCommand(String... command) throws Exception { runCommand(false, command); }
@Given("^I have a local committer") public void I_have_a_local_committer() throws Throwable { localRepo.runCommand(true, "config", "--local", "user.name", "Jane Doe"); localRepo.runCommand(true, "config", "--local", "user.email", "JaneDoe@example.com"); }
@Given("^I have a local committer") public void I_have_a_local_committer() throws Throwable { localRepo.runCommand(true, "config", "--local", "user.name", "Jane Doe"); localRepo.runCommand(true, "config", "--local", "user.email", "JaneDoe@example.com"); }
@Given("^I create a detached branch") public void I_create_a_detached_branch() throws Throwable { localRepo.runCommand(true, "log --oneline"); String actual = localRepo.stdOut.toString().replaceAll(LINE_SEPARATOR, "") .replaceAll("\\\\", "/"); String[] commitId = actual.split(" "); localRepo.runCommand(true, "checkout " + commitId[0]); }
@Given("^I create a detached branch") public void I_create_a_detached_branch() throws Throwable { localRepo.runCommand(true, "log --oneline"); String actual = localRepo.stdOut.toString().replaceAll(LINE_SEPARATOR, "") .replaceAll("\\\\", "/"); String[] commitId = actual.split(" "); localRepo.runCommand(true, "checkout " + commitId[0]); }
@Given("^I create a detached branch") public void I_create_a_detached_branch() throws Throwable { localRepo.runCommand(true, "log --oneline"); String actual = localRepo.stdOut.toString().replaceAll(LINE_SEPARATOR, "") .replaceAll("\\\\", "/"); String[] commitId = actual.split(" "); localRepo.runCommand(true, "checkout " + commitId[0]); }
@Given("^I have a repository with a remote$") public void I_have_a_repository_with_a_remote() throws Throwable { I_have_an_unconfigured_repository(); CLIContext remoteRepo = createRemote("remoterepo"); final URI remoteURI = remoteRepo.repositoryURI; localRepo.runCommand(true, "config", "--global", "user.name", "John Doe"); localRepo.runCommand(true, "config", "--global", "user.email", "JohnDoe@example.com"); String uriArg = remoteURI.toString(); localRepo.runCommand(true, "remote", "add", "origin", uriArg); }
@Given("^I clone a remote repository$") public void i_clone_a_remote_repository() throws Throwable { there_is_a_remote_repository(); CLIContext remoteRepo = contextProvider.getRepositoryContext("remoterepo"); URI remote = remoteRepo.repositoryURI; URI local = localRepo.repositoryURI; localRepo.runCommand(true, "clone", remote.toString(), local.toString()); localRepo.runCommand(true, "config", "--global", "user.name", "John Doe"); localRepo.runCommand(true, "config", "--global", "user.email", "JohnDoe@example.com"); }
@Given("^I have a repository$") public void I_have_a_repository() throws Throwable { I_have_an_unconfigured_repository(); localRepo.runCommand(true, "config", "--global", "user.name", "John Doe"); localRepo.runCommand(true, "config", "--global", "user.email", "JohnDoe@example.com"); }
/** * Inserts the Feature to the index and stages it to be committed. */ public ObjectId insertAndAdd(Feature f) throws Exception { ObjectId objectId = insert(f); runCommand(true, "add"); return objectId; }
@When("^I run the command \"([^\"]*)\" on the SpatiaLite database$") public void I_run_the_command_on_the_SpatiaLite_database(String commandSpec) throws Throwable { commandSpec += " --database "; commandSpec += getClass().getResource("testdb.sqlite").getPath(); String[] args = commandSpec.split(" "); localRepo.runCommand(args); }
@Given("^I have a repository$") public void I_have_a_repository() throws Throwable { I_have_an_unconfigured_repository(); localRepo.runCommand(true, "config", "--global", "user.name", "John Doe"); localRepo.runCommand(true, "config", "--global", "user.email", "JohnDoe@example.com"); }
@Given("^I have several commits$") public void I_have_several_commits() throws Throwable { localRepo.insertAndAdd(points1, points2); localRepo.runCommand(true, "commit -m Commit1"); localRepo.insertAndAdd(points3, lines1); localRepo.runCommand(true, "commit -m Commit2"); localRepo.insertAndAdd(lines2, lines3); localRepo.runCommand(true, "commit -m Commit3"); localRepo.insertAndAdd(points1_modified); localRepo.runCommand(true, "commit -m Commit4"); }
@Given("^I have several feature types in a path$") public void I_have_several_feature_types_in_a_path() throws Throwable { localRepo.insertAndAdd(points2); localRepo.runCommand(true, "commit -m Commit1"); localRepo.insertAndAdd(points1_FTmodified); localRepo.runCommand(true, "commit -m Commit2"); localRepo.insertAndAdd(points3); localRepo.insertAndAdd(lines1); localRepo.runCommand(true, "commit -m Commit3"); localRepo.insertAndAdd(lines2, lines3); localRepo.runCommand(true, "commit -m Commit4"); }
@Given("^I have several feature types in a path$") public void I_have_several_feature_types_in_a_path() throws Throwable { localRepo.insertAndAdd(points2); localRepo.runCommand(true, "commit -m Commit1"); localRepo.insertAndAdd(points1_FTmodified); localRepo.runCommand(true, "commit -m Commit2"); localRepo.insertAndAdd(points3); localRepo.insertAndAdd(lines1); localRepo.runCommand(true, "commit -m Commit3"); localRepo.insertAndAdd(lines2, lines3); localRepo.runCommand(true, "commit -m Commit4"); }
public List<String> runAndParseCommand(boolean failFast, String... command) throws Exception { runCommand(failFast, command); CharSource reader = CharSource.wrap(stdOut.toString(Charsets.UTF_8.name())); ImmutableList<String> lines = reader.readLines(); return lines; }
@When("^I run the command \"([^\"]*)\" on a new GeoPackage file$") public void I_run_the_command_on_a_new_GeoPackage_file(String commandSpec) throws Throwable { GeoPackageTestSupport support = new GeoPackageTestSupport(); commandSpec += " --database "; commandSpec += support.newFile().getPath(); String[] args = commandSpec.split(" "); localRepo.runCommand(args); }
@When("^I run the command \"(.*?)\"$") public void I_run_the_command_X(String commandSpec) throws Throwable { String[] args = ArgumentTokenizer.tokenize(commandSpec); for (int i = 0; i < args.length; i++) { args[i] = replaceKnownVariables(args[i]); } localRepo.runCommand(args); }
@Given("^the remote repository has changes") public void the_remote_repository_has_changes() throws Throwable { CLIContext remoteRepo = contextProvider.getOrCreateRepositoryContext("remoterepo"); remoteRepo.insertAndAdd(lines3); remoteRepo.runCommand(true, "commit -m Commit10"); }