diff --git a/console/src/main/java/com/arcadedb/console/Console.java b/console/src/main/java/com/arcadedb/console/Console.java index 64ebcb5471..d114bb65a6 100644 --- a/console/src/main/java/com/arcadedb/console/Console.java +++ b/console/src/main/java/com/arcadedb/console/Console.java @@ -55,6 +55,7 @@ public class Console { private static final String PROMPT = "%n%s> "; private static final String REMOTE_PREFIX = "remote:"; + private static final String LOCAL_PREFIX = "local:"; private static final String SQL_LANGUAGE = "SQL"; private final boolean system = System.console() != null; private final Terminal terminal; @@ -714,7 +715,11 @@ private void checkHasSpaces(final String key, final String value) { } private String parseLocalUrl(final String url) { - return databaseDirectory + url.replaceFirst("file://", ""); + if(url.startsWith(LOCAL_PREFIX + "//")) { + return url.replaceFirst(LOCAL_PREFIX + "//", "/"); + } else { + return databaseDirectory + url.replaceFirst("file://", ""); + } } private void connectToRemoteServer(final String url, final Boolean needsDatabase) { diff --git a/console/src/test/java/com/arcadedb/console/ConsoleTest.java b/console/src/test/java/com/arcadedb/console/ConsoleTest.java index 2409047f09..480b7ce141 100644 --- a/console/src/test/java/com/arcadedb/console/ConsoleTest.java +++ b/console/src/test/java/com/arcadedb/console/ConsoleTest.java @@ -40,20 +40,30 @@ public class ConsoleTest { private static final String DB_NAME = "console"; private static Console console; + private static String absoluteDBPath; @BeforeEach public void populate() throws IOException { - FileUtils.deleteRecursively(new File("./target/databases")); + File dbFile = new File("./target/databases"); + absoluteDBPath = dbFile.getAbsolutePath(); + FileUtils.deleteRecursively(dbFile); GlobalConfiguration.SERVER_ROOT_PATH.setValue("./target"); console = new Console(false); Assertions.assertTrue(console.parse("create database " + DB_NAME + "; close", false)); } @AfterEach - public void drop() { + public void drop() throws IOException { console.close(); TestServerHelper.checkActiveDatabases(); - FileUtils.deleteRecursively(new File("target/databases")); + Assertions.assertTrue(console.parse("drop database " + DB_NAME + "; close", false)); + } + + @Test + public void testDropCreateWithLocalUrl() throws IOException { + String localUrl = "local:/" + absoluteDBPath + "/" + DB_NAME; + Assertions.assertTrue(console.parse("drop database " + localUrl + "; close", false)); + Assertions.assertTrue(console.parse("create database " + localUrl + "; close", false)); } @Test @@ -91,6 +101,11 @@ public void testConnect() throws IOException { Assertions.assertTrue(console.parse("connect " + DB_NAME + ";info types", false)); } + @Test + public void testLocalConnect() throws IOException { + Assertions.assertTrue(console.parse("connect local:/" + absoluteDBPath + "/" + DB_NAME + ";info types", false)); + } + @Test public void testSetVerbose() throws IOException { try {