You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2014/02/15 11:34:03 UTC

svn commit: r1568610 - in /cayenne/main/trunk/cayenne-server/src: main/java/org/apache/cayenne/configuration/server/ test/java/org/apache/cayenne/configuration/server/

Author: aadamchik
Date: Sat Feb 15 10:34:02 2014
New Revision: 1568610

URL: http://svn.apache.org/r1568610
Log:
CAY-1901 Config-free ServerRuntime

Added:
    cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/FixedDataSourceFactory.java
    cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/FixedJNDIDataSourceFactory.java
    cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/SyntheticNodeDataDomainProvider.java
    cayenne/main/trunk/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/ServerRuntimeBuilder_InAction_Test.java
      - copied, changed from r1568609, cayenne/main/trunk/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/ServerRuntime_ConfigFree_Test.java
Removed:
    cayenne/main/trunk/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/ServerRuntime_ConfigFree_Test.java
Modified:
    cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/DataDomainProvider.java
    cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/JNDIDataSourceFactory.java
    cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerRuntimeBuilder.java

Modified: cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/DataDomainProvider.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/DataDomainProvider.java?rev=1568610&r1=1568609&r2=1568610&view=diff
==============================================================================
--- cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/DataDomainProvider.java (original)
+++ cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/DataDomainProvider.java Sat Feb 15 10:34:02 2014
@@ -60,7 +60,10 @@ import org.apache.commons.logging.LogFac
  */
 public class DataDomainProvider implements Provider<DataDomain> {
     
-    private static final String DEFAULT_NAME = "cayenne";
+    /**
+     * @since 3.2
+     */
+    static final String DEFAULT_NAME = "cayenne";
 
     private static Log logger = LogFactory.getLog(DataDomainProvider.class);
 
@@ -148,38 +151,7 @@ public class DataDomainProvider implemen
         dataDomain.getEntityResolver().applyObjectLayerDefaults();
 
         for (DataNodeDescriptor nodeDescriptor : descriptor.getNodeDescriptors()) {
-            DataNode dataNode = new DataNode(nodeDescriptor.getName());
-
-            dataNode.setJdbcEventLogger(jdbcEventLogger);
-            dataNode.setDataSourceLocation(nodeDescriptor.getParameters());
-
-            DataSource dataSource = dataSourceFactory.getDataSource(nodeDescriptor);
-
-            dataNode.setDataSourceFactory(nodeDescriptor.getDataSourceFactoryType());
-            dataNode.setDataSource(dataSource);
-
-            // schema update strategy
-            String schemaUpdateStrategyType = nodeDescriptor.getSchemaUpdateStrategyType();
-
-            if (schemaUpdateStrategyType == null) {
-                dataNode.setSchemaUpdateStrategy(defaultSchemaUpdateStrategy);
-                dataNode.setSchemaUpdateStrategyName(defaultSchemaUpdateStrategy.getClass().getName());
-            } else {
-                SchemaUpdateStrategy strategy = objectFactory.newInstance(SchemaUpdateStrategy.class,
-                        schemaUpdateStrategyType);
-                dataNode.setSchemaUpdateStrategyName(schemaUpdateStrategyType);
-                dataNode.setSchemaUpdateStrategy(strategy);
-            }
-
-            // DbAdapter
-            dataNode.setAdapter(adapterFactory.createAdapter(nodeDescriptor, dataSource));
-
-            // DataMaps
-            for (String dataMapName : nodeDescriptor.getDataMapNames()) {
-                dataNode.addDataMap(dataDomain.getDataMap(dataMapName));
-            }
-
-            dataDomain.addNode(dataNode);
+            addDataNode(dataDomain, nodeDescriptor);
         }
 
         // init default node
@@ -208,6 +180,46 @@ public class DataDomainProvider implemen
 
         return dataDomain;
     }
+    
+    /**
+     * @throws Exception 
+     * @since 3.2
+     */
+    protected DataNode addDataNode(DataDomain dataDomain, DataNodeDescriptor nodeDescriptor) throws Exception {
+        DataNode dataNode = new DataNode(nodeDescriptor.getName());
+
+        dataNode.setJdbcEventLogger(jdbcEventLogger);
+        dataNode.setDataSourceLocation(nodeDescriptor.getParameters());
+
+        DataSource dataSource = dataSourceFactory.getDataSource(nodeDescriptor);
+
+        dataNode.setDataSourceFactory(nodeDescriptor.getDataSourceFactoryType());
+        dataNode.setDataSource(dataSource);
+
+        // schema update strategy
+        String schemaUpdateStrategyType = nodeDescriptor.getSchemaUpdateStrategyType();
+
+        if (schemaUpdateStrategyType == null) {
+            dataNode.setSchemaUpdateStrategy(defaultSchemaUpdateStrategy);
+            dataNode.setSchemaUpdateStrategyName(defaultSchemaUpdateStrategy.getClass().getName());
+        } else {
+            SchemaUpdateStrategy strategy = objectFactory.newInstance(SchemaUpdateStrategy.class,
+                    schemaUpdateStrategyType);
+            dataNode.setSchemaUpdateStrategyName(schemaUpdateStrategyType);
+            dataNode.setSchemaUpdateStrategy(strategy);
+        }
+
+        // DbAdapter
+        dataNode.setAdapter(adapterFactory.createAdapter(nodeDescriptor, dataSource));
+
+        // DataMaps
+        for (String dataMapName : nodeDescriptor.getDataMapNames()) {
+            dataNode.addDataMap(dataDomain.getDataMap(dataMapName));
+        }
+
+        dataDomain.addNode(dataNode);
+        return dataNode;
+    }
 
     private DataChannelDescriptor descriptorFromConfigs() {
 

Added: cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/FixedDataSourceFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/FixedDataSourceFactory.java?rev=1568610&view=auto
==============================================================================
--- cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/FixedDataSourceFactory.java (added)
+++ cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/FixedDataSourceFactory.java Sat Feb 15 10:34:02 2014
@@ -0,0 +1,40 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.configuration.server;
+
+import javax.sql.DataSource;
+
+import org.apache.cayenne.configuration.DataNodeDescriptor;
+
+/**
+ * @since 3.2
+ */
+class FixedDataSourceFactory implements DataSourceFactory {
+
+    private DataSource dataSource;
+
+    public FixedDataSourceFactory(DataSource dataSource) {
+        this.dataSource = dataSource;
+    }
+
+    @Override
+    public DataSource getDataSource(DataNodeDescriptor nodeDescriptor) throws Exception {
+        return dataSource;
+    }
+}

Added: cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/FixedJNDIDataSourceFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/FixedJNDIDataSourceFactory.java?rev=1568610&view=auto
==============================================================================
--- cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/FixedJNDIDataSourceFactory.java (added)
+++ cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/FixedJNDIDataSourceFactory.java Sat Feb 15 10:34:02 2014
@@ -0,0 +1,39 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.configuration.server;
+
+import org.apache.cayenne.configuration.DataNodeDescriptor;
+
+/**
+ * @since 3.2
+ */
+class FixedJNDIDataSourceFactory extends JNDIDataSourceFactory {
+
+    private String location;
+
+    public FixedJNDIDataSourceFactory(String location) {
+        this.location = location;
+    }
+
+    @Override
+    protected String getLocation(DataNodeDescriptor nodeDescriptor) {
+        return location;
+    }
+
+}

Modified: cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/JNDIDataSourceFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/JNDIDataSourceFactory.java?rev=1568610&r1=1568609&r2=1568610&view=diff
==============================================================================
--- cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/JNDIDataSourceFactory.java (original)
+++ cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/JNDIDataSourceFactory.java Sat Feb 15 10:34:02 2014
@@ -45,12 +45,7 @@ public class JNDIDataSourceFactory imple
     @Override
     public DataSource getDataSource(DataNodeDescriptor nodeDescriptor) throws Exception {
 
-        String location = nodeDescriptor.getParameters();
-        if (location == null) {
-            throw new CayenneRuntimeException(
-                    "Null 'location' for nodeDescriptor '%s'",
-                    nodeDescriptor.getName());
-        }
+        String location = getLocation(nodeDescriptor);
 
         try {
             return lookupViaJNDI(location);
@@ -61,6 +56,15 @@ public class JNDIDataSourceFactory imple
             throw ex;
         }
     }
+    
+    protected String getLocation(DataNodeDescriptor nodeDescriptor) {
+        String location = nodeDescriptor.getParameters();
+        if (location == null) {
+            throw new CayenneRuntimeException("Null 'location' for nodeDescriptor '%s'", nodeDescriptor.getName());
+        }
+
+        return location;
+    }
 
     DataSource lookupViaJNDI(String location) throws NamingException {
         jdbcEventLogger.logConnect(location);

Modified: cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerRuntimeBuilder.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerRuntimeBuilder.java?rev=1568610&r1=1568609&r2=1568610&view=diff
==============================================================================
--- cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerRuntimeBuilder.java (original)
+++ cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerRuntimeBuilder.java Sat Feb 15 10:34:02 2014
@@ -21,18 +21,34 @@ package org.apache.cayenne.configuration
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.LinkedHashSet;
+import java.util.List;
 
+import javax.sql.DataSource;
+
+import org.apache.cayenne.access.DataDomain;
+import org.apache.cayenne.configuration.Constants;
+import org.apache.cayenne.di.Binder;
+import org.apache.cayenne.di.MapBuilder;
 import org.apache.cayenne.di.Module;
 
 /**
- * A convenience class to assemble custom ServerRuntime.
+ * A convenience class to assemble custom ServerRuntime. It allows to easily
+ * configure custom modules, multiple config locations, or quickly create a
+ * global DataSource.
  * 
  * @since 3.2
  */
 public class ServerRuntimeBuilder {
 
     private Collection<String> configs;
-    private Collection<Module> modules;
+    private List<Module> modules;
+    private DataSourceFactory dataSourceFactory;
+    private String jdbcUrl;
+    private String jdbcDriver;
+    private String jdbcUser;
+    private String jdbcPassword;
+    private int jdbcMinConnections;
+    private int jdbcMaxConnections;
 
     public ServerRuntimeBuilder() {
         this.configs = new LinkedHashSet<String>();
@@ -44,6 +60,53 @@ public class ServerRuntimeBuilder {
         addConfig(configurationLocation);
     }
 
+    /**
+     * Sets a DataSource that will override any DataSources found in the
+     * mapping. Moreover if the mapping contains no DataNodes, and the
+     * DataSource is set with this method, the builder would create a single
+     * default DataNode.
+     */
+    public ServerRuntimeBuilder dataSource(DataSource dataSource) {
+        this.dataSourceFactory = new FixedDataSourceFactory(dataSource);
+        return this;
+    }
+
+    public ServerRuntimeBuilder jndiDataSource(String location) {
+        this.dataSourceFactory = new FixedJNDIDataSourceFactory(location);
+        return this;
+    }
+
+    public ServerRuntimeBuilder url(String url) {
+        this.jdbcUrl = url;
+        return this;
+    }
+
+    public ServerRuntimeBuilder jdbcDriver(String driver) {
+        // TODO: guess the driver from URL
+        this.jdbcDriver = driver;
+        return this;
+    }
+
+    public ServerRuntimeBuilder user(String user) {
+        this.jdbcUser = user;
+        return this;
+    }
+
+    public ServerRuntimeBuilder password(String password) {
+        this.jdbcPassword = password;
+        return this;
+    }
+
+    public ServerRuntimeBuilder minConnections(int minConnections) {
+        this.jdbcMinConnections = minConnections;
+        return this;
+    }
+
+    public ServerRuntimeBuilder maxConnections(int maxConnections) {
+        this.jdbcMaxConnections = maxConnections;
+        return this;
+    }
+
     public ServerRuntimeBuilder addConfig(String configurationLocation) {
         configs.add(configurationLocation);
         return this;
@@ -59,14 +122,66 @@ public class ServerRuntimeBuilder {
         return this;
     }
 
-    public ServerRuntimeBuilder addMoudles(Collection<Module> modules) {
+    public ServerRuntimeBuilder addModules(Collection<Module> modules) {
         this.modules.addAll(modules);
         return this;
     }
 
     public ServerRuntime build() {
+
+        buildModules();
+
         String[] configs = this.configs.toArray(new String[this.configs.size()]);
         Module[] modules = this.modules.toArray(new Module[this.modules.size()]);
         return new ServerRuntime(configs, modules);
     }
+
+    private void buildModules() {
+
+        if (dataSourceFactory != null) {
+
+            prepend(new Module() {
+                @Override
+                public void configure(Binder binder) {
+                    binder.bind(DataDomain.class).toProvider(SyntheticNodeDataDomainProvider.class);
+                    binder.bind(DataSourceFactory.class).toInstance(dataSourceFactory);
+                }
+            });
+
+        }
+        // URL and driver are the minimal requirement for
+        // DelegatingDataSourceFactory to work
+        else if (jdbcUrl != null && jdbcDriver != null) {
+            prepend(new Module() {
+                @Override
+                public void configure(Binder binder) {
+                    binder.bind(DataDomain.class).toProvider(SyntheticNodeDataDomainProvider.class);
+                    MapBuilder<Object> props = binder.bindMap(Constants.PROPERTIES_MAP)
+                            .put(Constants.JDBC_DRIVER_PROPERTY, jdbcDriver).put(Constants.JDBC_URL_PROPERTY, jdbcUrl);
+
+                    if (jdbcUser != null) {
+                        props.put(Constants.JDBC_USERNAME_PROPERTY, jdbcUser);
+                    }
+
+                    if (jdbcPassword != null) {
+                        props.put(Constants.JDBC_PASSWORD_PROPERTY, jdbcPassword);
+                    }
+
+                    if (jdbcMinConnections > 0) {
+                        props.put(Constants.JDBC_MIN_CONNECTIONS_PROPERTY, Integer.toString(jdbcMinConnections));
+                    }
+
+                    if (jdbcMaxConnections > 0) {
+                        props.put(Constants.JDBC_MAX_CONNECTIONS_PROPERTY, Integer.toString(jdbcMaxConnections));
+                    }
+                }
+            });
+        }
+    }
+
+    private void prepend(Module module) {
+        // prepend any special modules BEFORE custom modules, to allow callers
+        // to override our stuff
+        modules.add(0, module);
+    }
 }

Added: cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/SyntheticNodeDataDomainProvider.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/SyntheticNodeDataDomainProvider.java?rev=1568610&view=auto
==============================================================================
--- cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/SyntheticNodeDataDomainProvider.java (added)
+++ cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/SyntheticNodeDataDomainProvider.java Sat Feb 15 10:34:02 2014
@@ -0,0 +1,51 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.configuration.server;
+
+import org.apache.cayenne.access.DataDomain;
+import org.apache.cayenne.access.DataNode;
+import org.apache.cayenne.configuration.DataChannelDescriptor;
+import org.apache.cayenne.configuration.DataNodeDescriptor;
+
+/**
+ * @since 3.2
+ */
+class SyntheticNodeDataDomainProvider extends DataDomainProvider {
+
+    @Override
+    protected DataDomain createAndInitDataDomain() throws Exception {
+
+        DataDomain dataDomain = super.createAndInitDataDomain();
+
+        // no nodes... add a synthetic node... it will become the default
+        if (dataDomain.getDataNodes().isEmpty()) {
+
+            DataChannelDescriptor channelDescriptor = new DataChannelDescriptor();
+            channelDescriptor.setName(DEFAULT_NAME);
+
+            DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor(DEFAULT_NAME);
+            nodeDescriptor.setDataChannelDescriptor(channelDescriptor);
+
+            DataNode node = addDataNode(dataDomain, nodeDescriptor);
+            dataDomain.setDefaultNode(node);
+        }
+        return dataDomain;
+    }
+
+}

Copied: cayenne/main/trunk/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/ServerRuntimeBuilder_InAction_Test.java (from r1568609, cayenne/main/trunk/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/ServerRuntime_ConfigFree_Test.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/ServerRuntimeBuilder_InAction_Test.java?p2=cayenne/main/trunk/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/ServerRuntimeBuilder_InAction_Test.java&p1=cayenne/main/trunk/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/ServerRuntime_ConfigFree_Test.java&r1=1568609&r2=1568610&rev=1568610&view=diff
==============================================================================
--- cayenne/main/trunk/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/ServerRuntime_ConfigFree_Test.java (original)
+++ cayenne/main/trunk/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/ServerRuntimeBuilder_InAction_Test.java Sat Feb 15 10:34:02 2014
@@ -20,7 +20,10 @@ package org.apache.cayenne.configuration
 
 import java.util.List;
 
+import javax.sql.DataSource;
+
 import org.apache.cayenne.DataRow;
+import org.apache.cayenne.conn.DataSourceInfo;
 import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.query.SQLSelect;
 import org.apache.cayenne.test.jdbc.DBHelper;
@@ -29,10 +32,18 @@ import org.apache.cayenne.unit.di.server
 import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
 @UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class ServerRuntime_ConfigFree_Test extends ServerCase {
+public class ServerRuntimeBuilder_InAction_Test extends ServerCase {
+
+    @Inject
+    private DBHelper dbHelper;
+
+    @Inject
+    private ServerRuntime runtime;
 
     @Inject
-    protected DBHelper dbHelper;
+    private DataSourceInfo dsi;
+
+    private DataSource dataSource;
 
     @Override
     protected void setUpAfterInjection() throws Exception {
@@ -48,13 +59,33 @@ public class ServerRuntime_ConfigFree_Te
         tArtist.setColumns("ARTIST_ID", "ARTIST_NAME");
         tArtist.insert(33001, "AA1");
         tArtist.insert(33002, "AA2");
+
+        this.dataSource = runtime.getDataSource("testmap");
     }
 
-    public void testRunSQL() {
+    public void testConfigFree_WithDataSource() {
+
+        ServerRuntime localRuntime = new ServerRuntimeBuilder().dataSource(dataSource).build();
+
+        try {
+            List<DataRow> result = SQLSelect.dataRowQuery("SELECT * FROM ARTIST").select(localRuntime.newContext());
+            assertEquals(2, result.size());
+        } finally {
+            localRuntime.shutdown();
+        }
+    }
 
-        ServerRuntime runtime = new ServerRuntimeBuilder().build();
+    public void testConfigFree_WithDBParams() {
 
-        List<DataRow> result = SQLSelect.dataRowQuery("SELECT * FROM ARTIST").select(runtime.newContext());
-        assertEquals(2, result.size());
+        ServerRuntime localRuntime = new ServerRuntimeBuilder().jdbcDriver(dsi.getJdbcDriver())
+                .url(dsi.getDataSourceUrl()).password(dsi.getPassword()).user(dsi.getUserName()).minConnections(1)
+                .maxConnections(2).build();
+
+        try {
+            List<DataRow> result = SQLSelect.dataRowQuery("SELECT * FROM ARTIST").select(localRuntime.newContext());
+            assertEquals(2, result.size());
+        } finally {
+            localRuntime.shutdown();
+        }
     }
 }