use of org.locationtech.geogig.api.Context in project GeoGig by boundlessgeo.
the class DataStoreConcurrencyTest method beforeTest.
@Before
public void beforeTest() throws Exception {
File workingDirectory = tmp.newFolder("repo");
File userHomeDirectory = tmp.newFolder("home");
TestPlatform platform = new TestPlatform(workingDirectory);
platform.setUserHome(userHomeDirectory);
Context injector = new CLITestContextBuilder(platform).build();
GeoGIG geogig = new GeoGIG(injector);
geogig.command(InitOp.class).call();
geogig.command(ConfigOp.class).setAction(ConfigAction.CONFIG_SET).setName("user.name").setValue("gabriel").call();
geogig.command(ConfigOp.class).setAction(ConfigAction.CONFIG_SET).setName("user.email").setValue("gabriel@roldan.example.com").call();
store = new GeoGigDataStore(geogig);
store.createSchema(pointType);
editThreads = Executors.newFixedThreadPool(writeThreadCount, new ThreadFactoryBuilder().setNameFormat("edit-thread-%d").build());
readThreads = Executors.newFixedThreadPool(readThreadCount, new ThreadFactoryBuilder().setNameFormat("read-thread-%d").build());
initialCommitCount = copyOf(store.getGeogig().command(LogOp.class).call()).size();
}
use of org.locationtech.geogig.api.Context in project GeoGig by boundlessgeo.
the class ImportOpTest method testDeleteException.
@Test
public void testDeleteException() throws Exception {
WorkingTree workTree = mock(WorkingTree.class);
Context cmdl = mock(Context.class);
when(cmdl.workingTree()).thenReturn(workTree);
doThrow(new RuntimeException("Exception")).when(workTree).delete(any(String.class));
ImportOp importOp = new ImportOp();
importOp.setContext(cmdl);
importOp.setDataStore(TestHelper.createTestFactory().createDataStore(null));
importOp.setAll(true);
exception.expect(GeoToolsOpException.class);
importOp.call();
}
use of org.locationtech.geogig.api.Context in project GeoGig by boundlessgeo.
the class InitOpTest method testReinitializeExistingRepo.
@Test
public void testReinitializeExistingRepo() throws Exception {
when(injector.repository()).thenReturn(mockRepo);
Optional<Ref> absent = Optional.absent();
when(mockRefParse.call()).thenReturn(absent);
Repository created = init.call();
assertSame(mockRepo, created);
verify(mockUpdateRef, times(3)).call();
verify(mockUpdateSymRef, times(1)).call();
assertTrue(new File(workingDir, ".geogig").exists());
assertTrue(new File(workingDir, ".geogig").isDirectory());
Ref master = new Ref(Ref.MASTER, ObjectId.forString("hash me"));
when(mockRefParse.call()).thenReturn(Optional.of(master));
Context injector = mock(Context.class);
when(injector.command(eq(RefParse.class))).thenReturn(mockRefParse);
when(injector.platform()).thenReturn(platform);
when(injector.repository()).thenReturn(mockRepo);
init.setContext(injector);
assertTrue(ResolveGeogigDir.lookup(platform.pwd()).isPresent());
assertNotNull(init.call());
verify(platform, atLeastOnce()).pwd();
assertTrue(ResolveGeogigDir.lookup(platform.pwd()).isPresent());
verify(injector, never()).command(eq(UpdateRef.class));
verify(injector, never()).command(eq(UpdateSymRef.class));
assertEquals(RevTree.EMPTY, objectDatabase.get(RevTree.EMPTY_TREE_ID));
}
use of org.locationtech.geogig.api.Context in project GeoGig by boundlessgeo.
the class DepthSearchTest method setUp.
@Before
public void setUp() throws IOException {
File envHome = tempFolder.getRoot();
Platform testPlatform = new TestPlatform(envHome);
Context injector = Guice.createInjector(Modules.override(new GeogigModule()).with(new MemoryModule(testPlatform))).getInstance(Context.class);
fakeGeogig = new GeoGIG(injector);
Repository fakeRepo = fakeGeogig.getOrCreateRepository();
odb = fakeRepo.objectDatabase();
search = new DepthSearch(odb);
RevTreeBuilder root = new RevTreeBuilder(odb);
root = addTree(root, "path/to/tree1", "node11", "node12", "node13");
root = addTree(root, "path/to/tree2", "node21", "node22", "node23");
root = addTree(root, "tree3", "node31", "node32", "node33");
RevTree rootTree = root.build();
odb.put(rootTree);
rootTreeId = rootTree.getId();
}
use of org.locationtech.geogig.api.Context in project GeoGig by boundlessgeo.
the class Diff method run.
/**
* Runs the command and builds the appropriate response
*
* @param context - the context to use for this command
*
* @throws CommandSpecException
*/
@Override
public void run(CommandContext context) {
if (oldRefSpec == null || oldRefSpec.trim().isEmpty()) {
throw new CommandSpecException("No old ref spec");
}
final Context geogig = this.getCommandLocator(context);
final Iterator<DiffEntry> diff = geogig.command(DiffOp.class).setOldVersion(oldRefSpec).setNewVersion(newRefSpec).setFilter(pathFilter).call();
context.setResponseContent(new CommandResponse() {
@Override
public void write(ResponseWriter out) throws Exception {
out.start();
if (showGeometryChanges) {
out.writeGeometryChanges(geogig, diff, page, elementsPerPage);
} else {
out.writeDiffEntries("diff", page * elementsPerPage, elementsPerPage, diff);
}
out.finish();
}
});
}
Aggregations