URIBuilder.after(); } finally { try {
@cucumber.api.java.Before(order = 1) public void before() throws Throwable { TestRepoURIBuilder builder = new PGWebTestRepoURIBuilder(); builder.before(); TestRepoURIBuilderProvider.setURIBuilder(builder); }
private String replaceKnownVariables(String s) throws IOException { if (s.contains("${currentdir}")) { File pwd = localRepo.platform.pwd(); s = s.replace("${currentdir}", pwd.getCanonicalPath().replace("\\", "/")); s = s.replace("\"", ""); } if (s.contains("${repoURI}")) { URI uri = localRepo.repositoryURI; s = s.replace("${repoURI}", uri.toString()); } if (s.contains("${localrepo}")) { URI uri = localRepo.repositoryURI; s = s.replace("${localrepo}", uri.toString()); } if (s.contains("${remoterepo}")) { CLIContext remote = contextProvider.getRepositoryContext("remoterepo"); URI remoteURI = remote.repositoryURI; s = s.replace("${remoterepo}", remoteURI.toString()); } if (s.contains("${remote repo}")) { CLIContext remote = contextProvider.getRepositoryContext("remote repo"); URI remoteURI = remote.repositoryURI; s = s.replace("${remote repo}", remoteURI.toString()); } if (s.contains("${rootRepoURI}")) { URI rootRepoURI = contextProvider.getURIBuilder().buildRootURI(localRepo.platform); s = s.replace("${rootRepoURI}", rootRepoURI.toString()); } return s; }
/** * Initialized method for cucumber tests/scenarios annotated with {@code @FileSystemReposOnly}; * runs after {@link #before()} and replaces the {@link TestRepoURIBuilder} potentially * overwritten by another steps definition class by the default one that sets up {@code file://} * URI's. */ @cucumber.api.java.Before(value = "@FileSystemReposOnly", order = 2) public void beforeFileOnlyTest() throws Throwable { // force using file based repos only CLIContextProvider provider = CLIContextProvider.get(); provider.setURIBuilder(TestRepoURIBuilder.createDefault()); }
/** * Obtains or creates the repository context for the repository named after {@code repoName} * <p> * The context's {@link Platform} is initialized to point to this provider's temporaty folder * home and working dir directories , and it's global config database is initialized with * default {@code user.name} and {@code user.email} values. */ public CLIContext getOrCreateRepositoryContext(final String repoName) throws Exception { CLIContext context = this.repositories.get(repoName); if (context == null) { File homeDirectory = this.homeDir; File workDir = this.workingDir; TestPlatform platform = new TestPlatform(workDir, homeDirectory); URI repoURI = URIBuilder.newRepositoryURI(repoName, platform); context = new CLIContext(repoURI, platform); context.geogigCLI.execute("config", "--global", "user.name", "gabriel"); context.geogigCLI.execute("config", "--global", "user.email", "gabriel@example.com"); repositories.put(repoName, context); } return context; }
/** * Initialized method for cucumber tests/scenarios annotated with {@code @FileSystemReposOnly}; * runs after {@link #before()} and replaces the {@link TestRepoURIBuilder} potentially * overwritten by another steps definition class by the default one that sets up {@code file://} * URI's. */ @cucumber.api.java.Before(value = "@FileSystemReposOnly", order = 2) public void beforeFileOnlyTest() throws Throwable { // force using file based repos only CLIContextProvider provider = CLIContextProvider.get(); provider.setURIBuilder(TestRepoURIBuilder.createDefault()); }
/** * Obtains or creates the repository context for the repository named after {@code repoName} * <p> * The context's {@link Platform} is initialized to point to this provider's temporaty folder * home and working dir directories , and it's global config database is initialized with * default {@code user.name} and {@code user.email} values. */ public CLIContext getOrCreateRepositoryContext(final String repoName) throws Exception { CLIContext context = this.repositories.get(repoName); if (context == null) { File homeDirectory = this.homeDir; File workDir = this.workingDir; TestPlatform platform = new TestPlatform(workDir, homeDirectory); URI repoURI = URIBuilder.newRepositoryURI(repoName, platform); context = new CLIContext(repoURI, platform); context.geogigCLI.execute("config", "--global", "user.name", "gabriel"); context.geogigCLI.execute("config", "--global", "user.email", "gabriel@example.com"); repositories.put(repoName, context); } return context; }
/** * Initialized method for cucumber tests/scenarios annotated with {@code @FileSystemReposOnly}; * runs after {@link #before()} and replaces the {@link TestRepoURIBuilder} potentially * overwritten by another steps definition class by the default one that sets up {@code file://} * URI's. */ @cucumber.api.java.Before(value = "@FileSystemReposOnly", order = 2) public void beforeFileOnlyTest() throws Throwable { // force using file based repos only CLIContextProvider provider = CLIContextProvider.get(); provider.setURIBuilder(TestRepoURIBuilder.createDefault()); }
/** * Initializes this context provider to set up the initial context (temporary folder with * "userhome" and "data" directories to be used as the repositories home and workingdir folders * respectively; initialization of the {@link GlobalContextBuilder} to use * {@link CLITestContextBuilder}, and {@link TestRepoURIBuilder#before()} initialization in case * it needs to set up temporary resources. * <p> * This mehtod is idempotent, only the first call makes effect, hence it's safe to call it from * any step definition class where it's used. */ public synchronized void before() throws Throwable { if (tempFolder != null) { return; } URIBuilder.before(); tempFolder = new TemporaryFolder(); tempFolder.create(); TestFeatures.setupFeatures(); this.homeDir = tempFolder.newFolder("userhome"); this.workingDir = tempFolder.newFolder("data"); CLITestContextBuilder testContextBuilder = new CLITestContextBuilder( new TestPlatform(workingDir, homeDir)); GlobalContextBuilder.builder(testContextBuilder); }
private String replaceKnownVariables(String s) throws IOException { if (s.contains("${currentdir}")) { File pwd = localRepo.platform.pwd(); s = s.replace("${currentdir}", pwd.getCanonicalPath().replace("\\", "/")); s = s.replace("\"", ""); } if (s.contains("${repoURI}")) { URI uri = localRepo.repositoryURI; s = s.replace("${repoURI}", uri.toString()); } if (s.contains("${localrepo}")) { URI uri = localRepo.repositoryURI; s = s.replace("${localrepo}", uri.toString()); } if (s.contains("${remoterepo}")) { CLIContext remote = contextProvider.getRepositoryContext("remoterepo"); URI remoteURI = remote.repositoryURI; s = s.replace("${remoterepo}", remoteURI.toString()); } if (s.contains("${remote repo}")) { CLIContext remote = contextProvider.getRepositoryContext("remote repo"); URI remoteURI = remote.repositoryURI; s = s.replace("${remote repo}", remoteURI.toString()); } if (s.contains("${rootRepoURI}")) { URI rootRepoURI = contextProvider.getURIBuilder().buildRootURI(localRepo.platform); s = s.replace("${rootRepoURI}", rootRepoURI.toString()); } return s; }
URIBuilder.after(); } finally { try {
/** * Obtains or creates the repository context for the repository named after {@code repoName} * <p> * The context's {@link Platform} is initialized to point to this provider's temporaty folder * home and working dir directories , and it's global config database is initialized with * default {@code user.name} and {@code user.email} values. */ public CLIContext getOrCreateRepositoryContext(final String repoName) throws Exception { CLIContext context = this.repositories.get(repoName); if (context == null) { File homeDirectory = this.homeDir; File workDir = this.workingDir; TestPlatform platform = new TestPlatform(workDir, homeDirectory); URI repoURI = URIBuilder.newRepositoryURI(repoName, platform); context = new CLIContext(repoURI, platform); context.geogigCLI.execute("config", "--global", "user.name", "gabriel"); context.geogigCLI.execute("config", "--global", "user.email", "gabriel@example.com"); repositories.put(repoName, context); } return context; }
@cucumber.api.java.Before public void before() throws Exception { if (TestRepoURIBuilderProvider.getURIBuilder() == null) { TestRepoURIBuilderProvider.setURIBuilder(TestRepoURIBuilder.createDefault()); } // before each Scenario, clear out the opened repository set openedRepos.clear(); context.before(); }
/** * Initializes this context provider to set up the initial context (temporary folder with * "userhome" and "data" directories to be used as the repositories home and workingdir folders * respectively; initialization of the {@link GlobalContextBuilder} to use * {@link CLITestContextBuilder}, and {@link TestRepoURIBuilder#before()} initialization in case * it needs to set up temporary resources. * <p> * This mehtod is idempotent, only the first call makes effect, hence it's safe to call it from * any step definition class where it's used. */ public synchronized void before() throws Throwable { if (tempFolder != null) { return; } URIBuilder.before(); tempFolder = new TemporaryFolder(); tempFolder.create(); TestFeatures.setupFeatures(); this.homeDir = tempFolder.newFolder("userhome"); this.workingDir = tempFolder.newFolder("data"); CLITestContextBuilder testContextBuilder = new CLITestContextBuilder( new TestPlatform(workingDir, homeDir)); GlobalContextBuilder.builder(testContextBuilder); }
private String replaceKnownVariables(String s) throws IOException { if (s.contains("${currentdir}")) { File pwd = localRepo.platform.pwd(); s = s.replace("${currentdir}", pwd.getCanonicalPath().replace("\\", "/")); s = s.replace("\"", ""); } if (s.contains("${repoURI}")) { URI uri = localRepo.repositoryURI; s = s.replace("${repoURI}", uri.toString()); } if (s.contains("${localrepo}")) { URI uri = localRepo.repositoryURI; s = s.replace("${localrepo}", uri.toString()); } if (s.contains("${remoterepo}")) { CLIContext remote = contextProvider.getRepositoryContext("remoterepo"); URI remoteURI = remote.repositoryURI; s = s.replace("${remoterepo}", remoteURI.toString()); } if (s.contains("${remote repo}")) { CLIContext remote = contextProvider.getRepositoryContext("remote repo"); URI remoteURI = remote.repositoryURI; s = s.replace("${remote repo}", remoteURI.toString()); } if (s.contains("${rootRepoURI}")) { URI rootRepoURI = contextProvider.getURIBuilder().buildRootURI(localRepo.platform); s = s.replace("${rootRepoURI}", rootRepoURI.toString()); } return s; }
URIBuilder.after(); } finally { try {
/** * Create a repository with the given name for testing. * * @param name the repository name * @return a newly created {@link TestData} for the repository. * @throws Exception */ @Override protected TestData createRepo(final String name) throws Exception { URI repoURI = TestRepoURIBuilderProvider.getURIBuilder().newRepositoryURI(name, platform); Hints hints = new Hints().uri(repoURI); Context repoContext = GlobalContextBuilder.builder().build(hints); GeoGIG geogig = new GeoGIG(repoContext); TestData testData = new TestData(geogig); return testData; }
@cucumber.api.java.Before(order = 1000) // order = 1000 to make sure it runs the latest if the // @Before annotated methods public void before(Scenario scenario) throws Throwable { contextProvider = CLIContextProvider.get(); if (contextProvider.getURIBuilder() == null) { contextProvider.setURIBuilder(TestRepoURIBuilder.createDefault()); } LOG.info("'{}': Using URIBuilder {}", scenario.getName(), contextProvider.getURIBuilder().getClass().getSimpleName()); contextProvider.before(); this.localRepo = contextProvider.getOrCreateRepositoryContext("localrepo"); RevFeatureType rft = RevFeatureTypeBuilder.build(TestFeatures.pointsType); setVariable("@PointsTypeID", rft.getId().toString()); rft = RevFeatureTypeBuilder.build(TestFeatures.linesType); setVariable("@LinesTypeID", rft.getId().toString()); }
/** * Initializes this context provider to set up the initial context (temporary folder with * "userhome" and "data" directories to be used as the repositories home and workingdir folders * respectively; initialization of the {@link GlobalContextBuilder} to use * {@link CLITestContextBuilder}, and {@link TestRepoURIBuilder#before()} initialization in case * it needs to set up temporary resources. * <p> * This mehtod is idempotent, only the first call makes effect, hence it's safe to call it from * any step definition class where it's used. */ public synchronized void before() throws Throwable { if (tempFolder != null) { return; } URIBuilder.before(); tempFolder = new TemporaryFolder(); tempFolder.create(); TestFeatures.setupFeatures(); this.homeDir = tempFolder.newFolder("userhome"); this.workingDir = tempFolder.newFolder("data"); CLITestContextBuilder testContextBuilder = new CLITestContextBuilder( new TestPlatform(workingDir, homeDir)); GlobalContextBuilder.builder(testContextBuilder); }
/** * Set up the context for a scenario. */ @Override protected void setUp() throws Exception { File rootFolder = tempFolder.getRoot(); this.platform = new TestPlatform(rootFolder); URI rootURI = TestRepoURIBuilderProvider.getURIBuilder().buildRootURI(platform); repoProvider = new MultiRepositoryProvider(rootURI); GlobalContextBuilder.builder(new FunctionalRepoContextBuilder(platform)); setVariable("@systemTempPath", rootFolder.getCanonicalPath().replace("\\", "/")); }