Search in sources :

Example 31 with Platform

use of org.locationtech.geogig.api.Platform in project GeoGig by boundlessgeo.

the class SLImportTest method setUpGeogig.

private void setUpGeogig(GeogigCLI cli) throws Exception {
    final File userhome = tempFolder.newFolder("mockUserHomeDir");
    final File workingDir = tempFolder.newFolder("mockWorkingDir");
    tempFolder.newFolder("mockWorkingDir/.geogig");
    final Platform platform = mock(Platform.class);
    when(platform.pwd()).thenReturn(workingDir);
    when(platform.getUserHome()).thenReturn(userhome);
    cli.setPlatform(platform);
}
Also used : Platform(org.locationtech.geogig.api.Platform) File(java.io.File)

Example 32 with Platform

use of org.locationtech.geogig.api.Platform in project GeoGig by boundlessgeo.

the class SQLServerDescribeTest method setUpGeogig.

private void setUpGeogig(GeogigCLI cli) throws Exception {
    final File userhome = tempFolder.newFolder("mockUserHomeDir");
    final File workingDir = tempFolder.newFolder("mockWorkingDir");
    tempFolder.newFolder("mockWorkingDir/.geogig");
    final Platform platform = mock(Platform.class);
    when(platform.pwd()).thenReturn(workingDir);
    when(platform.getUserHome()).thenReturn(userhome);
    cli.setPlatform(platform);
}
Also used : Platform(org.locationtech.geogig.api.Platform) File(java.io.File)

Example 33 with Platform

use of org.locationtech.geogig.api.Platform in project GeoGig by boundlessgeo.

the class GlobalState method setupGeogig.

public static void setupGeogig() throws Exception {
    assertNotNull(platform);
    stdIn = new ByteArrayInputStream(new byte[0]);
    stdOut = new ByteArrayOutputStream();
    if (GlobalState.consoleReader != null) {
        GlobalState.consoleReader.shutdown();
    }
    // GlobalState.consoleReader = new ConsoleReader(stdIn,
    // new TeeOutputStream(stdOut, System.err), new UnsupportedTerminal());
    GlobalState.consoleReader = new ConsoleReader(stdIn, stdOut, new UnsupportedTerminal());
    ContextBuilder injectorBuilder = new CLITestContextBuilder(platform);
    Context injector = injectorBuilder.build();
    if (geogigCLI != null) {
        geogigCLI.close();
    }
    geogigCLI = new GeogigCLI(GlobalState.consoleReader);
    GlobalContextBuilder.builder = injectorBuilder;
    Platform platform = injector.platform();
    geogigCLI.setPlatform(platform);
    geogigCLI.tryConfigureLogging();
}
Also used : Context(org.locationtech.geogig.api.Context) GeogigCLI(org.locationtech.geogig.cli.GeogigCLI) ConsoleReader(jline.console.ConsoleReader) TestPlatform(org.locationtech.geogig.api.TestPlatform) Platform(org.locationtech.geogig.api.Platform) ByteArrayInputStream(java.io.ByteArrayInputStream) UnsupportedTerminal(jline.UnsupportedTerminal) ContextBuilder(org.locationtech.geogig.api.ContextBuilder) GlobalContextBuilder(org.locationtech.geogig.api.GlobalContextBuilder) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 34 with Platform

use of org.locationtech.geogig.api.Platform in project GeoGig by boundlessgeo.

the class InitOpTest method setUp.

@Before
public void setUp() throws IOException, RepositoryConnectionException {
    injector = mock(Context.class);
    mockRefParse = mock(RefParse.class);
    when(mockRefParse.setName(anyString())).thenReturn(mockRefParse);
    mockUpdateRef = mock(UpdateRef.class);
    when(mockUpdateRef.setName(anyString())).thenReturn(mockUpdateRef);
    when(mockUpdateRef.setDelete(anyBoolean())).thenReturn(mockUpdateRef);
    when(mockUpdateRef.setNewValue((ObjectId) anyObject())).thenReturn(mockUpdateRef);
    when(mockUpdateRef.setOldValue((ObjectId) anyObject())).thenReturn(mockUpdateRef);
    when(mockUpdateRef.setReason(anyString())).thenReturn(mockUpdateRef);
    mockUpdateSymRef = mock(UpdateSymRef.class);
    when(mockUpdateSymRef.setName(anyString())).thenReturn(mockUpdateSymRef);
    when(mockUpdateSymRef.setDelete(anyBoolean())).thenReturn(mockUpdateSymRef);
    when(mockUpdateSymRef.setNewValue(anyString())).thenReturn(mockUpdateSymRef);
    when(mockUpdateSymRef.setOldValue(anyString())).thenReturn(mockUpdateSymRef);
    when(mockUpdateSymRef.setReason(anyString())).thenReturn(mockUpdateSymRef);
    when(injector.command(eq(RefParse.class))).thenReturn(mockRefParse);
    when(injector.command(eq(UpdateRef.class))).thenReturn(mockUpdateRef);
    when(injector.command(eq(UpdateSymRef.class))).thenReturn(mockUpdateSymRef);
    platform = mock(Platform.class);
    when(injector.platform()).thenReturn(platform);
    defaults = PluginDefaults.NO_PLUGINS;
    init = new InitOp(defaults);
    init.setContext(injector);
    mockRepo = mock(Repository.class);
    objectDatabase = new HeapObjectDatabse();
    when(mockRepo.objectDatabase()).thenReturn(objectDatabase);
    Mockito.doAnswer(new Answer<Void>() {

        @Override
        public Void answer(InvocationOnMock invocation) throws Throwable {
            objectDatabase.open();
            return null;
        }
    }).when(mockRepo).open();
    workingDir = tempFolder.getRoot();
    when(platform.pwd()).thenReturn(workingDir);
}
Also used : Context(org.locationtech.geogig.api.Context) Platform(org.locationtech.geogig.api.Platform) HeapObjectDatabse(org.locationtech.geogig.storage.memory.HeapObjectDatabse) UpdateRef(org.locationtech.geogig.api.plumbing.UpdateRef) UpdateSymRef(org.locationtech.geogig.api.plumbing.UpdateSymRef) Repository(org.locationtech.geogig.repository.Repository) InvocationOnMock(org.mockito.invocation.InvocationOnMock) RefParse(org.locationtech.geogig.api.plumbing.RefParse) Before(org.junit.Before)

Example 35 with Platform

use of org.locationtech.geogig.api.Platform in project GeoGig by boundlessgeo.

the class DiffTreeTest method setUp.

@Before
public void setUp() throws Exception {
    File workingDirectory = tempFolder.newFolder("mockWorkingDir");
    Platform testPlatform = new TestPlatform(workingDirectory);
    Context injector = Guice.createInjector(Modules.override(new GeogigModule()).with(new MemoryModule(testPlatform))).getInstance(Context.class);
    geogit = new GeoGIG(injector);
    assertNotNull(geogit.getOrCreateRepository());
    diffTree = geogit.command(DiffTree.class);
    SimpleFeatureType ft = DataUtilities.createType("points", "sp:String,ip:Integer,pp:Point:srid=3857");
    revtype = RevFeatureTypeImpl.build(ft);
    metadataId = revtype.getId();
    geogit.getContext().objectDatabase().put(revtype);
}
Also used : Context(org.locationtech.geogig.api.Context) TestPlatform(org.locationtech.geogig.api.TestPlatform) Platform(org.locationtech.geogig.api.Platform) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) TestPlatform(org.locationtech.geogig.api.TestPlatform) File(java.io.File) GeogigModule(org.locationtech.geogig.di.GeogigModule) MemoryModule(org.locationtech.geogig.api.MemoryModule) GeoGIG(org.locationtech.geogig.api.GeoGIG) Before(org.junit.Before)

Aggregations

Platform (org.locationtech.geogig.api.Platform)41 File (java.io.File)27 TestPlatform (org.locationtech.geogig.api.TestPlatform)10 Before (org.junit.Before)7 Context (org.locationtech.geogig.api.Context)7 GeogigModule (org.locationtech.geogig.di.GeogigModule)6 GeoGIG (org.locationtech.geogig.api.GeoGIG)5 ObjectId (org.locationtech.geogig.api.ObjectId)5 Repository (org.locationtech.geogig.repository.Repository)5 IOException (java.io.IOException)4 UpdateRef (org.locationtech.geogig.api.plumbing.UpdateRef)4 UpdateSymRef (org.locationtech.geogig.api.plumbing.UpdateSymRef)4 CommitBuilder (org.locationtech.geogig.api.CommitBuilder)3 DefaultPlatform (org.locationtech.geogig.api.DefaultPlatform)3 MemoryModule (org.locationtech.geogig.api.MemoryModule)3 RevCommit (org.locationtech.geogig.api.RevCommit)3 RevTree (org.locationtech.geogig.api.RevTree)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 URL (java.net.URL)2 UnsupportedTerminal (jline.UnsupportedTerminal)2