Search in sources :

Example 36 with GeogigCLI

use of org.locationtech.geogig.cli.GeogigCLI in project GeoGig by boundlessgeo.

the class PGListTest method testListException.

@Test
public void testListException() throws Exception {
    ConsoleReader consoleReader = new ConsoleReader(System.in, System.out, new UnsupportedTerminal());
    GeogigCLI mockCli = spy(new GeogigCLI(consoleReader));
    setUpGeogig(mockCli);
    when(mockCli.getConsole()).thenThrow(new MockitoException("Exception"));
    PGList listCommand = new PGList();
    listCommand.dataStoreFactory = TestHelper.createTestFactory();
    exception.expect(MockitoException.class);
    listCommand.run(mockCli);
}
Also used : GeogigCLI(org.locationtech.geogig.cli.GeogigCLI) ConsoleReader(jline.console.ConsoleReader) UnsupportedTerminal(jline.UnsupportedTerminal) MockitoException(org.mockito.exceptions.base.MockitoException) Test(org.junit.Test)

Example 37 with GeogigCLI

use of org.locationtech.geogig.cli.GeogigCLI 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 38 with GeogigCLI

use of org.locationtech.geogig.cli.GeogigCLI in project GeoGig by boundlessgeo.

the class OSMHistoryImportTest method setUp.

@Before
public void setUp() throws Exception {
    ConsoleReader consoleReader = new ConsoleReader(System.in, System.out, new UnsupportedTerminal());
    cli = new GeogigCLI(consoleReader);
    fakeOsmApiUrl = getClass().getResource("../../internal/history/01_10").toExternalForm();
    File workingDirectory = tempFolder.getRoot();
    TestPlatform platform = new TestPlatform(workingDirectory);
    GlobalContextBuilder.builder = new CLITestContextBuilder(platform);
    cli.setPlatform(platform);
    cli.execute("init");
    assertTrue(new File(workingDirectory, ".geogig").exists());
}
Also used : GeogigCLI(org.locationtech.geogig.cli.GeogigCLI) ConsoleReader(jline.console.ConsoleReader) UnsupportedTerminal(jline.UnsupportedTerminal) TestPlatform(org.locationtech.geogig.api.TestPlatform) File(java.io.File) CLITestContextBuilder(org.locationtech.geogig.cli.test.functional.general.CLITestContextBuilder) Before(org.junit.Before)

Example 39 with GeogigCLI

use of org.locationtech.geogig.cli.GeogigCLI in project GeoGig by boundlessgeo.

the class OSMApplyDiffTest method setUp.

@Before
public void setUp() throws Exception {
    ConsoleReader consoleReader = new ConsoleReader(System.in, System.out, new UnsupportedTerminal());
    cli = new GeogigCLI(consoleReader);
    File workingDirectory = tempFolder.getRoot();
    TestPlatform platform = new TestPlatform(workingDirectory);
    GlobalContextBuilder.builder = new CLITestContextBuilder(platform);
    cli.setPlatform(platform);
    cli.execute("init");
    cli.execute("config", "user.name", "Gabriel Roldan");
    cli.execute("config", "user.email", "groldan@boundlessgeo.com");
    assertTrue(new File(workingDirectory, ".geogig").exists());
}
Also used : GeogigCLI(org.locationtech.geogig.cli.GeogigCLI) ConsoleReader(jline.console.ConsoleReader) UnsupportedTerminal(jline.UnsupportedTerminal) TestPlatform(org.locationtech.geogig.api.TestPlatform) File(java.io.File) CLITestContextBuilder(org.locationtech.geogig.cli.test.functional.general.CLITestContextBuilder) Before(org.junit.Before)

Example 40 with GeogigCLI

use of org.locationtech.geogig.cli.GeogigCLI in project GeoGig by boundlessgeo.

the class OSMExportSLTest method setUp.

@Before
public void setUp() throws Exception {
    ConsoleReader consoleReader = new ConsoleReader(System.in, System.out, new UnsupportedTerminal());
    cli = new GeogigCLI(consoleReader);
    File workingDirectory = tempFolder.getRoot();
    TestPlatform platform = new TestPlatform(workingDirectory);
    GlobalContextBuilder.builder = new CLITestContextBuilder(platform);
    cli.setPlatform(platform);
    cli.execute("init");
    cli.execute("config", "user.name", "Gabriel Roldan");
    cli.execute("config", "user.email", "groldan@boundlessgeo.com");
    assertTrue(new File(workingDirectory, ".geogig").exists());
    // Use in-memory database to test whether we can load Spatialite extension
    Connection connection = null;
    Throwable thrown = null;
    try {
        Class.forName("org.spatialite.JDBC");
        SQLiteConfig config = new SQLiteConfig();
        config.enableSpatiaLite(true);
        connection = DriverManager.getConnection("jdbc:spatialite::memory:", config.toProperties());
        Statement statement = connection.createStatement();
        statement.execute("SELECT InitSpatialMetaData();");
    } catch (SQLException e) {
        thrown = e;
        thrown.printStackTrace();
    } finally {
        if (connection != null) {
            connection.close();
        }
    }
    if (thrown != null) {
        thrown.printStackTrace();
        Assume.assumeNoException(thrown);
    }
}
Also used : GeogigCLI(org.locationtech.geogig.cli.GeogigCLI) ConsoleReader(jline.console.ConsoleReader) UnsupportedTerminal(jline.UnsupportedTerminal) SQLException(java.sql.SQLException) Statement(java.sql.Statement) Connection(java.sql.Connection) SQLiteConfig(org.spatialite.SQLiteConfig) TestPlatform(org.locationtech.geogig.api.TestPlatform) File(java.io.File) CLITestContextBuilder(org.locationtech.geogig.cli.test.functional.general.CLITestContextBuilder) Before(org.junit.Before)

Aggregations

UnsupportedTerminal (jline.UnsupportedTerminal)42 ConsoleReader (jline.console.ConsoleReader)42 GeogigCLI (org.locationtech.geogig.cli.GeogigCLI)42 Before (org.junit.Before)19 Test (org.junit.Test)15 MockitoException (org.mockito.exceptions.base.MockitoException)12 TestPlatform (org.locationtech.geogig.api.TestPlatform)8 File (java.io.File)7 CLITestContextBuilder (org.locationtech.geogig.cli.test.functional.general.CLITestContextBuilder)7 CommitOp (org.locationtech.geogig.api.porcelain.CommitOp)6 IOException (java.io.IOException)4 ByteArrayInputStream (java.io.ByteArrayInputStream)2 Platform (org.locationtech.geogig.api.Platform)2 FileBackedOutputStream (com.google.common.io.FileBackedOutputStream)1 JsonObject (com.google.gson.JsonObject)1 BufferedOutputStream (java.io.BufferedOutputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1 Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1