DataAccess implements I_DomainAccess { @Override public DSLContext getContext() { return context; } DataAccess(SQLDialect dialect, String DBURL, String login, String password, I_KnowledgeCache knowledgeManager, I_IntrospectCache introspectCache);  DataAccess(Map<String, Object> properties);  DataAccess(DSLContext context, I_KnowledgeCache knowledgeManager, I_IntrospectCache introspectCache);  DataAccess(I_DomainAccess domainAccess); @Override SQLDialect getDialect(); @Override Connection getConnection(); @Override void releaseConnection(Connection connection); @Override DSLContext getContext(); @Override I_KnowledgeCache getKnowledgeManager(); @Override I_IntrospectCache getIntrospectCache(); @Override I_IntrospectCache initializeIntrospectCache(); @Override void setKnowledgeManager(I_KnowledgeCache knowledgeCache); @Override String getServerNodeId();  }
@Test public void setupPgJdbc42Access() throws Exception { Map<String, Object> properties = new HashMap<>(); properties.put(I_DomainAccess.KEY_KNOWLEDGE, knowledge); properties.put(I_DomainAccess.KEY_DIALECT, "POSTGRES"); properties.put(I_DomainAccess.KEY_URL, "jdbc:postgresql: properties.put(I_DomainAccess.KEY_PGJDBC_PREFIX+".user", System.getProperty("test.db.user")); properties.put(I_DomainAccess.KEY_PGJDBC_PREFIX+".password", System.getProperty("test.db.password")); try { testDomainAccess = new DummyDataAccess(properties); } catch (Exception e) { e.printStackTrace(); } context = testDomainAccess.getContext(); Result result = context.fetch("SELECT 1"); assertEquals("1", result.getValue(0, "?column?").toString()); }
@Test public void setupDBCP2_pgJdbc42Access() throws Exception { Map<String, Object> properties = new HashMap<>(); properties.put(I_DomainAccess.KEY_KNOWLEDGE, knowledge); properties.put(I_DomainAccess.KEY_DIALECT, "POSTGRES"); properties.put(I_DomainAccess.KEY_URL, "jdbc:postgresql: properties.put(I_DomainAccess.KEY_CONNECTION_MODE, I_DomainAccess.DBCP2_POOL); properties.put(I_DomainAccess.KEY_PGJDBC_PREFIX+".user", System.getProperty("test.db.user")); properties.put(I_DomainAccess.KEY_PGJDBC_PREFIX+".password", System.getProperty("test.db.password")); try { testDomainAccess = new DummyDataAccess(properties); } catch (Exception e) { e.printStackTrace(); } context = testDomainAccess.getContext(); Result result = context.fetch("SELECT 1"); assertEquals("1", result.getValue(0, "?column?").toString()); }
@Test public void setupDBCP2Access() throws Exception { Properties props = new Properties(); props.put("knowledge.path.archetype", "src/test/resources/knowledge/archetypes"); props.put("knowledge.path.template", "src/test/resources/knowledge/templates"); props.put("knowledge.path.opt", "src/test/resources/knowledge/operational_templates"); props.put("knowledge.cachelocatable", "true"); props.put("knowledge.forcecache", "true"); knowledge = new KnowledgeCache(null, props); Pattern include = Pattern.compile(".*"); knowledge.retrieveFileMap(include, null); Map<String, Object> properties = new HashMap<>(); properties.put(I_DomainAccess.KEY_DIALECT, "POSTGRES"); properties.put(I_DomainAccess.KEY_CONNECTION_MODE, I_DomainAccess.DBCP2_POOL); properties.put(I_DomainAccess.KEY_URL, "jdbc:postgresql: properties.put(I_DomainAccess.KEY_LOGIN, System.getProperty("test.db.user")); properties.put(I_DomainAccess.KEY_PASSWORD, System.getProperty("test.db.password")); properties.put(I_DomainAccess.KEY_KNOWLEDGE, knowledge); try { testDomainAccess = new DummyDataAccess(properties); } catch (Exception e) { e.printStackTrace(); } context = testDomainAccess.getContext(); Result result = context.select(EHR_.ID).from(EHR_).fetch(); assertTrue(result.isNotEmpty()); }