package org.umlg.sqlg.test.tp3;

import org.apache.tinkerpop.gremlin.LoadGraphWith;
import org.umlg.sqlg.PostgresPlugin;
import org.umlg.sqlg.SqlgPlugin;
import org.umlg.sqlg.structure.SqlgGraph;

import java.util.HashMap;
import java.util.Map;

/**
 * Date: 2014/07/13
 * Time: 5:57 PM
 */
public class SqlgPostgresProvider extends SqlgAbstractGraphProvider {

    @Override
    public Map<String, Object> getBaseConfiguration(String graphName, Class<?> test, String testMethodName, LoadGraphWith.GraphData loadGraphWith) {
        return new HashMap<String, Object>() {{
            put("gremlin.graph", SqlgGraph.class.getName());
            put("jdbc.url", "jdbc:postgresql://localhost:5432/" + graphName);
            put("jdbc.username", "postgres");
            put("jdbc.password", "postgres");
            put("maxPoolSize", 10);
        }};
    }

    @Override
    public SqlgPlugin getSqlgPlugin() {
        return new PostgresPlugin();
    }

}

@@ -26,16 +26,150 @@
 t.tp3;%0A%0A
+import java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0Aimport java.util.Properties;%0A%0A
 import o
@@ -211,16 +211,48 @@
 phWith;%0A
+import org.slf4j.LoggerFactory;%0A
 import o
@@ -360,57 +360,8 @@
 h;%0A%0A
-import java.util.HashMap;%0Aimport java.util.Map;%0A%0A
 /**%0A
@@ -635,34 +635,83 @@
 With) %7B%0A    
-    return
+%09System.out.println(graphName);%0A    %09Map%3CString, Object%3E m=
  new HashMap
@@ -1015,18 +1015,772 @@
 %7D%7D;%0A    
-%7D%0A
+    %0A    %09InputStream sqlProperties = Thread.currentThread().getContextClassLoader().getResourceAsStream(%22sqlg.properties%22);%0A        %0A    %09if (sqlProperties!=null)%7B%0A        %09Properties p=new Properties();%0A        %09try %7B%0A%09        %09p.load(sqlProperties);%0A%09        %09sqlProperties.close();%0A%09        %09for (String k:p.stringPropertyNames())%7B%0A%09        %09%09String v=p.getProperty(k);%0A%09        %09%09if (k.equals(%22jdbc.url%22))%7B%0A%09        %09%09%09v=v.substring(0, v.lastIndexOf(%22/%22)+1);%0A%09        %09%09%09v=v+graphName;%0A%09        %09%09%7D%0A%09        %09%09m.put(k, v);%0A%09        %09%7D%0A        %09%7D catch (IOException ioe)%7B%0A        %09%09LoggerFactory.getLogger(getClass()).error(%22Cannot read properties from sqlg.properties%22,ioe.getMessage());%0A        %09%7D%0A%0A        %7D%0A    %09return m;%0A        %0A%0A    %7D%0A%0A    %0A    
 %0A    @Ov

use properties file for Gremlin test