Search in sources :

Example 11 with OConsoleDatabaseApp

use of com.orientechnologies.orient.console.OConsoleDatabaseApp in project orientdb by orientechnologies.

the class OGremlinConsoleTest method testGraphMLImport.

@Test
public void testGraphMLImport() {
    final String INPUT_FILE = "src/test/resources/graph-example-2.xml";
    String dbUrl = "memory:testGraphMLImport";
    StringBuilder builder = new StringBuilder();
    builder.append("create database " + dbUrl + ";\n");
    builder.append("import database " + INPUT_FILE + ";\n");
    OConsoleDatabaseApp console = new TestOGremlinConsole(new String[] { builder.toString() });
    try {
        console.run();
        ODatabaseDocumentTx db = new ODatabaseDocumentTx(dbUrl);
        db.open("admin", "admin");
        try {
            List<ODocument> result = db.query(new OSQLSynchQuery<ODocument>("select from V"));
            Assert.assertFalse(result.isEmpty());
            result = db.query(new OSQLSynchQuery<ODocument>("select from V where name is null"));
            Assert.assertEquals(1, result.size());
        } finally {
            db.close();
        }
    } finally {
        console.close();
    }
}
Also used : OSQLSynchQuery(com.orientechnologies.orient.core.sql.query.OSQLSynchQuery) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) OConsoleDatabaseApp(com.orientechnologies.orient.console.OConsoleDatabaseApp) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.junit.Test)

Aggregations

OConsoleDatabaseApp (com.orientechnologies.orient.console.OConsoleDatabaseApp)11 Test (org.junit.Test)9 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)8 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)5 OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)2 IOException (java.io.IOException)2 TTYConsoleReader (com.orientechnologies.common.console.TTYConsoleReader)1 OSystemException (com.orientechnologies.common.exception.OSystemException)1 OCommandExecutorNotFoundException (com.orientechnologies.orient.core.command.OCommandExecutorNotFoundException)1 ODatabaseDocument (com.orientechnologies.orient.core.db.document.ODatabaseDocument)1 ODatabaseImportException (com.orientechnologies.orient.core.db.tool.ODatabaseImportException)1 OStorageException (com.orientechnologies.orient.core.exception.OStorageException)1 ORecord (com.orientechnologies.orient.core.record.ORecord)1 ORecordBytes (com.orientechnologies.orient.core.record.impl.ORecordBytes)1 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)1 Vertex (com.tinkerpop.blueprints.Vertex)1 OrientBaseGraph (com.tinkerpop.blueprints.impls.orient.OrientBaseGraph)1 OrientGraph (com.tinkerpop.blueprints.impls.orient.OrientGraph)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PrintStream (java.io.PrintStream)1