use of org.locationtech.geogig.cli.GeogigCLI in project GeoGig by boundlessgeo.
the class GeoJsonExportTest method setUpInternal.
@Override
public void setUpInternal() throws Exception {
ConsoleReader consoleReader = new ConsoleReader(System.in, System.out, new UnsupportedTerminal());
cli = new GeogigCLI(consoleReader);
cli.setGeogig(geogig);
// Add points
insertAndAdd(points1);
insertAndAdd(points2);
insertAndAdd(points3);
geogig.command(CommitOp.class).call();
// Add lines
insertAndAdd(lines1);
insertAndAdd(lines2);
insertAndAdd(lines3);
geogig.command(CommitOp.class).call();
}
use of org.locationtech.geogig.cli.GeogigCLI in project GeoGig by boundlessgeo.
the class GeoJsonImportTest method setUp.
@Before
public void setUp() throws Exception {
ConsoleReader consoleReader = new ConsoleReader(System.in, System.out, new UnsupportedTerminal());
cli = new GeogigCLI(consoleReader);
setUpGeogig(cli);
}
use of org.locationtech.geogig.cli.GeogigCLI in project GeoGig by boundlessgeo.
the class OracleDescribeTest method testDescribeException.
@Test
public void testDescribeException() 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"));
OracleDescribe describeCommand = new OracleDescribe();
describeCommand.table = "table1";
describeCommand.dataStoreFactory = TestHelper.createTestFactory();
exception.expect(MockitoException.class);
describeCommand.run(mockCli);
}
use of org.locationtech.geogig.cli.GeogigCLI in project GeoGig by boundlessgeo.
the class ConsoleResourceResource method processRequest.
private JsonObject processRequest(JsonObject json, final GeoGIG geogig) {
JsonObject response;
final String command = json.get("method").getAsString();
final String queryId = json.get("id").getAsString();
// not used, we're getting the whole command and args in the "method" object
// JsonArray paramsArray = json.get("params").getAsJsonArray();
InputStream in = new ByteArrayInputStream(new byte[0]);
// dumps output to a temp file if > threshold
FileBackedOutputStream out = new FileBackedOutputStream(4096);
try {
// pass it a BufferedOutputStream 'cause it doesn't buffer the internal FileOutputStream
ConsoleReader console = new ConsoleReader(in, new BufferedOutputStream(out), new UnsupportedTerminal());
Platform platform = geogig.getPlatform();
GeogigCLI geogigCLI = new GeogigCLI(geogig, console);
geogigCLI.setPlatform(platform);
geogigCLI.disableProgressListener();
String[] args = ArgumentTokenizer.tokenize(command);
final int exitCode = geogigCLI.execute(args);
response = new JsonObject();
response.addProperty("id", queryId);
final int charCountLimit = getOutputLimit(geogig.getContext());
final StringBuilder output = getLimitedOutput(out, charCountLimit);
if (exitCode == 0) {
response.addProperty("result", output.toString());
response.addProperty("error", (String) null);
} else {
Exception exception = geogigCLI.exception;
JsonObject error = buildError(exitCode, output, exception);
response.add("error", error);
}
return response;
} catch (IOException e) {
throw Throwables.propagate(e);
} finally {
// delete temp file
try {
out.reset();
} catch (IOException ignore) {
ignore.printStackTrace();
}
}
}
use of org.locationtech.geogig.cli.GeogigCLI in project GeoGig by boundlessgeo.
the class ShpExportTest method setUpInternal.
@Override
public void setUpInternal() throws Exception {
ConsoleReader consoleReader = new ConsoleReader(System.in, System.out, new UnsupportedTerminal());
cli = new GeogigCLI(consoleReader);
cli.setGeogig(geogig);
// Add points
insertAndAdd(points1);
insertAndAdd(points2);
insertAndAdd(points3);
geogig.command(CommitOp.class).call();
// Add lines
insertAndAdd(lines1);
insertAndAdd(lines2);
insertAndAdd(lines3);
geogig.command(CommitOp.class).call();
}
Aggregations