You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ma...@apache.org on 2015/05/20 18:42:21 UTC

[1/9] incubator-nifi git commit: Initial Database connection pooling service implementation NIFI-322

Repository: incubator-nifi
Updated Branches:
  refs/heads/develop 8c7dd6ab3 -> 149ad130d


Initial Database connection pooling service implementation NIFI-322

Signed-off-by: Toivo Adams <to...@gmail.com>
Signed-off-by: Mark Payne <ma...@hotmail.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/589e2b7e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/589e2b7e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/589e2b7e

Branch: refs/heads/develop
Commit: 589e2b7ebf6ef70307ff1a2ab67c473d2f19a9a9
Parents: 5273a63
Author: Toivo Adams <to...@gmail.com>
Authored: Sun Mar 1 22:27:06 2015 +0200
Committer: Mark Payne <ma...@hotmail.com>
Committed: Wed May 20 08:35:53 2015 -0400

----------------------------------------------------------------------
 .../nifi-dbcp-service-api/pom.xml               |  18 ++
 .../java/org/apache/nifi/dbcp/DBCPService.java  |  38 ++++
 .../nifi-dbcp-service-nar/pom.xml               |  28 +++
 .../nifi-dbcp-service/pom.xml                   |  49 +++++
 .../nifi/dbcp/DBCPServiceApacheDBCP14.java      | 208 ++++++++++++++++++
 .../nifi/dbcp/DatabaseSystemDescriptor.java     |  51 +++++
 .../org/apache/nifi/dbcp/DatabaseSystems.java   |  78 +++++++
 .../org/apache/nifi/dbcp/DBCPServiceTest.java   | 214 +++++++++++++++++++
 .../apache/nifi/dbcp/TestDatabaseSystems.java   |  37 ++++
 .../org/apache/nifi/dbcp/TestProcessor.java     |  47 ++++
 .../nifi-dbcp-service-bundle/pom.xml            |  18 ++
 .../nifi-standard-services-api-nar/pom.xml      |   6 +
 .../nifi-standard-services/pom.xml              |   1 +
 13 files changed, 793 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/589e2b7e/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-api/pom.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-api/pom.xml b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-api/pom.xml
new file mode 100644
index 0000000..f8ea08a
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-api/pom.xml
@@ -0,0 +1,18 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    
+    
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.nifi</groupId>
+        <artifactId>nifi-standard-services</artifactId>
+        <version>0.0.2-incubating-SNAPSHOT</version>
+    </parent>
+    <artifactId>nifi-dbcp-service-api</artifactId>
+    <packaging>jar</packaging>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-api</artifactId>
+        </dependency>
+    </dependencies>
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/589e2b7e/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-api/src/main/java/org/apache/nifi/dbcp/DBCPService.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-api/src/main/java/org/apache/nifi/dbcp/DBCPService.java b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-api/src/main/java/org/apache/nifi/dbcp/DBCPService.java
new file mode 100644
index 0000000..8f2aa5a
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-api/src/main/java/org/apache/nifi/dbcp/DBCPService.java
@@ -0,0 +1,38 @@
+/*
+ * 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.nifi.dbcp;
+
+import java.sql.Connection;
+
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.controller.ControllerService;
+import org.apache.nifi.processor.exception.ProcessException;
+
+/**
+ * Definition for Database Connection Pooling Service.
+ *
+ */
+@Tags({"dbcp", "jdbc", "database", "connection", "pooling", "store"})
+@CapabilityDescription("Provides Database Connection Pooling Service. Connections can be asked from pool and returned after usage."
+        )
+public interface DBCPService extends ControllerService {
+
+ 
+    public Connection getConnection()  throws ProcessException;
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/589e2b7e/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service-nar/pom.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service-nar/pom.xml b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service-nar/pom.xml
new file mode 100644
index 0000000..37722db
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service-nar/pom.xml
@@ -0,0 +1,28 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+
+
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.nifi</groupId>
+        <artifactId>nifi-dbcp-service-bundle</artifactId>
+        <version>0.0.2-incubating-SNAPSHOT</version>
+    </parent>
+    <artifactId>nifi-dbcp-service-nar</artifactId>
+    <packaging>nar</packaging>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-standard-services-api-nar</artifactId>
+            <type>nar</type>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-dbcp-service</artifactId>
+            <version>0.0.2-incubating-SNAPSHOT</version>
+        </dependency>
+    </dependencies>
+  
+  
+  
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/589e2b7e/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/pom.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/pom.xml b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/pom.xml
new file mode 100644
index 0000000..d06a14c
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/pom.xml
@@ -0,0 +1,49 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+
+
+    <modelVersion>4.0.0</modelVersion>  
+    <parent>
+        <groupId>org.apache.nifi</groupId>
+        <artifactId>nifi-dbcp-service-bundle</artifactId>
+        <version>0.0.2-incubating-SNAPSHOT</version>
+    </parent>
+    <artifactId>nifi-dbcp-service</artifactId>
+    <packaging>jar</packaging>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-dbcp-service-api</artifactId>
+            <version>0.0.2-incubating-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-processor-utils</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-security-utils</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-mock</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+	        <groupId>commons-dbcp</groupId>
+	        <artifactId>commons-dbcp</artifactId>
+	        <version>1.4</version>
+        </dependency>
+		<dependency>
+		    <groupId>org.apache.derby</groupId>
+		    <artifactId>derby</artifactId>
+		    <version>10.11.1.1</version>
+	    </dependency>        
+        
+    </dependencies>
+  
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/589e2b7e/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DBCPServiceApacheDBCP14.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DBCPServiceApacheDBCP14.java b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DBCPServiceApacheDBCP14.java
new file mode 100644
index 0000000..eb0a950
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DBCPServiceApacheDBCP14.java
@@ -0,0 +1,208 @@
+/*
+ * 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.nifi.dbcp;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.commons.dbcp.BasicDataSource;
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.annotation.lifecycle.OnEnabled;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.controller.AbstractControllerService;
+import org.apache.nifi.controller.ConfigurationContext;
+import org.apache.nifi.processor.exception.ProcessException;
+import org.apache.nifi.processor.util.StandardValidators;
+import org.apache.nifi.reporting.InitializationException;
+
+/**
+ * Implementation of for Database Connection Pooling Service.
+ * Apache DBCP is used for connection pooling functionality.
+ *
+ */
+@Tags({"dbcp", "jdbc", "database", "connection", "pooling", "store"})
+@CapabilityDescription("Provides Database Connection Pooling Service. Connections can be asked from pool and returned after usage."
+        )
+public class DBCPServiceApacheDBCP14 extends AbstractControllerService implements DBCPService {
+
+	public static final DatabaseSystemDescriptor DEFAULT_DATABASE_SYSTEM = DatabaseSystems.getDescriptor("JavaDB");
+
+    public static final PropertyDescriptor DATABASE_SYSTEM = new PropertyDescriptor.Builder()
+    .name("Database")
+    .description("Database management system")
+//    .allowableValues(POSTGRES, JavaDB, DERBY, MariaDB, OtherDB)
+    .allowableValues(DatabaseSystems.knownDatabaseSystems)
+    .defaultValue(DEFAULT_DATABASE_SYSTEM.getValue())
+    .required(true)
+    .build();    
+
+    public static final PropertyDescriptor DB_HOST = new PropertyDescriptor.Builder()
+    .name("Database host")
+    .description("Database host")
+    .defaultValue(null)
+    .required(true)
+    .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+    .build();
+
+    public static final PropertyDescriptor DB_PORT = new PropertyDescriptor.Builder()
+    .name("Database port")
+    .description("Database server port")
+    .defaultValue(DEFAULT_DATABASE_SYSTEM.defaultPort.toString())
+    .required(true)
+    .addValidator(StandardValidators.PORT_VALIDATOR)
+    .build();
+
+    public static final PropertyDescriptor DB_DRIVERNAME = new PropertyDescriptor.Builder()
+    .name("Database driver class name")
+    .description("Database driver class name")
+    .defaultValue(DEFAULT_DATABASE_SYSTEM.driverClassName)
+    .required(true)
+    .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+    .build();
+
+    public static final PropertyDescriptor DB_NAME = new PropertyDescriptor.Builder()
+    .name("Database name")
+    .description("Database name")
+    .defaultValue(null)
+    .required(true)
+    .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+    .build();
+
+    public static final PropertyDescriptor DB_USER = new PropertyDescriptor.Builder()
+    .name("Database user")
+    .description("Database user name")
+    .defaultValue(null)
+    .required(true)
+    .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+    .build();
+
+    public static final PropertyDescriptor DB_PASSWORD = new PropertyDescriptor.Builder()
+    .name("Password")
+    .description("The password for the database user")
+    .defaultValue(null)
+    .required(true)
+    .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+    .sensitive(true)
+    .build();
+
+    private static final List<PropertyDescriptor> properties;
+
+    static {
+        List<PropertyDescriptor> props = new ArrayList<>();
+        props.add(DATABASE_SYSTEM);
+        props.add(DB_HOST);
+        props.add(DB_PORT);
+        props.add(DB_DRIVERNAME);
+        props.add(DB_NAME);
+        props.add(DB_USER);
+        props.add(DB_PASSWORD);
+        
+        properties = Collections.unmodifiableList(props);
+    }
+    
+    private ConfigurationContext configContext;
+    private volatile BasicDataSource dataSource;
+
+    @Override
+    protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
+        return properties;
+    }
+    
+    //=================================   Apache DBCP pool parameters  ================================ 
+    
+    /** The maximum number of milliseconds that the pool will wait (when there are no available connections) 
+     * for a connection to be returned before throwing an exception, or -1 to wait indefinitely. 
+     */
+    static final long maxWaitMillis = 500;
+   
+    /** The maximum number of active connections that can be allocated from this pool at the same time, 
+     * or negative for no limit.
+     */
+    static final int maxTotal 		= 8;
+
+    //=================================================================================================
+    
+    /**
+     * Idea was to dynamically set port, driver and url properties default values after user select database system.
+     * As of 01mar2015 such functionality is not supported.
+     * 
+    @Override
+    public void onPropertyModified(final PropertyDescriptor descriptor, final String oldValue, final String newValue) {
+        super.onPropertyModified(descriptor, oldValue, newValue);
+
+        if (descriptor.equals(DATABASE_SYSTEM)) {
+        	
+        	DatabaseSystemDescriptor databaseSystemDescriptor = DatabaseSystems.getDescriptor(newValue);
+        }        
+    }
+	*/
+
+    @OnEnabled
+    public void onConfigured(final ConfigurationContext context) throws InitializationException {
+        configContext = context;
+
+        DatabaseSystemDescriptor dbsystem = DatabaseSystems.getDescriptor( context.getProperty(DATABASE_SYSTEM).getValue() );
+        
+        String host   = context.getProperty(DB_HOST).getValue();
+        Integer port  = context.getProperty(DB_PORT).asInteger();
+        String drv    = context.getProperty(DB_DRIVERNAME).getValue();
+        String dbname = context.getProperty(DB_NAME).getValue();
+        String user   = context.getProperty(DB_USER).getValue();
+        String passw  = context.getProperty(DB_PASSWORD).getValue();
+        
+        String dburl  = dbsystem.buildUrl(host, port, dbname);
+        
+        dataSource = new BasicDataSource();
+        dataSource.setMaxWait(maxWaitMillis);
+        dataSource.setMaxActive(maxTotal);
+
+        dataSource.setUrl(dburl);
+        dataSource.setDriverClassName(drv);
+        dataSource.setUsername(user);
+        dataSource.setPassword(passw);
+
+        // verify connection can be established.
+        try {
+			Connection con = dataSource.getConnection();
+			if (con==null)
+				throw new InitializationException("Connection to database cannot be established.");
+			con.close();
+		} catch (SQLException e) {
+			throw new InitializationException(e);
+		}
+    }
+    
+	@Override
+	public Connection getConnection() throws ProcessException {
+		try {
+			Connection con = dataSource.getConnection();
+			return con;
+		} catch (SQLException e) {
+			throw new ProcessException(e);
+		}
+	}
+
+    @Override
+    public String toString() {
+        return "DBCPServiceApacheDBCP14[id=" + getIdentifier() + "]";
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/589e2b7e/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DatabaseSystemDescriptor.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DatabaseSystemDescriptor.java b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DatabaseSystemDescriptor.java
new file mode 100644
index 0000000..d456c3b
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DatabaseSystemDescriptor.java
@@ -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.nifi.dbcp;
+
+import java.text.MessageFormat;
+
+import org.apache.nifi.components.AllowableValue;
+
+/**
+ * An immutable object for holding information about a database system.
+ *
+ */
+public class DatabaseSystemDescriptor extends AllowableValue {
+
+	public final String driverClassName;
+	public final Integer defaultPort;
+	public final String urlTemplate;
+	public final boolean internalDriverJar;
+	
+	public DatabaseSystemDescriptor(String value, String description,
+			String driverClassName, Integer	defaultPort, String urlTemplate, boolean internalDriverJar) {
+		super(value, value, description);
+		
+		if (defaultPort==null)
+			throw new IllegalArgumentException("defaultPort cannot be null");
+
+		this.driverClassName = driverClassName;
+		this.defaultPort	 = defaultPort;
+		this.urlTemplate	 = urlTemplate;
+		this.internalDriverJar = internalDriverJar;
+	}
+
+	public String buildUrl(String host, Integer port, String dbname) {
+		return MessageFormat.format(urlTemplate, host, port.toString(), dbname);
+	}
+	
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/589e2b7e/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DatabaseSystems.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DatabaseSystems.java b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DatabaseSystems.java
new file mode 100644
index 0000000..1859b72
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DatabaseSystems.java
@@ -0,0 +1,78 @@
+/*
+ * 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.nifi.dbcp;
+
+public class DatabaseSystems {
+
+	/**
+	 *	{0}		host name/ip
+	 *	{1}		port number  
+	 *  {2}		database name
+	 * 
+	 * for example url template
+	 *   "jdbc:postgresql://{0}:{1}/{2}"
+	 * will be after building
+	 *  "jdbc:postgresql://bighost:5432/Trove"
+	 * 
+	 */
+	
+	public static DatabaseSystemDescriptor[] knownDatabaseSystems = { 
+		
+		// =================  JDBC driver jar should be included in nar (in pom.xml dependencies) =======================
+		
+		new DatabaseSystemDescriptor("Postgres", "PostgreSQL open soure object-relational database.", 
+				"org.postgresql.Driver", 5432, "jdbc:postgresql://{0}:{1}/{2}", true),
+
+		new DatabaseSystemDescriptor("JavaDB", "Java DB is Oracle's supported distribution of the Apache Derby open source database. Included in JDK.", 
+				"org.apache.derby.jdbc.EmbeddedDriver", 1, "jdbc:derby:{2};create=true", true),
+				
+		new DatabaseSystemDescriptor("Derby", "Apache Derby is an open source relational database.", 
+				"org.apache.derby.jdbc.EmbeddedDriver", 1, "jdbc:derby:{2};create=true", true),
+	
+
+		// =================  JDBC driver jar must be loaded from external location  =======================
+				
+		new DatabaseSystemDescriptor("MariaDB",
+				"MariaDB is a community-developed fork of the MySQL relational database management system intended to remain free under the GNU GPL.", 
+				"org.mariadb.jdbc.Driver", 3306, "jdbc:mariadb://{0}:{1}/{2}", false),
+
+		new DatabaseSystemDescriptor("Oracle",
+				"Oracle Database is an object-relational database management system.", 
+				"oracle.jdbc.OracleDriver", 1521, "jdbc:oracle:thin:@//{0}:{1}/{2}", false),
+
+		new DatabaseSystemDescriptor("Sybase",
+				"Sybase is an relational database management system.", 
+				"com.sybase.jdbc3.jdbc.SybDriver", 5000, "jdbc:sybase:Tds:{0}:{1}/{2}", false),
+
+
+		// =================  Unknown JDBC driver, user must provide connection details =====================		
+				
+		new DatabaseSystemDescriptor("Other DB", "Other JDBC compliant JDBC driver", 
+				null, 1, null, false),
+		
+	};
+	
+	public static DatabaseSystemDescriptor getDescriptor(String name) {
+		for ( DatabaseSystemDescriptor descr : DatabaseSystems.knownDatabaseSystems) {
+			if (descr.getValue().equalsIgnoreCase(name))
+				return descr;
+		}
+		throw new IllegalArgumentException("Can't find DatabaseSystemDescriptor by name " + name);
+	}
+	
+	
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/589e2b7e/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java
new file mode 100644
index 0000000..684cc76
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java
@@ -0,0 +1,214 @@
+/*
+ * 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.nifi.dbcp;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.activation.DataSource;
+
+import org.apache.nifi.processor.exception.ProcessException;
+import org.apache.nifi.reporting.InitializationException;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+public class DBCPServiceTest {
+    
+	final static String DB_LOCATION = "/var/tmp/testdb";
+	
+	/**
+	 *	Unknown database system.  
+	 * 
+	 */
+    @Test
+    public void testBad1() throws InitializationException {
+        final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
+        final DBCPServiceApacheDBCP14 service = new DBCPServiceApacheDBCP14();
+        final Map<String, String> properties = new HashMap<String, String>();
+        properties.put(DBCPServiceApacheDBCP14.DATABASE_SYSTEM.getName(), "garbage");
+        runner.addControllerService("test-bad2", service, properties);
+        runner.assertNotValid(service);
+    }
+    
+    /**
+     *  Missing property values.
+     */    
+    @Test
+    public void testGood1() throws InitializationException {
+        final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
+        final DBCPServiceApacheDBCP14 service = new DBCPServiceApacheDBCP14();
+        final Map<String, String> properties = new HashMap<String, String>();
+        runner.addControllerService("test-bad1", service, properties);
+        runner.assertNotValid(service);
+    }
+
+    /**
+     * 	Test database connection using Derby.
+     * Connect, create table, insert, select, drop table. 
+     * 
+     */
+    @Test
+    public void testGood2() throws InitializationException, SQLException {
+        final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
+        final DBCPServiceApacheDBCP14 service = new DBCPServiceApacheDBCP14();
+        runner.addControllerService("test-good1", service);
+        
+        // remove previous test database, if any
+        File dbLocation = new File(DB_LOCATION);
+        dbLocation.delete();
+        
+        // Should setProperty call also generate DBCPServiceApacheDBCP14.onPropertyModified() method call? 
+        // It does not currently.
+        
+        // Some properties already should have JavaDB/Derby default values, let's set only missing values.
+        
+        runner.setProperty(service, DBCPServiceApacheDBCP14.DB_HOST, "NA");	// Embedded Derby don't use host
+        runner.setProperty(service, DBCPServiceApacheDBCP14.DB_NAME, DB_LOCATION);
+        runner.setProperty(service, DBCPServiceApacheDBCP14.DB_USER, 	"tester");
+        runner.setProperty(service, DBCPServiceApacheDBCP14.DB_PASSWORD, "testerp");
+        
+        runner.enableControllerService(service);
+
+        runner.assertValid(service);
+        DBCPService dbcpService = (DBCPService) runner.getProcessContext().getControllerServiceLookup().getControllerService("test-good1");
+        Assert.assertNotNull(dbcpService);
+        Connection connection = dbcpService.getConnection();
+        Assert.assertNotNull(connection);
+        
+        createInsertSelectDrop(connection);
+        
+        connection.close();		// return to pool
+    }
+
+    
+    @Rule
+    public ExpectedException exception = ExpectedException.none();
+    
+    /**
+     * 	Test get database connection using Derby.
+     * Get many times, after a while pool should not contain any available connection
+     * and getConnection should fail.    
+     */
+    @Test
+    public void testExhaustPool() throws InitializationException, SQLException {
+        final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
+        final DBCPServiceApacheDBCP14 service = new DBCPServiceApacheDBCP14();
+        runner.addControllerService("test-exhaust", service);
+        
+        // remove previous test database, if any
+        File dbLocation = new File(DB_LOCATION);
+        dbLocation.delete();
+        
+        runner.setProperty(service, DBCPServiceApacheDBCP14.DB_HOST, "NA");	// Embedded Derby don't use host
+        runner.setProperty(service, DBCPServiceApacheDBCP14.DB_NAME, DB_LOCATION);
+        runner.setProperty(service, DBCPServiceApacheDBCP14.DB_USER, 	"tester");
+        runner.setProperty(service, DBCPServiceApacheDBCP14.DB_PASSWORD, "testerp");
+        
+        runner.enableControllerService(service);
+
+        runner.assertValid(service);
+        DBCPService dbcpService = (DBCPService) runner.getProcessContext().getControllerServiceLookup().getControllerService("test-exhaust");
+        Assert.assertNotNull(dbcpService);
+        
+        exception.expect(ProcessException.class);
+        for (int i = 0; i < 100; i++) {
+            Connection connection = dbcpService.getConnection();
+            Assert.assertNotNull(connection);
+		}
+    }
+
+    /**
+     * 	Test get database connection using Derby.
+     * Get many times, release immediately
+     * and getConnection should not fail.    
+     */
+    @Test
+    public void testGetMany() throws InitializationException, SQLException {
+        final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
+        final DBCPServiceApacheDBCP14 service = new DBCPServiceApacheDBCP14();
+        runner.addControllerService("test-exhaust", service);
+        
+        // remove previous test database, if any
+        File dbLocation = new File(DB_LOCATION);
+        dbLocation.delete();
+        
+        runner.setProperty(service, DBCPServiceApacheDBCP14.DB_HOST, "NA");	// Embedded Derby don't use host
+        runner.setProperty(service, DBCPServiceApacheDBCP14.DB_NAME, DB_LOCATION);
+        runner.setProperty(service, DBCPServiceApacheDBCP14.DB_USER, 	"tester");
+        runner.setProperty(service, DBCPServiceApacheDBCP14.DB_PASSWORD, "testerp");
+        
+        runner.enableControllerService(service);
+
+        runner.assertValid(service);
+        DBCPService dbcpService = (DBCPService) runner.getProcessContext().getControllerServiceLookup().getControllerService("test-exhaust");
+        Assert.assertNotNull(dbcpService);
+        
+        for (int i = 0; i < 1000; i++) {
+            Connection connection = dbcpService.getConnection();
+            Assert.assertNotNull(connection);
+            connection.close();
+		}
+    }
+    
+    
+    @Test
+    public void testDriverLaod() throws ClassNotFoundException {
+    	Class<?> clazz = Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
+    	assertNotNull(clazz);
+    }
+    
+    
+	String createTable = "create table restaurants(id integer, name varchar(20), city varchar(50))";
+	String dropTable = "drop table restaurants";
+    
+    protected void createInsertSelectDrop( Connection con) throws SQLException {
+    	
+    	Statement st = con.createStatement();
+    	
+    	try {
+        	st.executeUpdate(dropTable);
+		} catch (Exception e) {
+			// table may not exist, this is not serious problem.
+		}
+    	
+		st.executeUpdate(createTable);
+    	
+    	st.executeUpdate("insert into restaurants values (1, 'Irifunes', 'San Mateo')");
+    	st.executeUpdate("insert into restaurants values (2, 'Estradas', 'Daly City')");
+    	st.executeUpdate("insert into restaurants values (3, 'Prime Rib House', 'San Francisco')");
+
+    	int nrOfRows = 0;
+    	ResultSet resultSet = st.executeQuery("select * from restaurants");
+    	while (resultSet.next())
+    		nrOfRows++;
+    	assertEquals(3, nrOfRows);
+
+    	st.close();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/589e2b7e/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/TestDatabaseSystems.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/TestDatabaseSystems.java b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/TestDatabaseSystems.java
new file mode 100644
index 0000000..2a360b2
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/TestDatabaseSystems.java
@@ -0,0 +1,37 @@
+/*
+ * 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.nifi.dbcp;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import static org.apache.nifi.dbcp.DatabaseSystems.getDescriptor;
+
+public class TestDatabaseSystems {
+
+	@Test
+	public void testKnownDatabaseSystems() {
+		
+		assertEquals( "jdbc:postgresql://bighost:5432/Trove", getDescriptor("Postgres").buildUrl("bighost",5432,"Trove") ); 
+		
+	}
+
+	
+	
+	
+	
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/589e2b7e/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/TestProcessor.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/TestProcessor.java b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/TestProcessor.java
new file mode 100644
index 0000000..b25d3f1
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/TestProcessor.java
@@ -0,0 +1,47 @@
+/*
+ * 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.nifi.dbcp;
+
+import org.apache.nifi.dbcp.DBCPService;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.processor.AbstractProcessor;
+import org.apache.nifi.processor.ProcessContext;
+import org.apache.nifi.processor.ProcessSession;
+import org.apache.nifi.processor.exception.ProcessException;
+import org.apache.nifi.processor.util.StandardValidators;
+
+public class TestProcessor extends AbstractProcessor {
+
+    @Override
+    public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException {
+    }
+
+    @Override
+    protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
+        List<PropertyDescriptor> propDescs = new ArrayList<>();
+        propDescs.add(new PropertyDescriptor.Builder()
+                .name("DBCPService test processor")
+                .description("DBCPService test processor")
+                .addValidator(StandardValidators.createControllerServiceExistsValidator(DBCPService.class))
+                .required(true)
+                .build());
+        return propDescs;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/589e2b7e/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/pom.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/pom.xml b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/pom.xml
new file mode 100644
index 0000000..2a2c74b
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/pom.xml
@@ -0,0 +1,18 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.nifi</groupId>
+        <artifactId>nifi-standard-services</artifactId>
+        <version>0.0.2-incubating-SNAPSHOT</version>
+    </parent>
+    <artifactId>nifi-dbcp-service-bundle</artifactId>
+    <packaging>pom</packaging>
+    <modules>
+        <module>nifi-dbcp-service</module>
+        <module>nifi-dbcp-service-nar</module>
+    </modules>
+    
+    
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/589e2b7e/nifi/nifi-nar-bundles/nifi-standard-services/nifi-standard-services-api-nar/pom.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-standard-services-api-nar/pom.xml b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-standard-services-api-nar/pom.xml
index b3a6c80..fbc20c6 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-standard-services-api-nar/pom.xml
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-standard-services-api-nar/pom.xml
@@ -42,5 +42,11 @@
 			<artifactId>nifi-http-context-map-api</artifactId>
 			<scope>compile</scope>
 		</dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-dbcp-service-api</artifactId>
+            <version>0.1.0-incubating-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
 </project>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/589e2b7e/nifi/nifi-nar-bundles/nifi-standard-services/pom.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/pom.xml b/nifi/nifi-nar-bundles/nifi-standard-services/pom.xml
index 083fb26..d225986 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-services/pom.xml
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/pom.xml
@@ -31,5 +31,6 @@
         <module>nifi-ssl-context-service-api</module>
 		<module>nifi-http-context-map-bundle</module>
         <module>nifi-standard-services-api-nar</module>
+        <module>nifi-dbcp-service-api</module>
     </modules>
 </project>



[4/9] incubator-nifi git commit: bump version to 0.1.0 , test cleanup

Posted by ma...@apache.org.
bump version to 0.1.0 , test cleanup

Signed-off-by: Toivo Adams <to...@gmail.com>
Signed-off-by: Mark Payne <ma...@hotmail.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/78906a94
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/78906a94
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/78906a94

Branch: refs/heads/develop
Commit: 78906a9427757b5d387a18282191835089faebac
Parents: 1682d62
Author: Toivo Adams <to...@gmail.com>
Authored: Sun Mar 22 15:10:37 2015 +0200
Committer: Mark Payne <ma...@hotmail.com>
Committed: Wed May 20 08:35:55 2015 -0400

----------------------------------------------------------------------
 .../nifi-dbcp-service-api/pom.xml               |  2 +-
 .../nifi-dbcp-service-nar/pom.xml               |  4 +-
 .../nifi-dbcp-service/pom.xml                   |  4 +-
 .../org/apache/nifi/dbcp/DBCPServiceTest.java   | 58 +++++++++-----------
 .../nifi-dbcp-service-bundle/pom.xml            |  2 +-
 5 files changed, 32 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/78906a94/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-api/pom.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-api/pom.xml b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-api/pom.xml
index f8ea08a..1eec223 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-api/pom.xml
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-api/pom.xml
@@ -5,7 +5,7 @@
     <parent>
         <groupId>org.apache.nifi</groupId>
         <artifactId>nifi-standard-services</artifactId>
-        <version>0.0.2-incubating-SNAPSHOT</version>
+        <version>0.1.0-incubating-SNAPSHOT</version>
     </parent>
     <artifactId>nifi-dbcp-service-api</artifactId>
     <packaging>jar</packaging>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/78906a94/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service-nar/pom.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service-nar/pom.xml b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service-nar/pom.xml
index 37722db..e7cd28e 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service-nar/pom.xml
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service-nar/pom.xml
@@ -6,7 +6,7 @@
     <parent>
         <groupId>org.apache.nifi</groupId>
         <artifactId>nifi-dbcp-service-bundle</artifactId>
-        <version>0.0.2-incubating-SNAPSHOT</version>
+        <version>0.1.0-incubating-SNAPSHOT</version>
     </parent>
     <artifactId>nifi-dbcp-service-nar</artifactId>
     <packaging>nar</packaging>
@@ -19,7 +19,7 @@
         <dependency>
             <groupId>org.apache.nifi</groupId>
             <artifactId>nifi-dbcp-service</artifactId>
-            <version>0.0.2-incubating-SNAPSHOT</version>
+            <version>0.1.0-incubating-SNAPSHOT</version>
         </dependency>
     </dependencies>
   

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/78906a94/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/pom.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/pom.xml b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/pom.xml
index a17ddff..eec2a17 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/pom.xml
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/pom.xml
@@ -6,7 +6,7 @@
     <parent>
         <groupId>org.apache.nifi</groupId>
         <artifactId>nifi-dbcp-service-bundle</artifactId>
-        <version>0.0.2-incubating-SNAPSHOT</version>
+        <version>0.1.0-incubating-SNAPSHOT</version>
     </parent>
     <artifactId>nifi-dbcp-service</artifactId>
     <packaging>jar</packaging>
@@ -14,7 +14,7 @@
         <dependency>
             <groupId>org.apache.nifi</groupId>
             <artifactId>nifi-dbcp-service-api</artifactId>
-            <version>0.0.2-incubating-SNAPSHOT</version>
+            <version>0.1.0-incubating-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>org.apache.nifi</groupId>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/78906a94/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java
index cb9c208..d5ea3da 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java
@@ -39,6 +39,7 @@ import org.apache.nifi.reporting.InitializationException;
 import org.apache.nifi.util.TestRunner;
 import org.apache.nifi.util.TestRunners;
 import org.junit.Assert;
+import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
@@ -120,6 +121,7 @@ public class DBCPServiceTest {
      * Connect, create table, insert, select, drop table. 
      * 
      */
+    @Ignore
     @Test
     public void testExternalJDBCDriverUsage() throws InitializationException, SQLException {
         final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
@@ -244,7 +246,6 @@ public class DBCPServiceTest {
     	
     	ClassLoader parent = Thread.currentThread().getContextClassLoader();
     	URLClassLoader ucl = new URLClassLoader(urls,parent);
-//    	URLClassLoader ucl = new URLClassLoader(urls);
     	
     	Class<?> clazz = Class.forName("org.mariadb.jdbc.Driver", true, ucl);
     	assertNotNull(clazz);
@@ -253,19 +254,32 @@ public class DBCPServiceTest {
     	Driver shim   = new DriverShim(driver);
     	DriverManager.registerDriver( shim );
     	
-    	// Driver is found when using URL ClassLoader
-    	assertTrue( isDriverAllowed(driver, ucl) );
+    	Driver driver2 = DriverManager.getDriver("jdbc:mariadb://localhost:3306/testdb");
+    	assertNotNull(driver2);
+    }
+    
+    /**
+     *  NB!!!!
+     * 	Prerequisite: file should be present in /var/tmp/mariadb-java-client-1.1.7.jar
+     * 	Prerequisite: access to running MariaDb database server
+     */
+    @Ignore
+    @Test
+    public void testURLClassLoaderGetConnection() throws ClassNotFoundException, MalformedURLException, SQLException, InstantiationException, IllegalAccessException {
     	
-    	// Driver is not found when using parent ClassLoader
-    	// unfortunately DriverManager will use caller ClassLoadar and driver is not found !!!  
-//    	assertTrue( isDriverAllowed(driver, parent) );
+    	URL url = new URL("file:///var/tmp/mariadb-java-client-1.1.7.jar");
+    	URL[] urls = new URL[] { url };
+    	
+    	ClassLoader parent = Thread.currentThread().getContextClassLoader();
+    	URLClassLoader ucl = new URLClassLoader(urls,parent);
+    	
+    	Class<?> clazz = Class.forName("org.mariadb.jdbc.Driver", true, ucl);
+    	assertNotNull(clazz);
+    	
+    	Driver driver = (Driver) clazz.newInstance();
+    	Driver shim   = new DriverShim(driver);
+    	DriverManager.registerDriver( shim );
     	
-    	Enumeration<Driver> drivers = DriverManager.getDrivers();
-    	while (drivers.hasMoreElements()) {
-			driver = (Driver) drivers.nextElement();
-			System.out.println(driver);
-		}
-
     	Driver driver2 = DriverManager.getDriver("jdbc:mariadb://localhost:3306/testdb");
     	assertNotNull(driver2);
     	
@@ -304,25 +318,5 @@ public class DBCPServiceTest {
 
     	st.close();
     }
-
-    //==================================== problem solving - no suitable driver found, mariadb =========================================
-    // method isDriverAllowed is from DriverManager
-    private static boolean isDriverAllowed(Driver driver, ClassLoader classLoader) {
-        boolean result = false;
-        if(driver != null) {
-            Class<?> aClass = null;
-            try {
-                aClass =  Class.forName(driver.getClass().getName(), true, classLoader);
-            } catch (Exception ex) {
-            	System.out.println(ex);
-                result = false;
-            }
-
-             result = ( aClass == driver.getClass() ) ? true : false;
-        }
-
-        return result;
-    }
-    
     
 }

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/78906a94/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/pom.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/pom.xml b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/pom.xml
index 2a2c74b..5f5b916 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/pom.xml
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/pom.xml
@@ -5,7 +5,7 @@
     <parent>
         <groupId>org.apache.nifi</groupId>
         <artifactId>nifi-standard-services</artifactId>
-        <version>0.0.2-incubating-SNAPSHOT</version>
+        <version>0.1.0-incubating-SNAPSHOT</version>
     </parent>
     <artifactId>nifi-dbcp-service-bundle</artifactId>
     <packaging>pom</packaging>


[7/9] incubator-nifi git commit: Merge branch 'NIFI-322-Db-Connection-Pooling' into develop

Posted by ma...@apache.org.
Merge branch 'NIFI-322-Db-Connection-Pooling' into develop


Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/281ebafc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/281ebafc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/281ebafc

Branch: refs/heads/develop
Commit: 281ebafc2c84c37c0bf0b27f5d17c732ab3662b4
Parents: a66848b 91aaabf
Author: Mark Payne <ma...@hotmail.com>
Authored: Wed May 20 09:54:16 2015 -0400
Committer: Mark Payne <ma...@hotmail.com>
Committed: Wed May 20 09:54:16 2015 -0400

----------------------------------------------------------------------
 nifi/nifi-assembly/LICENSE                      |  29 ++
 nifi/nifi-assembly/pom.xml                      |   6 +
 .../nifi-dbcp-service-api/pom.xml               |  31 ++
 .../java/org/apache/nifi/dbcp/DBCPService.java  |  34 ++
 .../nifi-dbcp-service-nar/pom.xml               |  37 +++
 .../src/main/resources/META-INF/NOTICE          |  22 ++
 .../nifi-dbcp-service/pom.xml                   |  65 ++++
 .../apache/nifi/dbcp/DBCPConnectionPool.java    | 269 +++++++++++++++
 .../nifi/dbcp/DatabaseSystemDescriptor.java     |  50 +++
 .../org/apache/nifi/dbcp/DatabaseSystems.java   |  82 +++++
 .../java/org/apache/nifi/dbcp/DriverShim.java   |  74 +++++
 ...org.apache.nifi.controller.ControllerService |  15 +
 .../org/apache/nifi/dbcp/DBCPServiceTest.java   | 331 +++++++++++++++++++
 .../apache/nifi/dbcp/TestDatabaseSystems.java   |  31 ++
 .../org/apache/nifi/dbcp/TestProcessor.java     |  45 +++
 .../nifi-dbcp-service-bundle/pom.xml            |  29 ++
 .../nifi-standard-services-api-nar/pom.xml      |   6 +
 .../nifi-standard-services/pom.xml              |   2 +
 nifi/pom.xml                                    |   5 +
 19 files changed, 1163 insertions(+)
----------------------------------------------------------------------



[9/9] incubator-nifi git commit: Merge branch 'develop' of http://git-wip-us.apache.org/repos/asf/incubator-nifi into develop

Posted by ma...@apache.org.
Merge branch 'develop' of http://git-wip-us.apache.org/repos/asf/incubator-nifi into develop


Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/149ad130
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/149ad130
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/149ad130

Branch: refs/heads/develop
Commit: 149ad130d91b06167db7fb45112d16fa341ad04b
Parents: e0ee55e 8c7dd6a
Author: Mark Payne <ma...@hotmail.com>
Authored: Wed May 20 12:41:51 2015 -0400
Committer: Mark Payne <ma...@hotmail.com>
Committed: Wed May 20 12:41:51 2015 -0400

----------------------------------------------------------------------
 nifi-site/Gruntfile.js                | 10 ++++++++++
 nifi-site/src/pages/html/download.hbs |  1 +
 2 files changed, 11 insertions(+)
----------------------------------------------------------------------



[6/9] incubator-nifi git commit: NIFI-322: Fixed checkstyle errors, licensing issues, unit tests

Posted by ma...@apache.org.
NIFI-322: Fixed checkstyle errors, licensing issues, unit tests


Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/91aaabfa
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/91aaabfa
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/91aaabfa

Branch: refs/heads/develop
Commit: 91aaabfa4c0533641568d82f0940402a28e5e8b7
Parents: 78906a9
Author: Mark Payne <ma...@hotmail.com>
Authored: Wed May 20 09:53:36 2015 -0400
Committer: Mark Payne <ma...@hotmail.com>
Committed: Wed May 20 09:53:36 2015 -0400

----------------------------------------------------------------------
 nifi/nifi-assembly/LICENSE                      |  29 ++
 nifi/nifi-assembly/pom.xml                      |   6 +
 .../nifi-dbcp-service-api/pom.xml               |  19 +-
 .../java/org/apache/nifi/dbcp/DBCPService.java  |   6 +-
 .../nifi-dbcp-service-nar/pom.xml               |  25 +-
 .../src/main/resources/META-INF/NOTICE          |  22 ++
 .../nifi-dbcp-service/pom.xml                   |  23 +-
 .../apache/nifi/dbcp/DBCPConnectionPool.java    | 178 ++++++------
 .../nifi/dbcp/DatabaseSystemDescriptor.java     |  43 ++-
 .../org/apache/nifi/dbcp/DatabaseSystems.java   | 106 +++----
 .../java/org/apache/nifi/dbcp/DriverShim.java   |  84 +++---
 .../org/apache/nifi/dbcp/DBCPServiceTest.java   | 289 ++++++++++---------
 .../apache/nifi/dbcp/TestDatabaseSystems.java   |  18 +-
 .../org/apache/nifi/dbcp/TestProcessor.java     |  12 +-
 .../nifi-dbcp-service-bundle/pom.xml            |  21 +-
 .../nifi-standard-services-api-nar/pom.xml      |   2 +-
 .../nifi-standard-services/pom.xml              |   1 +
 nifi/pom.xml                                    |   5 +
 18 files changed, 497 insertions(+), 392 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/91aaabfa/nifi/nifi-assembly/LICENSE
----------------------------------------------------------------------
diff --git a/nifi/nifi-assembly/LICENSE b/nifi/nifi-assembly/LICENSE
index ec360de..984bcea 100644
--- a/nifi/nifi-assembly/LICENSE
+++ b/nifi/nifi-assembly/LICENSE
@@ -851,3 +851,32 @@ For details see http://asm.ow2.org/asmdex-license.html
     ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     THE POSSIBILITY OF SUCH DAMAGE.
 
+The binary distribution of this product bundles 'Hamcrest' which is available
+under a BSD license.  More details found here: http://hamcrest.org.
+
+	Copyright (c) 2000-2006, www.hamcrest.org
+	All rights reserved.
+	
+	Redistribution and use in source and binary forms, with or without
+	modification, are permitted provided that the following conditions are met:
+	
+	Redistributions of source code must retain the above copyright notice, this list of
+	conditions and the following disclaimer. Redistributions in binary form must reproduce
+	the above copyright notice, this list of conditions and the following disclaimer in
+	the documentation and/or other materials provided with the distribution.
+	
+	Neither the name of Hamcrest nor the names of its contributors may be used to endorse
+	or promote products derived from this software without specific prior written
+	permission.
+	
+	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+	EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+	OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+	SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+	INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+	TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+	BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
+	WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+	DAMAGE.
+	    
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/91aaabfa/nifi/nifi-assembly/pom.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-assembly/pom.xml b/nifi/nifi-assembly/pom.xml
index cfe1de6..8c060aa 100644
--- a/nifi/nifi-assembly/pom.xml
+++ b/nifi/nifi-assembly/pom.xml
@@ -164,6 +164,12 @@ language governing permissions and limitations under the License. -->
         </dependency>
         <dependency>
             <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-dbcp-service-nar</artifactId>
+	        <version>0.1.0-incubating-SNAPSHOT</version>
+            <type>nar</type>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
             <artifactId>nifi-mongodb-nar</artifactId>
             <type>nar</type>
         </dependency>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/91aaabfa/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-api/pom.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-api/pom.xml b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-api/pom.xml
index 1eec223..9924d2d 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-api/pom.xml
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-api/pom.xml
@@ -1,12 +1,25 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    
-    
+    <!--
+      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.
+    -->
     <modelVersion>4.0.0</modelVersion>
     <parent>
         <groupId>org.apache.nifi</groupId>
         <artifactId>nifi-standard-services</artifactId>
-        <version>0.1.0-incubating-SNAPSHOT</version>
+        <version>0.1.1-incubating-SNAPSHOT</version>
     </parent>
+    
     <artifactId>nifi-dbcp-service-api</artifactId>
     <packaging>jar</packaging>
     <dependencies>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/91aaabfa/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-api/src/main/java/org/apache/nifi/dbcp/DBCPService.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-api/src/main/java/org/apache/nifi/dbcp/DBCPService.java b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-api/src/main/java/org/apache/nifi/dbcp/DBCPService.java
index 8f2aa5a..9cfe096 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-api/src/main/java/org/apache/nifi/dbcp/DBCPService.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-api/src/main/java/org/apache/nifi/dbcp/DBCPService.java
@@ -28,11 +28,7 @@ import org.apache.nifi.processor.exception.ProcessException;
  *
  */
 @Tags({"dbcp", "jdbc", "database", "connection", "pooling", "store"})
-@CapabilityDescription("Provides Database Connection Pooling Service. Connections can be asked from pool and returned after usage."
-        )
+@CapabilityDescription("Provides Database Connection Pooling Service. Connections can be asked from pool and returned after usage.")
 public interface DBCPService extends ControllerService {
-
- 
     public Connection getConnection()  throws ProcessException;
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/91aaabfa/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service-nar/pom.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service-nar/pom.xml b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service-nar/pom.xml
index e7cd28e..c75b9aa 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service-nar/pom.xml
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service-nar/pom.xml
@@ -1,13 +1,25 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
-
-
+    <!--
+      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.
+    -->
     <modelVersion>4.0.0</modelVersion>
     <parent>
         <groupId>org.apache.nifi</groupId>
         <artifactId>nifi-dbcp-service-bundle</artifactId>
-        <version>0.1.0-incubating-SNAPSHOT</version>
+        <version>0.1.1-incubating-SNAPSHOT</version>
     </parent>
+    
     <artifactId>nifi-dbcp-service-nar</artifactId>
     <packaging>nar</packaging>
     <dependencies>
@@ -19,10 +31,7 @@
         <dependency>
             <groupId>org.apache.nifi</groupId>
             <artifactId>nifi-dbcp-service</artifactId>
-            <version>0.1.0-incubating-SNAPSHOT</version>
+            <version>0.1.1-incubating-SNAPSHOT</version>
         </dependency>
     </dependencies>
-  
-  
-  
 </project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/91aaabfa/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service-nar/src/main/resources/META-INF/NOTICE
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service-nar/src/main/resources/META-INF/NOTICE b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service-nar/src/main/resources/META-INF/NOTICE
new file mode 100644
index 0000000..d24b785
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service-nar/src/main/resources/META-INF/NOTICE
@@ -0,0 +1,22 @@
+nifi-dbcp-service-nar
+Copyright 2014-2015 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+===========================================
+Apache Software License v2
+===========================================
+
+The following binary components are provided under the Apache Software License v2
+
+  (ASLv2) Apache Commons DBCP
+    The following NOTICE information applies:
+      Apache Commons DBCP
+      Copyright 2001-2015 The Apache Software Foundation.
+      
+  (ASLv2) Apache Derby
+    The following NOTICE information applies:
+      Apache Derby
+      Copyright 2004-2014 Apache, Apache DB, Apache Derby, Apache Torque, Apache JDO, Apache DDLUtils, 
+      the Derby hat logo, the Apache JDO logo, and the Apache feather logo are trademarks of The Apache Software Foundation.

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/91aaabfa/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/pom.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/pom.xml b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/pom.xml
index eec2a17..a300b58 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/pom.xml
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/pom.xml
@@ -1,20 +1,32 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
-
-
+    <!--
+      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.
+    -->
     <modelVersion>4.0.0</modelVersion>  
     <parent>
         <groupId>org.apache.nifi</groupId>
         <artifactId>nifi-dbcp-service-bundle</artifactId>
-        <version>0.1.0-incubating-SNAPSHOT</version>
+        <version>0.1.1-incubating-SNAPSHOT</version>
     </parent>
+    
     <artifactId>nifi-dbcp-service</artifactId>
     <packaging>jar</packaging>
     <dependencies>
         <dependency>
             <groupId>org.apache.nifi</groupId>
             <artifactId>nifi-dbcp-service-api</artifactId>
-            <version>0.1.0-incubating-SNAPSHOT</version>
+            <version>0.1.1-incubating-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>org.apache.nifi</groupId>
@@ -48,7 +60,6 @@
 			<artifactId>hamcrest-all</artifactId>
 			<version>1.3</version>
 		</dependency>
-		        
     </dependencies>
   
 </project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/91aaabfa/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DBCPConnectionPool.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DBCPConnectionPool.java b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DBCPConnectionPool.java
index e2c0fea..ef42be3 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DBCPConnectionPool.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DBCPConnectionPool.java
@@ -46,19 +46,18 @@ import org.apache.nifi.reporting.InitializationException;
  *
  */
 @Tags({"dbcp", "jdbc", "database", "connection", "pooling", "store"})
-@CapabilityDescription("Provides Database Connection Pooling Service. Connections can be asked from pool and returned after usage."
-        )
+@CapabilityDescription("Provides Database Connection Pooling Service. Connections can be asked from pool and returned after usage.")
 public class DBCPConnectionPool extends AbstractControllerService implements DBCPService {
 
-	public static final DatabaseSystemDescriptor DEFAULT_DATABASE_SYSTEM = DatabaseSystems.getDescriptor("JavaDB");
+    public static final DatabaseSystemDescriptor DEFAULT_DATABASE_SYSTEM = DatabaseSystems.getDescriptor("JavaDB");
 
     public static final PropertyDescriptor DATABASE_SYSTEM = new PropertyDescriptor.Builder()
-    .name("Database")
+    .name("Database Type")
     .description("Database management system")
     .allowableValues(DatabaseSystems.knownDatabaseSystems)
     .defaultValue(DEFAULT_DATABASE_SYSTEM.getValue())
     .required(true)
-    .build();    
+    .build();
 
     public static final PropertyDescriptor DB_HOST = new PropertyDescriptor.Builder()
     .name("Database Host")
@@ -71,7 +70,6 @@ public class DBCPConnectionPool extends AbstractControllerService implements DBC
     public static final PropertyDescriptor DB_PORT = new PropertyDescriptor.Builder()
     .name("Database Port")
     .description("Database server port")
-    .defaultValue(DEFAULT_DATABASE_SYSTEM.defaultPort.toString())
     .required(true)
     .addValidator(StandardValidators.PORT_VALIDATOR)
     .build();
@@ -119,23 +117,23 @@ public class DBCPConnectionPool extends AbstractControllerService implements DBC
 
     public static final PropertyDescriptor MAX_WAIT_TIME = new PropertyDescriptor.Builder()
     .name("Max Wait Time")
-    .description("The maximum amount of time that the pool will wait (when there are no available connections) " 
-     + " for a connection to be returned before failing, or -1 to wait indefinitely. ")
-    .defaultValue("500 millis")
-    .required(true)
-    .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR)
-    .sensitive(false)
-    .build();
+    .description("The maximum amount of time that the pool will wait (when there are no available connections) "
+        + " for a connection to be returned before failing, or -1 to wait indefinitely. ")
+        .defaultValue("500 millis")
+        .required(true)
+        .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR)
+        .sensitive(false)
+        .build();
 
     public static final PropertyDescriptor MAX_TOTAL_CONNECTIONS = new PropertyDescriptor.Builder()
     .name("Max Total Connections")
-    .description("The maximum number of active connections that can be allocated from this pool at the same time, " 
-     + " or negative for no limit.")
-    .defaultValue("8")
-    .required(true)
-    .addValidator(StandardValidators.INTEGER_VALIDATOR)
-    .sensitive(true)
-    .build();
+    .description("The maximum number of active connections that can be allocated from this pool at the same time, "
+        + " or negative for no limit.")
+        .defaultValue("8")
+        .required(true)
+        .addValidator(StandardValidators.INTEGER_VALIDATOR)
+        .sensitive(false)
+        .build();
 
     private static final List<PropertyDescriptor> properties;
 
@@ -151,10 +149,10 @@ public class DBCPConnectionPool extends AbstractControllerService implements DBC
         props.add(DB_PASSWORD);
         props.add(MAX_WAIT_TIME);
         props.add(MAX_TOTAL_CONNECTIONS);
-        
+
         properties = Collections.unmodifiableList(props);
     }
-    
+
     private volatile BasicDataSource dataSource;
 
     @Override
@@ -163,81 +161,81 @@ public class DBCPConnectionPool extends AbstractControllerService implements DBC
     }
 
     /**
-     *  Create new pool, open some connections ready to be used
-     * @param context
-     * @throws InitializationException
+     * Create new pool, open some connections ready to be used
+     * @param context the configuration context
+     * @throws InitializationException if unable to create a database connection
      */
     @OnEnabled
     public void onConfigured(final ConfigurationContext context) throws InitializationException {
-
         DatabaseSystemDescriptor dbsystem = DatabaseSystems.getDescriptor( context.getProperty(DATABASE_SYSTEM).getValue() );
-        
-        String host   = context.getProperty(DB_HOST).getValue();
-        Integer port  = context.getProperty(DB_PORT).asInteger();
-        String drv    = context.getProperty(DB_DRIVERNAME).getValue();
+
+        String host = context.getProperty(DB_HOST).getValue();
+        Integer port = context.getProperty(DB_PORT).asInteger();
+        String drv = context.getProperty(DB_DRIVERNAME).getValue();
         String dbname = context.getProperty(DB_NAME).getValue();
-        String user   = context.getProperty(DB_USER).getValue();
-        String passw  = context.getProperty(DB_PASSWORD).getValue();
+        String user = context.getProperty(DB_USER).getValue();
+        String passw = context.getProperty(DB_PASSWORD).getValue();
         Long maxWaitMillis = context.getProperty(MAX_WAIT_TIME).asTimePeriod(TimeUnit.MILLISECONDS);
-        Integer maxTotal  = context.getProperty(MAX_TOTAL_CONNECTIONS).asInteger();
-        
-        dataSource = new BasicDataSource();        
+        Integer maxTotal = context.getProperty(MAX_TOTAL_CONNECTIONS).asInteger();
+
+        dataSource = new BasicDataSource();
         dataSource.setDriverClassName(drv);
-        
+
         // Optional driver URL, when exist, this URL will be used to locate driver jar file location
-        String urlString	= context.getProperty(DB_DRIVER_JAR_URL).getValue();
+        String urlString = context.getProperty(DB_DRIVER_JAR_URL).getValue();
         dataSource.setDriverClassLoader( getDriverClassLoader(urlString, drv) );
-        
-        String dburl  = dbsystem.buildUrl(host, port, dbname);
-        
+
+        String dburl = dbsystem.buildUrl(host, port, dbname);
+
         dataSource.setMaxWait(maxWaitMillis);
         dataSource.setMaxActive(maxTotal);
 
         dataSource.setUrl(dburl);
         dataSource.setUsername(user);
         dataSource.setPassword(passw);
-        
+
         // verify connection can be established.
         try {
-			Connection con = dataSource.getConnection();
-			if (con==null)
-				throw new InitializationException("Connection to database cannot be established.");
-			con.close();
-		} catch (SQLException e) {
-			throw new InitializationException(e);
-		}
+            Connection con = dataSource.getConnection();
+            if (con==null) {
+                throw new InitializationException("Connection to database cannot be established.");
+            }
+            con.close();
+        } catch (SQLException e) {
+            throw new InitializationException(e);
+        }
     }
-    
-    /**	
-     * 	using Thread.currentThread().getContextClassLoader();
+
+    /**
+     * using Thread.currentThread().getContextClassLoader();
      * will ensure that you are using the ClassLoader for you NAR.
-     * @throws InitializationException 
+     * @throws InitializationException if there is a problem obtaining the ClassLoader
      */
     protected ClassLoader getDriverClassLoader(String urlString, String drvName) throws InitializationException {
         if (urlString!=null && urlString.length()>0) {
-        	try {
-				URL[] urls = new URL[] { new URL(urlString) };
-				URLClassLoader ucl = new URLClassLoader(urls);
-				
-				// Workaround which allows to use URLClassLoader for JDBC driver loading.
-				// (Because the DriverManager will refuse to use a driver not loaded by the system ClassLoader.) 
-		    	Class<?> clazz = Class.forName(drvName, true, ucl);
-		    	if (clazz==null)
-		    		throw new InitializationException("Can't load Database Driver " + drvName);
-		    	Driver driver = (Driver) clazz.newInstance();
-		    	DriverManager.registerDriver( new DriverShim(driver) );
-				
-				return ucl;
-				
-			} catch (MalformedURLException e) {
-				throw new InitializationException("Invalid Database Driver Jar Url", e);
-			} catch (Exception e) {
-				throw new InitializationException("Can't load Database Driver", e);
-			}
-        }
-        else 
-            // That will ensure that you are using the ClassLoader for you NAR. 
+            try {
+                URL[] urls = new URL[] { new URL(urlString) };
+                URLClassLoader ucl = new URLClassLoader(urls);
+
+                // Workaround which allows to use URLClassLoader for JDBC driver loading.
+                // (Because the DriverManager will refuse to use a driver not loaded by the system ClassLoader.)
+                Class<?> clazz = Class.forName(drvName, true, ucl);
+                if (clazz==null) {
+                    throw new InitializationException("Can't load Database Driver " + drvName);
+                }
+                Driver driver = (Driver) clazz.newInstance();
+                DriverManager.registerDriver( new DriverShim(driver) );
+
+                return ucl;
+            } catch (MalformedURLException e) {
+                throw new InitializationException("Invalid Database Driver Jar Url", e);
+            } catch (Exception e) {
+                throw new InitializationException("Can't load Database Driver", e);
+            }
+        } else {
+            // That will ensure that you are using the ClassLoader for you NAR.
             return Thread.currentThread().getContextClassLoader();
+        }
     }
 
     /**
@@ -245,23 +243,23 @@ public class DBCPConnectionPool extends AbstractControllerService implements DBC
      */
     @OnDisabled
     public void shutdown() {
-    	try {
-			dataSource.close();
-		} catch (SQLException e) {
-			throw new ProcessException(e);
-		}
+        try {
+            dataSource.close();
+        } catch (SQLException e) {
+            throw new ProcessException(e);
+        }
+    }
+
+
+    @Override
+    public Connection getConnection() throws ProcessException {
+        try {
+            Connection con = dataSource.getConnection();
+            return con;
+        } catch (SQLException e) {
+            throw new ProcessException(e);
+        }
     }
-    
-    
-	@Override
-	public Connection getConnection() throws ProcessException {
-		try {
-			Connection con = dataSource.getConnection();
-			return con;
-		} catch (SQLException e) {
-			throw new ProcessException(e);
-		}
-	}
 
     @Override
     public String toString() {

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/91aaabfa/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DatabaseSystemDescriptor.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DatabaseSystemDescriptor.java b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DatabaseSystemDescriptor.java
index d456c3b..fd45421 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DatabaseSystemDescriptor.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DatabaseSystemDescriptor.java
@@ -26,26 +26,25 @@ import org.apache.nifi.components.AllowableValue;
  */
 public class DatabaseSystemDescriptor extends AllowableValue {
 
-	public final String driverClassName;
-	public final Integer defaultPort;
-	public final String urlTemplate;
-	public final boolean internalDriverJar;
-	
-	public DatabaseSystemDescriptor(String value, String description,
-			String driverClassName, Integer	defaultPort, String urlTemplate, boolean internalDriverJar) {
-		super(value, value, description);
-		
-		if (defaultPort==null)
-			throw new IllegalArgumentException("defaultPort cannot be null");
-
-		this.driverClassName = driverClassName;
-		this.defaultPort	 = defaultPort;
-		this.urlTemplate	 = urlTemplate;
-		this.internalDriverJar = internalDriverJar;
-	}
-
-	public String buildUrl(String host, Integer port, String dbname) {
-		return MessageFormat.format(urlTemplate, host, port.toString(), dbname);
-	}
-	
+    public final String driverClassName;
+    public final Integer defaultPort;
+    public final String urlTemplate;
+    public final boolean internalDriverJar;
+
+    public DatabaseSystemDescriptor(String value, String description, String driverClassName, Integer defaultPort, String urlTemplate, boolean internalDriverJar) {
+        super(value, value, description);
+
+        if (defaultPort==null)
+            throw new IllegalArgumentException("defaultPort cannot be null");
+
+        this.driverClassName = driverClassName;
+        this.defaultPort = defaultPort;
+        this.urlTemplate = urlTemplate;
+        this.internalDriverJar = internalDriverJar;
+    }
+
+    public String buildUrl(String host, Integer port, String dbname) {
+        return MessageFormat.format(urlTemplate, host, port.toString(), dbname);
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/91aaabfa/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DatabaseSystems.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DatabaseSystems.java b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DatabaseSystems.java
index 1859b72..2d21cd7 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DatabaseSystems.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DatabaseSystems.java
@@ -18,61 +18,65 @@ package org.apache.nifi.dbcp;
 
 public class DatabaseSystems {
 
-	/**
-	 *	{0}		host name/ip
-	 *	{1}		port number  
-	 *  {2}		database name
-	 * 
-	 * for example url template
-	 *   "jdbc:postgresql://{0}:{1}/{2}"
-	 * will be after building
-	 *  "jdbc:postgresql://bighost:5432/Trove"
-	 * 
-	 */
-	
-	public static DatabaseSystemDescriptor[] knownDatabaseSystems = { 
-		
-		// =================  JDBC driver jar should be included in nar (in pom.xml dependencies) =======================
-		
-		new DatabaseSystemDescriptor("Postgres", "PostgreSQL open soure object-relational database.", 
-				"org.postgresql.Driver", 5432, "jdbc:postgresql://{0}:{1}/{2}", true),
+    /**
+     * Currently contain only few known Database systems.
+     * Please help to expand this list.
+     *
+     * Please be ensure that all JDBC drivers are license-compatible with Apache.
+     * http://www.apache.org/legal/resolved.html
+     * If not include them in "JDBC driver jar must be loaded from external location" section
+     * and do not include actual driver in NiFi distribution (don't include driver in pom.xml file)
+     *
+     * {0} host name/ip
+     * {1} port number
+     * {2} database name
+     *
+     * for example url template
+     *   "jdbc:postgresql://{0}:{1}/{2}"
+     * will be after building
+     *  "jdbc:postgresql://bighost:5432/Trove"
+     */
+    public static DatabaseSystemDescriptor[] knownDatabaseSystems = {
+        // =================  JDBC driver jar should be included in nar (in pom.xml dependencies) =======================
 
-		new DatabaseSystemDescriptor("JavaDB", "Java DB is Oracle's supported distribution of the Apache Derby open source database. Included in JDK.", 
-				"org.apache.derby.jdbc.EmbeddedDriver", 1, "jdbc:derby:{2};create=true", true),
-				
-		new DatabaseSystemDescriptor("Derby", "Apache Derby is an open source relational database.", 
-				"org.apache.derby.jdbc.EmbeddedDriver", 1, "jdbc:derby:{2};create=true", true),
-	
+        new DatabaseSystemDescriptor("Postgres", "PostgreSQL open soure object-relational database.",
+            "org.postgresql.Driver", 5432, "jdbc:postgresql://{0}:{1}/{2}", true),
 
-		// =================  JDBC driver jar must be loaded from external location  =======================
-				
-		new DatabaseSystemDescriptor("MariaDB",
-				"MariaDB is a community-developed fork of the MySQL relational database management system intended to remain free under the GNU GPL.", 
-				"org.mariadb.jdbc.Driver", 3306, "jdbc:mariadb://{0}:{1}/{2}", false),
+            new DatabaseSystemDescriptor("JavaDB", "Java DB is Oracle's supported distribution of the Apache Derby open source database. Included in JDK.",
+                "org.apache.derby.jdbc.EmbeddedDriver", 1, "jdbc:derby:{2};create=true", true),
 
-		new DatabaseSystemDescriptor("Oracle",
-				"Oracle Database is an object-relational database management system.", 
-				"oracle.jdbc.OracleDriver", 1521, "jdbc:oracle:thin:@//{0}:{1}/{2}", false),
+                new DatabaseSystemDescriptor("Derby", "Apache Derby is an open source relational database.",
+                    "org.apache.derby.jdbc.EmbeddedDriver", 1, "jdbc:derby:{2};create=true", true),
 
-		new DatabaseSystemDescriptor("Sybase",
-				"Sybase is an relational database management system.", 
-				"com.sybase.jdbc3.jdbc.SybDriver", 5000, "jdbc:sybase:Tds:{0}:{1}/{2}", false),
+
+                    // =================  JDBC driver jar must be loaded from external location  =======================
+                    // Such drivers cannot be included in NiFi distribution because are not license-compatible with Apache.
+                    new DatabaseSystemDescriptor("MariaDB",
+                        "MariaDB is a community-developed fork of the MySQL relational database management system intended to remain free under the GNU GPL.",
+                        "org.mariadb.jdbc.Driver", 3306, "jdbc:mariadb://{0}:{1}/{2}", false),
+
+                        new DatabaseSystemDescriptor("Oracle",
+                            "Oracle Database is an object-relational database management system.",
+                            "oracle.jdbc.OracleDriver", 1521, "jdbc:oracle:thin:@//{0}:{1}/{2}", false),
+
+                            new DatabaseSystemDescriptor("Sybase",
+                                "Sybase is an relational database management system.",
+                                "com.sybase.jdbc3.jdbc.SybDriver", 5000, "jdbc:sybase:Tds:{0}:{1}/{2}", false),
+
+
+                                // =================  Unknown JDBC driver, user must provide connection details =====================
+                                new DatabaseSystemDescriptor("Other DB", "Other JDBC compliant JDBC driver",
+                                    null, 1, null, false),
+
+    };
+
+    public static DatabaseSystemDescriptor getDescriptor(String name) {
+        for ( DatabaseSystemDescriptor descr : DatabaseSystems.knownDatabaseSystems) {
+            if (descr.getValue().equalsIgnoreCase(name))
+                return descr;
+        }
+        throw new IllegalArgumentException("Can't find DatabaseSystemDescriptor by name " + name);
+    }
 
 
-		// =================  Unknown JDBC driver, user must provide connection details =====================		
-				
-		new DatabaseSystemDescriptor("Other DB", "Other JDBC compliant JDBC driver", 
-				null, 1, null, false),
-		
-	};
-	
-	public static DatabaseSystemDescriptor getDescriptor(String name) {
-		for ( DatabaseSystemDescriptor descr : DatabaseSystems.knownDatabaseSystems) {
-			if (descr.getValue().equalsIgnoreCase(name))
-				return descr;
-		}
-		throw new IllegalArgumentException("Can't find DatabaseSystemDescriptor by name " + name);
-	}
-	
-	
 }

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/91aaabfa/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DriverShim.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DriverShim.java b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DriverShim.java
index 8905d9d..596f171 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DriverShim.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DriverShim.java
@@ -26,49 +26,49 @@ import java.util.logging.Logger;
 
 /**
  *  Workaround which allows to use URLClassLoader for JDBC driver loading.
- *  (Because the DriverManager will refuse to use a driver not loaded by the system ClassLoader.) 
+ *  (Because the DriverManager will refuse to use a driver not loaded by the system ClassLoader.)
  *
  */
 class DriverShim implements Driver {
-	private Driver driver;
-	
-	DriverShim(Driver d) {
-		this.driver = d;
-	}
-	
-	@Override
-	public boolean acceptsURL(String u) throws SQLException {
-		return this.driver.acceptsURL(u);
-	}
-	
-	@Override
-	public Connection connect(String u, Properties p) throws SQLException {
-		return this.driver.connect(u, p);
-	}
-	
-	@Override
-	public int getMajorVersion() {
-		return this.driver.getMajorVersion();
-	}
-	
-	@Override
-	public int getMinorVersion() {
-		return this.driver.getMinorVersion();
-	}
-	
-	@Override
-	public DriverPropertyInfo[] getPropertyInfo(String u, Properties p) throws SQLException {
-		return this.driver.getPropertyInfo(u, p);
-	}
-	
-	@Override
-	public boolean jdbcCompliant() {
-		return this.driver.jdbcCompliant();
-	}
-	
-	@Override
-	public Logger getParentLogger() throws SQLFeatureNotSupportedException {
-		return driver.getParentLogger();
-	}
-	
+    private Driver driver;
+
+    DriverShim(Driver d) {
+        this.driver = d;
+    }
+
+    @Override
+    public boolean acceptsURL(String u) throws SQLException {
+        return this.driver.acceptsURL(u);
+    }
+
+    @Override
+    public Connection connect(String u, Properties p) throws SQLException {
+        return this.driver.connect(u, p);
+    }
+
+    @Override
+    public int getMajorVersion() {
+        return this.driver.getMajorVersion();
+    }
+
+    @Override
+    public int getMinorVersion() {
+        return this.driver.getMinorVersion();
+    }
+
+    @Override
+    public DriverPropertyInfo[] getPropertyInfo(String u, Properties p) throws SQLException {
+        return this.driver.getPropertyInfo(u, p);
+    }
+
+    @Override
+    public boolean jdbcCompliant() {
+        return this.driver.jdbcCompliant();
+    }
+
+    @Override
+    public Logger getParentLogger() throws SQLFeatureNotSupportedException {
+        return driver.getParentLogger();
+    }
+
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/91aaabfa/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java
index d5ea3da..541df8f 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java
@@ -17,7 +17,8 @@
 package org.apache.nifi.dbcp;
 
 import static org.apache.nifi.dbcp.DatabaseSystems.getDescriptor;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 
 import java.io.File;
 import java.net.MalformedURLException;
@@ -29,9 +30,7 @@ import java.sql.DriverManager;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
-import java.util.Enumeration;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
 
 import org.apache.nifi.processor.exception.ProcessException;
@@ -39,19 +38,26 @@ import org.apache.nifi.reporting.InitializationException;
 import org.apache.nifi.util.TestRunner;
 import org.apache.nifi.util.TestRunners;
 import org.junit.Assert;
+import org.junit.BeforeClass;
 import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 
 public class DBCPServiceTest {
-    
-	final static String DB_LOCATION = "/var/tmp/testdb";
-	
-	/**
-	 *	Unknown database system.  
-	 * 
-	 */
+
+    final static String DB_LOCATION = "target/db";
+
+    @BeforeClass
+    public static void setup() {
+        System.setProperty("derby.stream.error.file", "target/derby.log");
+    }
+
+
+    /**
+     *    Unknown database system.
+     *
+     */
     @Test
     public void testUnknownDatabaseSystem() throws InitializationException {
         final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
@@ -61,10 +67,10 @@ public class DBCPServiceTest {
         runner.addControllerService("test-bad2", service, properties);
         runner.assertNotValid(service);
     }
-    
+
     /**
      *  Missing property values.
-     */    
+     */
     @Test
     public void testMissingPropertyValues() throws InitializationException {
         final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
@@ -75,30 +81,30 @@ public class DBCPServiceTest {
     }
 
     /**
-     * 	Test database connection using Derby.
-     * Connect, create table, insert, select, drop table. 
-     * 
+     * Test database connection using Derby.
+     * Connect, create table, insert, select, drop table.
+     *
      */
     @Test
     public void testCreateInsertSelect() throws InitializationException, SQLException {
         final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
         final DBCPConnectionPool service = new DBCPConnectionPool();
         runner.addControllerService("test-good1", service);
-        
+
         // remove previous test database, if any
         File dbLocation = new File(DB_LOCATION);
         dbLocation.delete();
-        
-        // Should setProperty call also generate DBCPConnectionPool.onPropertyModified() method call? 
+
+        // Should setProperty call also generate DBCPConnectionPool.onPropertyModified() method call?
         // It does not currently.
-        
+
         // Some properties already should have JavaDB/Derby default values, let's set only missing values.
-        
-        runner.setProperty(service, DBCPConnectionPool.DB_HOST, "NA");	// Embedded Derby don't use host
+        runner.setProperty(service, DBCPConnectionPool.DB_HOST, "NA");    // Embedded Derby don't use host
+        runner.setProperty(service, DBCPConnectionPool.DB_PORT, "1");  // Embedded Derby don't use port, but must have value anyway
         runner.setProperty(service, DBCPConnectionPool.DB_NAME, DB_LOCATION);
-        runner.setProperty(service, DBCPConnectionPool.DB_USER, 	"tester");
+        runner.setProperty(service, DBCPConnectionPool.DB_USER,     "tester");
         runner.setProperty(service, DBCPConnectionPool.DB_PASSWORD, "testerp");
-        
+
         runner.enableControllerService(service);
 
         runner.assertValid(service);
@@ -106,20 +112,20 @@ public class DBCPServiceTest {
         Assert.assertNotNull(dbcpService);
         Connection connection = dbcpService.getConnection();
         Assert.assertNotNull(connection);
-        
+
         createInsertSelectDrop(connection);
-        
-        connection.close();		// return to pool
+
+        connection.close(); // return to pool
     }
 
     /**
      *  NB!!!!
-     * 	Prerequisite: file should be present in /var/tmp/mariadb-java-client-1.1.7.jar
-     * 	Prerequisite: access to running MariaDb database server
-     * 
-     * 	Test database connection using external JDBC jar located by URL.
-     * Connect, create table, insert, select, drop table. 
-     * 
+     *     Prerequisite: file should be present in /var/tmp/mariadb-java-client-1.1.7.jar
+     *     Prerequisite: access to running MariaDb database server
+     *
+     *     Test database connection using external JDBC jar located by URL.
+     * Connect, create table, insert, select, drop table.
+     *
      */
     @Ignore
     @Test
@@ -127,22 +133,22 @@ public class DBCPServiceTest {
         final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
         final DBCPConnectionPool service = new DBCPConnectionPool();
         runner.addControllerService("test-external-jar", service);
-        
+
         DatabaseSystemDescriptor mariaDb = getDescriptor("MariaDB");
         assertNotNull(mariaDb);
-        
+
         // Set MariaDB properties values.
         runner.setProperty(service, DBCPConnectionPool.DATABASE_SYSTEM, mariaDb.getValue());
-        runner.setProperty(service, DBCPConnectionPool.DB_PORT, 		mariaDb.defaultPort.toString());
-        runner.setProperty(service, DBCPConnectionPool.DB_DRIVERNAME, 	mariaDb.driverClassName);
+        runner.setProperty(service, DBCPConnectionPool.DB_PORT,         mariaDb.defaultPort.toString());
+        runner.setProperty(service, DBCPConnectionPool.DB_DRIVERNAME,     mariaDb.driverClassName);
         runner.setProperty(service, DBCPConnectionPool.DB_DRIVER_JAR_URL, "file:///var/tmp/mariadb-java-client-1.1.7.jar");
-        
-        
-        runner.setProperty(service, DBCPConnectionPool.DB_HOST, "localhost");	// localhost
+
+
+        runner.setProperty(service, DBCPConnectionPool.DB_HOST, "localhost");    // localhost
         runner.setProperty(service, DBCPConnectionPool.DB_NAME, "testdb");
-        runner.setProperty(service, DBCPConnectionPool.DB_USER, 	"tester");
+        runner.setProperty(service, DBCPConnectionPool.DB_USER,     "tester");
         runner.setProperty(service, DBCPConnectionPool.DB_PASSWORD, "testerp");
-        
+
         runner.enableControllerService(service);
 
         runner.assertValid(service);
@@ -150,173 +156,176 @@ public class DBCPServiceTest {
         Assert.assertNotNull(dbcpService);
         Connection connection = dbcpService.getConnection();
         Assert.assertNotNull(connection);
-        
+
         createInsertSelectDrop(connection);
-        
-        connection.close();		// return to pool
+
+        connection.close();        // return to pool
     }
 
-    
+
     @Rule
     public ExpectedException exception = ExpectedException.none();
-    
+
     /**
-     * 	Test get database connection using Derby.
+     *     Test get database connection using Derby.
      * Get many times, after a while pool should not contain any available connection
-     * and getConnection should fail.    
+     * and getConnection should fail.
      */
     @Test
     public void testExhaustPool() throws InitializationException, SQLException {
         final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
         final DBCPConnectionPool service = new DBCPConnectionPool();
         runner.addControllerService("test-exhaust", service);
-        
+
         // remove previous test database, if any
         File dbLocation = new File(DB_LOCATION);
         dbLocation.delete();
-        
-        runner.setProperty(service, DBCPConnectionPool.DB_HOST, "NA");	// Embedded Derby don't use host
+
+        runner.setProperty(service, DBCPConnectionPool.DB_HOST, "NA");    // Embedded Derby don't use host
+        runner.setProperty(service, DBCPConnectionPool.DB_PORT, "1");   // Embedded Derby don't use port, but must have value anyway
         runner.setProperty(service, DBCPConnectionPool.DB_NAME, DB_LOCATION);
-        runner.setProperty(service, DBCPConnectionPool.DB_USER, 	"tester");
+        runner.setProperty(service, DBCPConnectionPool.DB_USER, "tester");
         runner.setProperty(service, DBCPConnectionPool.DB_PASSWORD, "testerp");
-        
+
         runner.enableControllerService(service);
 
         runner.assertValid(service);
         DBCPService dbcpService = (DBCPService) runner.getProcessContext().getControllerServiceLookup().getControllerService("test-exhaust");
         Assert.assertNotNull(dbcpService);
-        
+
         exception.expect(ProcessException.class);
         exception.expectMessage("Cannot get a connection, pool error Timeout waiting for idle object");
         for (int i = 0; i < 100; i++) {
             Connection connection = dbcpService.getConnection();
             Assert.assertNotNull(connection);
-		}
+        }
     }
 
     /**
-     * 	Test get database connection using Derby.
+     *     Test get database connection using Derby.
      * Get many times, release immediately
-     * and getConnection should not fail.    
+     * and getConnection should not fail.
      */
     @Test
     public void testGetManyNormal() throws InitializationException, SQLException {
         final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
         final DBCPConnectionPool service = new DBCPConnectionPool();
         runner.addControllerService("test-exhaust", service);
-        
+
         // remove previous test database, if any
         File dbLocation = new File(DB_LOCATION);
         dbLocation.delete();
-        
-        runner.setProperty(service, DBCPConnectionPool.DB_HOST, "NA");	// Embedded Derby don't use host
+
+        runner.setProperty(service, DBCPConnectionPool.DB_HOST, "NA");    // Embedded Derby don't use host
+        runner.setProperty(service, DBCPConnectionPool.DB_PORT, "1");   // Embedded Derby don't use port, but must have value anyway
         runner.setProperty(service, DBCPConnectionPool.DB_NAME, DB_LOCATION);
-        runner.setProperty(service, DBCPConnectionPool.DB_USER, 	"tester");
+        runner.setProperty(service, DBCPConnectionPool.DB_USER, "tester");
         runner.setProperty(service, DBCPConnectionPool.DB_PASSWORD, "testerp");
-        
+
         runner.enableControllerService(service);
 
         runner.assertValid(service);
         DBCPService dbcpService = (DBCPService) runner.getProcessContext().getControllerServiceLookup().getControllerService("test-exhaust");
         Assert.assertNotNull(dbcpService);
-        
+
         for (int i = 0; i < 1000; i++) {
             Connection connection = dbcpService.getConnection();
             Assert.assertNotNull(connection);
-            connection.close();
-		}
+            connection.close();         // will return connection to pool
+        }
     }
-    
-    
+
+
     @Test
     public void testDriverLoad() throws ClassNotFoundException {
-    	Class<?> clazz = Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
-    	assertNotNull(clazz);
+        Class<?> clazz = Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
+        assertNotNull(clazz);
     }
-    
+
     /**
      *  NB!!!!
-     * 	Prerequisite: file should be present in /var/tmp/mariadb-java-client-1.1.7.jar
+     *     Prerequisite: file should be present in /var/tmp/mariadb-java-client-1.1.7.jar
      */
     @Test
+    @Ignore("Intended only for local testing, not automated testing")
     public void testURLClassLoader() throws ClassNotFoundException, MalformedURLException, SQLException, InstantiationException, IllegalAccessException {
-    	
-    	URL url = new URL("file:///var/tmp/mariadb-java-client-1.1.7.jar");
-    	URL[] urls = new URL[] { url };
-    	
-    	ClassLoader parent = Thread.currentThread().getContextClassLoader();
-    	URLClassLoader ucl = new URLClassLoader(urls,parent);
-    	
-    	Class<?> clazz = Class.forName("org.mariadb.jdbc.Driver", true, ucl);
-    	assertNotNull(clazz);
-    	
-    	Driver driver = (Driver) clazz.newInstance();
-    	Driver shim   = new DriverShim(driver);
-    	DriverManager.registerDriver( shim );
-    	
-    	Driver driver2 = DriverManager.getDriver("jdbc:mariadb://localhost:3306/testdb");
-    	assertNotNull(driver2);
+
+        URL url = new URL("file:///var/tmp/mariadb-java-client-1.1.7.jar");
+        URL[] urls = new URL[] { url };
+
+        ClassLoader parent = Thread.currentThread().getContextClassLoader();
+        URLClassLoader ucl = new URLClassLoader(urls,parent);
+
+        Class<?> clazz = Class.forName("org.mariadb.jdbc.Driver", true, ucl);
+        assertNotNull(clazz);
+
+        Driver driver = (Driver) clazz.newInstance();
+        Driver shim   = new DriverShim(driver);
+        DriverManager.registerDriver( shim );
+
+        Driver driver2 = DriverManager.getDriver("jdbc:mariadb://localhost:3306/testdb");
+        assertNotNull(driver2);
     }
-    
+
     /**
      *  NB!!!!
-     * 	Prerequisite: file should be present in /var/tmp/mariadb-java-client-1.1.7.jar
-     * 	Prerequisite: access to running MariaDb database server
+     *     Prerequisite: file should be present in /var/tmp/mariadb-java-client-1.1.7.jar
+     *     Prerequisite: access to running MariaDb database server
      */
-    @Ignore
     @Test
+    @Ignore("Intended only for local testing, not automated testing")
     public void testURLClassLoaderGetConnection() throws ClassNotFoundException, MalformedURLException, SQLException, InstantiationException, IllegalAccessException {
-    	
-    	URL url = new URL("file:///var/tmp/mariadb-java-client-1.1.7.jar");
-    	URL[] urls = new URL[] { url };
-    	
-    	ClassLoader parent = Thread.currentThread().getContextClassLoader();
-    	URLClassLoader ucl = new URLClassLoader(urls,parent);
-    	
-    	Class<?> clazz = Class.forName("org.mariadb.jdbc.Driver", true, ucl);
-    	assertNotNull(clazz);
-    	
-    	Driver driver = (Driver) clazz.newInstance();
-    	Driver shim   = new DriverShim(driver);
-    	DriverManager.registerDriver( shim );
-    	
-    	Driver driver2 = DriverManager.getDriver("jdbc:mariadb://localhost:3306/testdb");
-    	assertNotNull(driver2);
-    	
-    	Connection connection = DriverManager.getConnection("jdbc:mariadb://localhost:3306/testdb","tester","testerp");
-    	assertNotNull(connection);
-    	connection.close();
-    	
-    	DriverManager.deregisterDriver(shim);
+
+        URL url = new URL("file:///var/tmp/mariadb-java-client-1.1.7.jar");
+        URL[] urls = new URL[] { url };
+
+        ClassLoader parent = Thread.currentThread().getContextClassLoader();
+        URLClassLoader ucl = new URLClassLoader(urls,parent);
+
+        Class<?> clazz = Class.forName("org.mariadb.jdbc.Driver", true, ucl);
+        assertNotNull(clazz);
+
+        Driver driver = (Driver) clazz.newInstance();
+        Driver shim   = new DriverShim(driver);
+        DriverManager.registerDriver( shim );
+
+        Driver driver2 = DriverManager.getDriver("jdbc:mariadb://localhost:3306/testdb");
+        assertNotNull(driver2);
+
+        Connection connection = DriverManager.getConnection("jdbc:mariadb://localhost:3306/testdb","tester","testerp");
+        assertNotNull(connection);
+        connection.close();
+
+        DriverManager.deregisterDriver(shim);
     }
 
-    
-	String createTable = "create table restaurants(id integer, name varchar(20), city varchar(50))";
-	String dropTable = "drop table restaurants";
-    
+
+    String createTable = "create table restaurants(id integer, name varchar(20), city varchar(50))";
+    String dropTable = "drop table restaurants";
+
     protected void createInsertSelectDrop( Connection con) throws SQLException {
-    	
-    	Statement st = con.createStatement();
-    	
-    	try {
-        	st.executeUpdate(dropTable);
-		} catch (Exception e) {
-			// table may not exist, this is not serious problem.
-		}
-    	
-		st.executeUpdate(createTable);
-    	
-    	st.executeUpdate("insert into restaurants values (1, 'Irifunes', 'San Mateo')");
-    	st.executeUpdate("insert into restaurants values (2, 'Estradas', 'Daly City')");
-    	st.executeUpdate("insert into restaurants values (3, 'Prime Rib House', 'San Francisco')");
-
-    	int nrOfRows = 0;
-    	ResultSet resultSet = st.executeQuery("select * from restaurants");
-    	while (resultSet.next())
-    		nrOfRows++;
-    	assertEquals(3, nrOfRows);
-
-    	st.close();
+
+        Statement st = con.createStatement();
+
+        try {
+            st.executeUpdate(dropTable);
+        } catch (Exception e) {
+            // table may not exist, this is not serious problem.
+        }
+
+        st.executeUpdate(createTable);
+
+        st.executeUpdate("insert into restaurants values (1, 'Irifunes', 'San Mateo')");
+        st.executeUpdate("insert into restaurants values (2, 'Estradas', 'Daly City')");
+        st.executeUpdate("insert into restaurants values (3, 'Prime Rib House', 'San Francisco')");
+
+        int nrOfRows = 0;
+        ResultSet resultSet = st.executeQuery("select * from restaurants");
+        while (resultSet.next())
+            nrOfRows++;
+        assertEquals(3, nrOfRows);
+
+        st.close();
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/91aaabfa/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/TestDatabaseSystems.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/TestDatabaseSystems.java b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/TestDatabaseSystems.java
index 2a360b2..3c9064e 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/TestDatabaseSystems.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/TestDatabaseSystems.java
@@ -16,22 +16,16 @@
  */
 package org.apache.nifi.dbcp;
 
-import static org.junit.Assert.*;
+import static org.apache.nifi.dbcp.DatabaseSystems.getDescriptor;
+import static org.junit.Assert.assertEquals;
 
 import org.junit.Test;
-import static org.apache.nifi.dbcp.DatabaseSystems.getDescriptor;
 
 public class TestDatabaseSystems {
 
-	@Test
-	public void testKnownDatabaseSystems() {
-		
-		assertEquals( "jdbc:postgresql://bighost:5432/Trove", getDescriptor("Postgres").buildUrl("bighost",5432,"Trove") ); 
-		
-	}
+    @Test
+    public void testKnownDatabaseSystems() {
+        assertEquals("jdbc:postgresql://bighost:5432/Trove", getDescriptor("Postgres").buildUrl("bighost",5432,"Trove"));
+    }
 
-	
-	
-	
-	
 }

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/91aaabfa/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/TestProcessor.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/TestProcessor.java b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/TestProcessor.java
index b25d3f1..cadeee9 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/TestProcessor.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/TestProcessor.java
@@ -16,7 +16,6 @@
  */
 package org.apache.nifi.dbcp;
 
-import org.apache.nifi.dbcp.DBCPService;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -25,7 +24,6 @@ import org.apache.nifi.processor.AbstractProcessor;
 import org.apache.nifi.processor.ProcessContext;
 import org.apache.nifi.processor.ProcessSession;
 import org.apache.nifi.processor.exception.ProcessException;
-import org.apache.nifi.processor.util.StandardValidators;
 
 public class TestProcessor extends AbstractProcessor {
 
@@ -37,11 +35,11 @@ public class TestProcessor extends AbstractProcessor {
     protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
         List<PropertyDescriptor> propDescs = new ArrayList<>();
         propDescs.add(new PropertyDescriptor.Builder()
-                .name("DBCPService test processor")
-                .description("DBCPService test processor")
-                .addValidator(StandardValidators.createControllerServiceExistsValidator(DBCPService.class))
-                .required(true)
-                .build());
+        .name("DBCPService test processor")
+        .description("DBCPService test processor")
+        .identifiesControllerService(DBCPService.class)
+        .required(true)
+        .build());
         return propDescs;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/91aaabfa/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/pom.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/pom.xml b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/pom.xml
index 5f5b916..61a6946 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/pom.xml
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/pom.xml
@@ -1,18 +1,29 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
-
+    <!--
+      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.
+    -->
     <modelVersion>4.0.0</modelVersion>
     <parent>
         <groupId>org.apache.nifi</groupId>
         <artifactId>nifi-standard-services</artifactId>
-        <version>0.1.0-incubating-SNAPSHOT</version>
+        <version>0.1.1-incubating-SNAPSHOT</version>
     </parent>
+    
     <artifactId>nifi-dbcp-service-bundle</artifactId>
     <packaging>pom</packaging>
     <modules>
         <module>nifi-dbcp-service</module>
         <module>nifi-dbcp-service-nar</module>
     </modules>
-    
-    
 </project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/91aaabfa/nifi/nifi-nar-bundles/nifi-standard-services/nifi-standard-services-api-nar/pom.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-standard-services-api-nar/pom.xml b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-standard-services-api-nar/pom.xml
index fbc20c6..0d624ff 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-standard-services-api-nar/pom.xml
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-standard-services-api-nar/pom.xml
@@ -45,7 +45,7 @@
         <dependency>
             <groupId>org.apache.nifi</groupId>
             <artifactId>nifi-dbcp-service-api</artifactId>
-            <version>0.1.0-incubating-SNAPSHOT</version>
+            <version>0.1.1-incubating-SNAPSHOT</version>
             <scope>compile</scope>
         </dependency>
     </dependencies>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/91aaabfa/nifi/nifi-nar-bundles/nifi-standard-services/pom.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/pom.xml b/nifi/nifi-nar-bundles/nifi-standard-services/pom.xml
index d225986..b851854 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-services/pom.xml
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/pom.xml
@@ -32,5 +32,6 @@
 		<module>nifi-http-context-map-bundle</module>
         <module>nifi-standard-services-api-nar</module>
         <module>nifi-dbcp-service-api</module>
+        <module>nifi-dbcp-service-bundle</module>
     </modules>
 </project>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/91aaabfa/nifi/pom.xml
----------------------------------------------------------------------
diff --git a/nifi/pom.xml b/nifi/pom.xml
index f8d2638..d86d480 100644
--- a/nifi/pom.xml
+++ b/nifi/pom.xml
@@ -833,6 +833,11 @@
                 <version>0.1.1-incubating-SNAPSHOT</version>
             </dependency>
             <dependency>
+                <groupId>org.apache.nifi</groupId>
+                <artifactId>nifi-dbcp-service</artifactId>
+                <version>0.1.1-incubating-SNAPSHOT</version>
+            </dependency>
+            <dependency>
                 <groupId>com.jayway.jsonpath</groupId>
                 <artifactId>json-path</artifactId>
                 <version>2.0.0</version>


[8/9] incubator-nifi git commit: NIFI-322: Fixed version number

Posted by ma...@apache.org.
NIFI-322: Fixed version number


Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/e0ee55e6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/e0ee55e6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/e0ee55e6

Branch: refs/heads/develop
Commit: e0ee55e6c44fc563b7a376857d0f81c8133bae74
Parents: 281ebaf
Author: Mark Payne <ma...@hotmail.com>
Authored: Wed May 20 10:53:22 2015 -0400
Committer: Mark Payne <ma...@hotmail.com>
Committed: Wed May 20 10:53:22 2015 -0400

----------------------------------------------------------------------
 nifi/nifi-assembly/pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/e0ee55e6/nifi/nifi-assembly/pom.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-assembly/pom.xml b/nifi/nifi-assembly/pom.xml
index 8c060aa..ba8dc24 100644
--- a/nifi/nifi-assembly/pom.xml
+++ b/nifi/nifi-assembly/pom.xml
@@ -165,7 +165,7 @@ language governing permissions and limitations under the License. -->
         <dependency>
             <groupId>org.apache.nifi</groupId>
             <artifactId>nifi-dbcp-service-nar</artifactId>
-	        <version>0.1.0-incubating-SNAPSHOT</version>
+	        <version>0.1.1-incubating-SNAPSHOT</version>
             <type>nar</type>
         </dependency>
         <dependency>


[2/9] incubator-nifi git commit: Loading external JDBC driver using URLClassLoader

Posted by ma...@apache.org.
Loading external JDBC driver using URLClassLoader

Signed-off-by: Toivo Adams <to...@gmail.com>
Signed-off-by: Mark Payne <ma...@hotmail.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/864e0996
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/864e0996
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/864e0996

Branch: refs/heads/develop
Commit: 864e0996ca0cbbe922d4db25ede0d3ad1e38c3c5
Parents: d1cace6
Author: Toivo Adams <to...@gmail.com>
Authored: Sun Mar 8 19:45:32 2015 +0200
Committer: Mark Payne <ma...@hotmail.com>
Committed: Wed May 20 08:35:54 2015 -0400

----------------------------------------------------------------------
 .../apache/nifi/dbcp/DBCPConnectionPool.java    |  66 +++++++---
 .../org/apache/nifi/dbcp/DBCPServiceTest.java   | 125 +++++++++++++++++--
 2 files changed, 167 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/864e0996/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DBCPConnectionPool.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DBCPConnectionPool.java b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DBCPConnectionPool.java
index a80e9bf..c2511c3 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DBCPConnectionPool.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DBCPConnectionPool.java
@@ -16,11 +16,15 @@
  */
 package org.apache.nifi.dbcp;
 
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.commons.dbcp.BasicDataSource;
 import org.apache.nifi.annotation.documentation.CapabilityDescription;
@@ -78,6 +82,14 @@ public class DBCPConnectionPool extends AbstractControllerService implements DBC
     .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
     .build();
 
+    public static final PropertyDescriptor DB_DRIVER_JAR_URL = new PropertyDescriptor.Builder()
+    .name("Database Driver Jar Url")
+    .description("Optional database driver jar file path url. For example 'file:///var/tmp/mariadb-java-client-1.1.7.jar'")
+    .defaultValue(null)
+    .required(false)
+    .addValidator(StandardValidators.URL_VALIDATOR)
+    .build();
+
     public static final PropertyDescriptor DB_NAME = new PropertyDescriptor.Builder()
     .name("Database Name")
     .description("Database name")
@@ -103,14 +115,14 @@ public class DBCPConnectionPool extends AbstractControllerService implements DBC
     .sensitive(true)
     .build();
 
-    public static final PropertyDescriptor MAX_WAIT_MILLIS = new PropertyDescriptor.Builder()
-    .name("Max Wait Millis")
-    .description("The maximum number of milliseconds that the pool will wait (when there are no available connections) " 
-     + " for a connection to be returned before throwing an exception, or -1 to wait indefinitely. ")
-    .defaultValue("500")
+    public static final PropertyDescriptor MAX_WAIT_TIME = new PropertyDescriptor.Builder()
+    .name("Max Wait Time")
+    .description("The maximum amount of time that the pool will wait (when there are no available connections) " 
+     + " for a connection to be returned before failing, or -1 to wait indefinitely. ")
+    .defaultValue("500 millis")
     .required(true)
-    .addValidator(StandardValidators.LONG_VALIDATOR)
-    .sensitive(true)
+    .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR)
+    .sensitive(false)
     .build();
 
     public static final PropertyDescriptor MAX_TOTAL_CONNECTIONS = new PropertyDescriptor.Builder()
@@ -131,14 +143,16 @@ public class DBCPConnectionPool extends AbstractControllerService implements DBC
         props.add(DB_HOST);
         props.add(DB_PORT);
         props.add(DB_DRIVERNAME);
+        props.add(DB_DRIVER_JAR_URL);
         props.add(DB_NAME);
         props.add(DB_USER);
         props.add(DB_PASSWORD);
+        props.add(MAX_WAIT_TIME);
+        props.add(MAX_TOTAL_CONNECTIONS);
         
         properties = Collections.unmodifiableList(props);
     }
     
-    private ConfigurationContext configContext;
     private volatile BasicDataSource dataSource;
 
     @Override
@@ -153,7 +167,6 @@ public class DBCPConnectionPool extends AbstractControllerService implements DBC
      */
     @OnEnabled
     public void onConfigured(final ConfigurationContext context) throws InitializationException {
-        configContext = context;
 
         DatabaseSystemDescriptor dbsystem = DatabaseSystems.getDescriptor( context.getProperty(DATABASE_SYSTEM).getValue() );
         
@@ -163,23 +176,25 @@ public class DBCPConnectionPool extends AbstractControllerService implements DBC
         String dbname = context.getProperty(DB_NAME).getValue();
         String user   = context.getProperty(DB_USER).getValue();
         String passw  = context.getProperty(DB_PASSWORD).getValue();
-        Long maxWaitMillis = context.getProperty(MAX_WAIT_MILLIS).asLong();
+        Long maxWaitMillis = context.getProperty(MAX_WAIT_TIME).asTimePeriod(TimeUnit.MILLISECONDS);
         Integer maxTotal  = context.getProperty(MAX_TOTAL_CONNECTIONS).asInteger();
         
+        dataSource = new BasicDataSource();        
+        dataSource.setDriverClassName(drv);
+        
+        // Optional driver URL, when exist, this URL will be used to locate driver jar file location
+        String urlString	= context.getProperty(DB_DRIVER_JAR_URL).getValue();
+        dataSource.setDriverClassLoader( getDriverClassLoader(urlString) );
+        
         String dburl  = dbsystem.buildUrl(host, port, dbname);
         
-        dataSource = new BasicDataSource();
         dataSource.setMaxWait(maxWaitMillis);
         dataSource.setMaxActive(maxTotal);
 
         dataSource.setUrl(dburl);
-        dataSource.setDriverClassName(drv);
         dataSource.setUsername(user);
         dataSource.setPassword(passw);
         
-        // That will ensure that you are using the ClassLoader for you NAR. 
-        dataSource.setDriverClassLoader(Thread.currentThread().getContextClassLoader());
-
         // verify connection can be established.
         try {
 			Connection con = dataSource.getConnection();
@@ -191,6 +206,25 @@ public class DBCPConnectionPool extends AbstractControllerService implements DBC
 		}
     }
     
+    /**	
+     * 	using Thread.currentThread().getContextClassLoader();
+     * will ensure that you are using the ClassLoader for you NAR.
+     * @throws InitializationException 
+     */    
+    protected ClassLoader getDriverClassLoader(String urlString) throws InitializationException {
+        if (urlString!=null && urlString.length()>0) {
+        	try {
+				URL[] urls = new URL[] { new URL(urlString) };
+				return new URLClassLoader(urls);
+			} catch (MalformedURLException e) {
+				throw new InitializationException("Invalid Database Driver Jar Url", e);
+			}
+        }
+        else 
+            // That will ensure that you are using the ClassLoader for you NAR. 
+            return Thread.currentThread().getContextClassLoader();
+    }
+
     /**
      *  Shutdown pool, close all open connections.
      */
@@ -216,7 +250,7 @@ public class DBCPConnectionPool extends AbstractControllerService implements DBC
 
     @Override
     public String toString() {
-        return "DBCPServiceApacheDBCP14[id=" + getIdentifier() + "]";
+        return "DBCPConnectionPool[id=" + getIdentifier() + "]";
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/864e0996/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java
index e93faad..07d1398 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java
@@ -16,15 +16,22 @@
  */
 package org.apache.nifi.dbcp;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.apache.nifi.dbcp.DatabaseSystems.getDescriptor;
+import static org.junit.Assert.*;
 
 import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
 import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.DriverManager;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
+import java.util.Enumeration;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.Map;
 
 import org.apache.nifi.processor.exception.ProcessException;
@@ -44,7 +51,7 @@ public class DBCPServiceTest {
 	 *	Unknown database system.  
 	 * 
 	 */
-    @Test
+//    @Test
     public void testUnknownDatabaseSystem() throws InitializationException {
         final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
         final DBCPConnectionPool service = new DBCPConnectionPool();
@@ -57,7 +64,7 @@ public class DBCPServiceTest {
     /**
      *  Missing property values.
      */    
-    @Test
+//    @Test
     public void testMissingPropertyValues() throws InitializationException {
         final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
         final DBCPConnectionPool service = new DBCPConnectionPool();
@@ -71,7 +78,7 @@ public class DBCPServiceTest {
      * Connect, create table, insert, select, drop table. 
      * 
      */
-    @Test
+//    @Test
     public void testCreateInsertSelect() throws InitializationException, SQLException {
         final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
         final DBCPConnectionPool service = new DBCPConnectionPool();
@@ -104,6 +111,49 @@ public class DBCPServiceTest {
         connection.close();		// return to pool
     }
 
+    /**
+     *  NB!!!!
+     * 	Prerequisite: file should be present in /var/tmp/mariadb-java-client-1.1.7.jar
+     * 	Prerequisite: access to running MariaDb database server
+     * 
+     * 	Test database connection using external JDBC jar located by URL.
+     * Connect, create table, insert, select, drop table. 
+     * 
+     */
+//    @Test
+    public void testExternalJDBCDriverUsage() throws InitializationException, SQLException {
+        final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
+        final DBCPConnectionPool service = new DBCPConnectionPool();
+        runner.addControllerService("test-external-jar", service);
+        
+        DatabaseSystemDescriptor mariaDb = getDescriptor("MariaDB");
+        assertNotNull(mariaDb);
+        
+        // Set MariaDB properties values.
+        runner.setProperty(service, DBCPConnectionPool.DATABASE_SYSTEM, mariaDb.getValue());
+        runner.setProperty(service, DBCPConnectionPool.DB_PORT, 		mariaDb.defaultPort.toString());
+        runner.setProperty(service, DBCPConnectionPool.DB_DRIVERNAME, 	mariaDb.driverClassName);
+        runner.setProperty(service, DBCPConnectionPool.DB_DRIVER_JAR_URL, "file:///var/tmp/mariadb-java-client-1.1.7.jar");
+        
+        
+        runner.setProperty(service, DBCPConnectionPool.DB_HOST, "127.0.0.1");	// localhost
+        runner.setProperty(service, DBCPConnectionPool.DB_NAME, "testdb");
+        runner.setProperty(service, DBCPConnectionPool.DB_USER, 	"tester");
+        runner.setProperty(service, DBCPConnectionPool.DB_PASSWORD, "testerp");
+        
+        runner.enableControllerService(service);
+
+        runner.assertValid(service);
+        DBCPService dbcpService = (DBCPService) runner.getProcessContext().getControllerServiceLookup().getControllerService("test-external-jar");
+        Assert.assertNotNull(dbcpService);
+        Connection connection = dbcpService.getConnection();
+        Assert.assertNotNull(connection);
+        
+        createInsertSelectDrop(connection);
+        
+        connection.close();		// return to pool
+    }
+
     
     @Rule
     public ExpectedException exception = ExpectedException.none();
@@ -113,7 +163,7 @@ public class DBCPServiceTest {
      * Get many times, after a while pool should not contain any available connection
      * and getConnection should fail.    
      */
-    @Test
+//    @Test
     public void testExhaustPool() throws InitializationException, SQLException {
         final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
         final DBCPConnectionPool service = new DBCPConnectionPool();
@@ -147,7 +197,7 @@ public class DBCPServiceTest {
      * Get many times, release immediately
      * and getConnection should not fail.    
      */
-    @Test
+//    @Test
     public void testGetManyNormal() throws InitializationException, SQLException {
         final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
         final DBCPConnectionPool service = new DBCPConnectionPool();
@@ -176,12 +226,49 @@ public class DBCPServiceTest {
     }
     
     
-    @Test
+//    @Test
     public void testDriverLoad() throws ClassNotFoundException {
     	Class<?> clazz = Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
     	assertNotNull(clazz);
     }
     
+    /**
+     *  NB!!!!
+     * 	Prerequisite: file should be present in /var/tmp/mariadb-java-client-1.1.7.jar
+     */
+    @Test
+    public void testURLClassLoader() throws ClassNotFoundException, MalformedURLException, SQLException, InstantiationException, IllegalAccessException {
+    	
+    	URL url = new URL("file:///var/tmp/mariadb-java-client-1.1.7.jar");
+    	URL[] urls = new URL[] { url };
+    	
+    	ClassLoader parent = Thread.currentThread().getContextClassLoader();
+    	URLClassLoader ucl = new URLClassLoader(urls,parent);
+    	
+    	Class<?> clazz = Class.forName("org.mariadb.jdbc.Driver", true, ucl);
+    	assertNotNull(clazz);
+    	
+    	Driver driver = (Driver) clazz.newInstance();
+    	
+    	// Driver is found when using URL ClassLoader
+    	assertTrue( isDriverAllowed(driver, ucl) );
+    	
+    	// Driver is not found when using parent ClassLoader
+    	// unfortunately DriverManager will use caller ClassLoadar and driver is not found !!!  
+    	assertTrue( isDriverAllowed(driver, parent) );
+    	
+//    	DriverManager.registerDriver( (Driver) clazz.newInstance());
+    	Enumeration<Driver> drivers = DriverManager.getDrivers();
+    	while (drivers.hasMoreElements()) {
+			driver = (Driver) drivers.nextElement();
+			System.out.println(driver);
+		}
+    	
+    	
+   // 	Driver driver = DriverManager.getDriver("jdbc:mariadb://127.0.0.1:3306/testdb");
+   // 	assertNotNull(driver);
+    }
+
     
 	String createTable = "create table restaurants(id integer, name varchar(20), city varchar(50))";
 	String dropTable = "drop table restaurants";
@@ -211,4 +298,26 @@ public class DBCPServiceTest {
     	st.close();
     }
 
+    //==================================== problem solving - no suitable driver found, mariadb =========================================
+    
+    private static boolean isDriverAllowed(Driver driver, ClassLoader classLoader) {
+        boolean result = false;
+        if(driver != null) {
+            Class<?> aClass = null;
+            try {
+                aClass =  Class.forName(driver.getClass().getName(), true, classLoader);
+            } catch (Exception ex) {
+            	System.out.println(ex);
+                result = false;
+            }
+
+             result = ( aClass == driver.getClass() ) ? true : false;
+        }
+
+        return result;
+    }
+    
+    
+    
+    
 }


[3/9] incubator-nifi git commit: DBCPConnectionPool service fixes

Posted by ma...@apache.org.
DBCPConnectionPool service fixes

Signed-off-by: Toivo Adams <to...@gmail.com>
Signed-off-by: Mark Payne <ma...@hotmail.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/d1cace6a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/d1cace6a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/d1cace6a

Branch: refs/heads/develop
Commit: d1cace6a8a3105d852a595a0e8ca0ec2d397293a
Parents: 589e2b7
Author: Toivo Adams <to...@gmail.com>
Authored: Tue Mar 3 21:18:01 2015 +0200
Committer: Mark Payne <ma...@hotmail.com>
Committed: Wed May 20 08:35:54 2015 -0400

----------------------------------------------------------------------
 .../nifi-dbcp-service/pom.xml                   |   7 +-
 .../apache/nifi/dbcp/DBCPConnectionPool.java    | 222 +++++++++++++++++++
 .../nifi/dbcp/DBCPServiceApacheDBCP14.java      | 208 -----------------
 ...org.apache.nifi.controller.ControllerService |  15 ++
 .../org/apache/nifi/dbcp/DBCPServiceTest.java   |  54 ++---
 5 files changed, 270 insertions(+), 236 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d1cace6a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/pom.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/pom.xml b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/pom.xml
index d06a14c..a17ddff 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/pom.xml
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/pom.xml
@@ -43,7 +43,12 @@
 		    <artifactId>derby</artifactId>
 		    <version>10.11.1.1</version>
 	    </dependency>        
-        
+		<dependency>
+			<groupId>org.hamcrest</groupId>
+			<artifactId>hamcrest-all</artifactId>
+			<version>1.3</version>
+		</dependency>
+		        
     </dependencies>
   
 </project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d1cace6a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DBCPConnectionPool.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DBCPConnectionPool.java b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DBCPConnectionPool.java
new file mode 100644
index 0000000..a80e9bf
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DBCPConnectionPool.java
@@ -0,0 +1,222 @@
+/*
+ * 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.nifi.dbcp;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.commons.dbcp.BasicDataSource;
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.annotation.lifecycle.OnDisabled;
+import org.apache.nifi.annotation.lifecycle.OnEnabled;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.controller.AbstractControllerService;
+import org.apache.nifi.controller.ConfigurationContext;
+import org.apache.nifi.processor.exception.ProcessException;
+import org.apache.nifi.processor.util.StandardValidators;
+import org.apache.nifi.reporting.InitializationException;
+
+/**
+ * Implementation of for Database Connection Pooling Service.
+ * Apache DBCP is used for connection pooling functionality.
+ *
+ */
+@Tags({"dbcp", "jdbc", "database", "connection", "pooling", "store"})
+@CapabilityDescription("Provides Database Connection Pooling Service. Connections can be asked from pool and returned after usage."
+        )
+public class DBCPConnectionPool extends AbstractControllerService implements DBCPService {
+
+	public static final DatabaseSystemDescriptor DEFAULT_DATABASE_SYSTEM = DatabaseSystems.getDescriptor("JavaDB");
+
+    public static final PropertyDescriptor DATABASE_SYSTEM = new PropertyDescriptor.Builder()
+    .name("Database")
+    .description("Database management system")
+    .allowableValues(DatabaseSystems.knownDatabaseSystems)
+    .defaultValue(DEFAULT_DATABASE_SYSTEM.getValue())
+    .required(true)
+    .build();    
+
+    public static final PropertyDescriptor DB_HOST = new PropertyDescriptor.Builder()
+    .name("Database Host")
+    .description("Database Host")
+    .defaultValue(null)
+    .required(true)
+    .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+    .build();
+
+    public static final PropertyDescriptor DB_PORT = new PropertyDescriptor.Builder()
+    .name("Database Port")
+    .description("Database server port")
+    .defaultValue(DEFAULT_DATABASE_SYSTEM.defaultPort.toString())
+    .required(true)
+    .addValidator(StandardValidators.PORT_VALIDATOR)
+    .build();
+
+    public static final PropertyDescriptor DB_DRIVERNAME = new PropertyDescriptor.Builder()
+    .name("Database Driver Class Name")
+    .description("Database driver class name")
+    .defaultValue(DEFAULT_DATABASE_SYSTEM.driverClassName)
+    .required(true)
+    .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+    .build();
+
+    public static final PropertyDescriptor DB_NAME = new PropertyDescriptor.Builder()
+    .name("Database Name")
+    .description("Database name")
+    .defaultValue(null)
+    .required(true)
+    .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+    .build();
+
+    public static final PropertyDescriptor DB_USER = new PropertyDescriptor.Builder()
+    .name("Database User")
+    .description("Database user name")
+    .defaultValue(null)
+    .required(true)
+    .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+    .build();
+
+    public static final PropertyDescriptor DB_PASSWORD = new PropertyDescriptor.Builder()
+    .name("Password")
+    .description("The password for the database user")
+    .defaultValue(null)
+    .required(true)
+    .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+    .sensitive(true)
+    .build();
+
+    public static final PropertyDescriptor MAX_WAIT_MILLIS = new PropertyDescriptor.Builder()
+    .name("Max Wait Millis")
+    .description("The maximum number of milliseconds that the pool will wait (when there are no available connections) " 
+     + " for a connection to be returned before throwing an exception, or -1 to wait indefinitely. ")
+    .defaultValue("500")
+    .required(true)
+    .addValidator(StandardValidators.LONG_VALIDATOR)
+    .sensitive(true)
+    .build();
+
+    public static final PropertyDescriptor MAX_TOTAL_CONNECTIONS = new PropertyDescriptor.Builder()
+    .name("Max Total Connections")
+    .description("The maximum number of active connections that can be allocated from this pool at the same time, " 
+     + " or negative for no limit.")
+    .defaultValue("8")
+    .required(true)
+    .addValidator(StandardValidators.INTEGER_VALIDATOR)
+    .sensitive(true)
+    .build();
+
+    private static final List<PropertyDescriptor> properties;
+
+    static {
+        List<PropertyDescriptor> props = new ArrayList<>();
+        props.add(DATABASE_SYSTEM);
+        props.add(DB_HOST);
+        props.add(DB_PORT);
+        props.add(DB_DRIVERNAME);
+        props.add(DB_NAME);
+        props.add(DB_USER);
+        props.add(DB_PASSWORD);
+        
+        properties = Collections.unmodifiableList(props);
+    }
+    
+    private ConfigurationContext configContext;
+    private volatile BasicDataSource dataSource;
+
+    @Override
+    protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
+        return properties;
+    }
+
+    /**
+     *  Create new pool, open some connections ready to be used
+     * @param context
+     * @throws InitializationException
+     */
+    @OnEnabled
+    public void onConfigured(final ConfigurationContext context) throws InitializationException {
+        configContext = context;
+
+        DatabaseSystemDescriptor dbsystem = DatabaseSystems.getDescriptor( context.getProperty(DATABASE_SYSTEM).getValue() );
+        
+        String host   = context.getProperty(DB_HOST).getValue();
+        Integer port  = context.getProperty(DB_PORT).asInteger();
+        String drv    = context.getProperty(DB_DRIVERNAME).getValue();
+        String dbname = context.getProperty(DB_NAME).getValue();
+        String user   = context.getProperty(DB_USER).getValue();
+        String passw  = context.getProperty(DB_PASSWORD).getValue();
+        Long maxWaitMillis = context.getProperty(MAX_WAIT_MILLIS).asLong();
+        Integer maxTotal  = context.getProperty(MAX_TOTAL_CONNECTIONS).asInteger();
+        
+        String dburl  = dbsystem.buildUrl(host, port, dbname);
+        
+        dataSource = new BasicDataSource();
+        dataSource.setMaxWait(maxWaitMillis);
+        dataSource.setMaxActive(maxTotal);
+
+        dataSource.setUrl(dburl);
+        dataSource.setDriverClassName(drv);
+        dataSource.setUsername(user);
+        dataSource.setPassword(passw);
+        
+        // That will ensure that you are using the ClassLoader for you NAR. 
+        dataSource.setDriverClassLoader(Thread.currentThread().getContextClassLoader());
+
+        // verify connection can be established.
+        try {
+			Connection con = dataSource.getConnection();
+			if (con==null)
+				throw new InitializationException("Connection to database cannot be established.");
+			con.close();
+		} catch (SQLException e) {
+			throw new InitializationException(e);
+		}
+    }
+    
+    /**
+     *  Shutdown pool, close all open connections.
+     */
+    @OnDisabled
+    public void shutdown() {
+    	try {
+			dataSource.close();
+		} catch (SQLException e) {
+			throw new ProcessException(e);
+		}
+    }
+    
+    
+	@Override
+	public Connection getConnection() throws ProcessException {
+		try {
+			Connection con = dataSource.getConnection();
+			return con;
+		} catch (SQLException e) {
+			throw new ProcessException(e);
+		}
+	}
+
+    @Override
+    public String toString() {
+        return "DBCPServiceApacheDBCP14[id=" + getIdentifier() + "]";
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d1cace6a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DBCPServiceApacheDBCP14.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DBCPServiceApacheDBCP14.java b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DBCPServiceApacheDBCP14.java
deleted file mode 100644
index eb0a950..0000000
--- a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DBCPServiceApacheDBCP14.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * 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.nifi.dbcp;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.commons.dbcp.BasicDataSource;
-import org.apache.nifi.annotation.documentation.CapabilityDescription;
-import org.apache.nifi.annotation.documentation.Tags;
-import org.apache.nifi.annotation.lifecycle.OnEnabled;
-import org.apache.nifi.components.PropertyDescriptor;
-import org.apache.nifi.controller.AbstractControllerService;
-import org.apache.nifi.controller.ConfigurationContext;
-import org.apache.nifi.processor.exception.ProcessException;
-import org.apache.nifi.processor.util.StandardValidators;
-import org.apache.nifi.reporting.InitializationException;
-
-/**
- * Implementation of for Database Connection Pooling Service.
- * Apache DBCP is used for connection pooling functionality.
- *
- */
-@Tags({"dbcp", "jdbc", "database", "connection", "pooling", "store"})
-@CapabilityDescription("Provides Database Connection Pooling Service. Connections can be asked from pool and returned after usage."
-        )
-public class DBCPServiceApacheDBCP14 extends AbstractControllerService implements DBCPService {
-
-	public static final DatabaseSystemDescriptor DEFAULT_DATABASE_SYSTEM = DatabaseSystems.getDescriptor("JavaDB");
-
-    public static final PropertyDescriptor DATABASE_SYSTEM = new PropertyDescriptor.Builder()
-    .name("Database")
-    .description("Database management system")
-//    .allowableValues(POSTGRES, JavaDB, DERBY, MariaDB, OtherDB)
-    .allowableValues(DatabaseSystems.knownDatabaseSystems)
-    .defaultValue(DEFAULT_DATABASE_SYSTEM.getValue())
-    .required(true)
-    .build();    
-
-    public static final PropertyDescriptor DB_HOST = new PropertyDescriptor.Builder()
-    .name("Database host")
-    .description("Database host")
-    .defaultValue(null)
-    .required(true)
-    .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
-    .build();
-
-    public static final PropertyDescriptor DB_PORT = new PropertyDescriptor.Builder()
-    .name("Database port")
-    .description("Database server port")
-    .defaultValue(DEFAULT_DATABASE_SYSTEM.defaultPort.toString())
-    .required(true)
-    .addValidator(StandardValidators.PORT_VALIDATOR)
-    .build();
-
-    public static final PropertyDescriptor DB_DRIVERNAME = new PropertyDescriptor.Builder()
-    .name("Database driver class name")
-    .description("Database driver class name")
-    .defaultValue(DEFAULT_DATABASE_SYSTEM.driverClassName)
-    .required(true)
-    .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
-    .build();
-
-    public static final PropertyDescriptor DB_NAME = new PropertyDescriptor.Builder()
-    .name("Database name")
-    .description("Database name")
-    .defaultValue(null)
-    .required(true)
-    .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
-    .build();
-
-    public static final PropertyDescriptor DB_USER = new PropertyDescriptor.Builder()
-    .name("Database user")
-    .description("Database user name")
-    .defaultValue(null)
-    .required(true)
-    .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
-    .build();
-
-    public static final PropertyDescriptor DB_PASSWORD = new PropertyDescriptor.Builder()
-    .name("Password")
-    .description("The password for the database user")
-    .defaultValue(null)
-    .required(true)
-    .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
-    .sensitive(true)
-    .build();
-
-    private static final List<PropertyDescriptor> properties;
-
-    static {
-        List<PropertyDescriptor> props = new ArrayList<>();
-        props.add(DATABASE_SYSTEM);
-        props.add(DB_HOST);
-        props.add(DB_PORT);
-        props.add(DB_DRIVERNAME);
-        props.add(DB_NAME);
-        props.add(DB_USER);
-        props.add(DB_PASSWORD);
-        
-        properties = Collections.unmodifiableList(props);
-    }
-    
-    private ConfigurationContext configContext;
-    private volatile BasicDataSource dataSource;
-
-    @Override
-    protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
-        return properties;
-    }
-    
-    //=================================   Apache DBCP pool parameters  ================================ 
-    
-    /** The maximum number of milliseconds that the pool will wait (when there are no available connections) 
-     * for a connection to be returned before throwing an exception, or -1 to wait indefinitely. 
-     */
-    static final long maxWaitMillis = 500;
-   
-    /** The maximum number of active connections that can be allocated from this pool at the same time, 
-     * or negative for no limit.
-     */
-    static final int maxTotal 		= 8;
-
-    //=================================================================================================
-    
-    /**
-     * Idea was to dynamically set port, driver and url properties default values after user select database system.
-     * As of 01mar2015 such functionality is not supported.
-     * 
-    @Override
-    public void onPropertyModified(final PropertyDescriptor descriptor, final String oldValue, final String newValue) {
-        super.onPropertyModified(descriptor, oldValue, newValue);
-
-        if (descriptor.equals(DATABASE_SYSTEM)) {
-        	
-        	DatabaseSystemDescriptor databaseSystemDescriptor = DatabaseSystems.getDescriptor(newValue);
-        }        
-    }
-	*/
-
-    @OnEnabled
-    public void onConfigured(final ConfigurationContext context) throws InitializationException {
-        configContext = context;
-
-        DatabaseSystemDescriptor dbsystem = DatabaseSystems.getDescriptor( context.getProperty(DATABASE_SYSTEM).getValue() );
-        
-        String host   = context.getProperty(DB_HOST).getValue();
-        Integer port  = context.getProperty(DB_PORT).asInteger();
-        String drv    = context.getProperty(DB_DRIVERNAME).getValue();
-        String dbname = context.getProperty(DB_NAME).getValue();
-        String user   = context.getProperty(DB_USER).getValue();
-        String passw  = context.getProperty(DB_PASSWORD).getValue();
-        
-        String dburl  = dbsystem.buildUrl(host, port, dbname);
-        
-        dataSource = new BasicDataSource();
-        dataSource.setMaxWait(maxWaitMillis);
-        dataSource.setMaxActive(maxTotal);
-
-        dataSource.setUrl(dburl);
-        dataSource.setDriverClassName(drv);
-        dataSource.setUsername(user);
-        dataSource.setPassword(passw);
-
-        // verify connection can be established.
-        try {
-			Connection con = dataSource.getConnection();
-			if (con==null)
-				throw new InitializationException("Connection to database cannot be established.");
-			con.close();
-		} catch (SQLException e) {
-			throw new InitializationException(e);
-		}
-    }
-    
-	@Override
-	public Connection getConnection() throws ProcessException {
-		try {
-			Connection con = dataSource.getConnection();
-			return con;
-		} catch (SQLException e) {
-			throw new ProcessException(e);
-		}
-	}
-
-    @Override
-    public String toString() {
-        return "DBCPServiceApacheDBCP14[id=" + getIdentifier() + "]";
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d1cace6a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/resources/META-INF/services/org.apache.nifi.controller.ControllerService
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/resources/META-INF/services/org.apache.nifi.controller.ControllerService b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/resources/META-INF/services/org.apache.nifi.controller.ControllerService
new file mode 100644
index 0000000..d022695
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/resources/META-INF/services/org.apache.nifi.controller.ControllerService
@@ -0,0 +1,15 @@
+# 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.
+org.apache.nifi.dbcp.DBCPConnectionPool
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d1cace6a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java
index 684cc76..e93faad 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java
@@ -16,7 +16,8 @@
  */
 package org.apache.nifi.dbcp;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 
 import java.io.File;
 import java.sql.Connection;
@@ -26,8 +27,6 @@ import java.sql.Statement;
 import java.util.HashMap;
 import java.util.Map;
 
-import javax.activation.DataSource;
-
 import org.apache.nifi.processor.exception.ProcessException;
 import org.apache.nifi.reporting.InitializationException;
 import org.apache.nifi.util.TestRunner;
@@ -46,11 +45,11 @@ public class DBCPServiceTest {
 	 * 
 	 */
     @Test
-    public void testBad1() throws InitializationException {
+    public void testUnknownDatabaseSystem() throws InitializationException {
         final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
-        final DBCPServiceApacheDBCP14 service = new DBCPServiceApacheDBCP14();
+        final DBCPConnectionPool service = new DBCPConnectionPool();
         final Map<String, String> properties = new HashMap<String, String>();
-        properties.put(DBCPServiceApacheDBCP14.DATABASE_SYSTEM.getName(), "garbage");
+        properties.put(DBCPConnectionPool.DATABASE_SYSTEM.getName(), "garbage");
         runner.addControllerService("test-bad2", service, properties);
         runner.assertNotValid(service);
     }
@@ -59,9 +58,9 @@ public class DBCPServiceTest {
      *  Missing property values.
      */    
     @Test
-    public void testGood1() throws InitializationException {
+    public void testMissingPropertyValues() throws InitializationException {
         final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
-        final DBCPServiceApacheDBCP14 service = new DBCPServiceApacheDBCP14();
+        final DBCPConnectionPool service = new DBCPConnectionPool();
         final Map<String, String> properties = new HashMap<String, String>();
         runner.addControllerService("test-bad1", service, properties);
         runner.assertNotValid(service);
@@ -73,24 +72,24 @@ public class DBCPServiceTest {
      * 
      */
     @Test
-    public void testGood2() throws InitializationException, SQLException {
+    public void testCreateInsertSelect() throws InitializationException, SQLException {
         final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
-        final DBCPServiceApacheDBCP14 service = new DBCPServiceApacheDBCP14();
+        final DBCPConnectionPool service = new DBCPConnectionPool();
         runner.addControllerService("test-good1", service);
         
         // remove previous test database, if any
         File dbLocation = new File(DB_LOCATION);
         dbLocation.delete();
         
-        // Should setProperty call also generate DBCPServiceApacheDBCP14.onPropertyModified() method call? 
+        // Should setProperty call also generate DBCPConnectionPool.onPropertyModified() method call? 
         // It does not currently.
         
         // Some properties already should have JavaDB/Derby default values, let's set only missing values.
         
-        runner.setProperty(service, DBCPServiceApacheDBCP14.DB_HOST, "NA");	// Embedded Derby don't use host
-        runner.setProperty(service, DBCPServiceApacheDBCP14.DB_NAME, DB_LOCATION);
-        runner.setProperty(service, DBCPServiceApacheDBCP14.DB_USER, 	"tester");
-        runner.setProperty(service, DBCPServiceApacheDBCP14.DB_PASSWORD, "testerp");
+        runner.setProperty(service, DBCPConnectionPool.DB_HOST, "NA");	// Embedded Derby don't use host
+        runner.setProperty(service, DBCPConnectionPool.DB_NAME, DB_LOCATION);
+        runner.setProperty(service, DBCPConnectionPool.DB_USER, 	"tester");
+        runner.setProperty(service, DBCPConnectionPool.DB_PASSWORD, "testerp");
         
         runner.enableControllerService(service);
 
@@ -117,17 +116,17 @@ public class DBCPServiceTest {
     @Test
     public void testExhaustPool() throws InitializationException, SQLException {
         final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
-        final DBCPServiceApacheDBCP14 service = new DBCPServiceApacheDBCP14();
+        final DBCPConnectionPool service = new DBCPConnectionPool();
         runner.addControllerService("test-exhaust", service);
         
         // remove previous test database, if any
         File dbLocation = new File(DB_LOCATION);
         dbLocation.delete();
         
-        runner.setProperty(service, DBCPServiceApacheDBCP14.DB_HOST, "NA");	// Embedded Derby don't use host
-        runner.setProperty(service, DBCPServiceApacheDBCP14.DB_NAME, DB_LOCATION);
-        runner.setProperty(service, DBCPServiceApacheDBCP14.DB_USER, 	"tester");
-        runner.setProperty(service, DBCPServiceApacheDBCP14.DB_PASSWORD, "testerp");
+        runner.setProperty(service, DBCPConnectionPool.DB_HOST, "NA");	// Embedded Derby don't use host
+        runner.setProperty(service, DBCPConnectionPool.DB_NAME, DB_LOCATION);
+        runner.setProperty(service, DBCPConnectionPool.DB_USER, 	"tester");
+        runner.setProperty(service, DBCPConnectionPool.DB_PASSWORD, "testerp");
         
         runner.enableControllerService(service);
 
@@ -136,6 +135,7 @@ public class DBCPServiceTest {
         Assert.assertNotNull(dbcpService);
         
         exception.expect(ProcessException.class);
+        exception.expectMessage("Cannot get a connection, pool error Timeout waiting for idle object");
         for (int i = 0; i < 100; i++) {
             Connection connection = dbcpService.getConnection();
             Assert.assertNotNull(connection);
@@ -148,19 +148,19 @@ public class DBCPServiceTest {
      * and getConnection should not fail.    
      */
     @Test
-    public void testGetMany() throws InitializationException, SQLException {
+    public void testGetManyNormal() throws InitializationException, SQLException {
         final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
-        final DBCPServiceApacheDBCP14 service = new DBCPServiceApacheDBCP14();
+        final DBCPConnectionPool service = new DBCPConnectionPool();
         runner.addControllerService("test-exhaust", service);
         
         // remove previous test database, if any
         File dbLocation = new File(DB_LOCATION);
         dbLocation.delete();
         
-        runner.setProperty(service, DBCPServiceApacheDBCP14.DB_HOST, "NA");	// Embedded Derby don't use host
-        runner.setProperty(service, DBCPServiceApacheDBCP14.DB_NAME, DB_LOCATION);
-        runner.setProperty(service, DBCPServiceApacheDBCP14.DB_USER, 	"tester");
-        runner.setProperty(service, DBCPServiceApacheDBCP14.DB_PASSWORD, "testerp");
+        runner.setProperty(service, DBCPConnectionPool.DB_HOST, "NA");	// Embedded Derby don't use host
+        runner.setProperty(service, DBCPConnectionPool.DB_NAME, DB_LOCATION);
+        runner.setProperty(service, DBCPConnectionPool.DB_USER, 	"tester");
+        runner.setProperty(service, DBCPConnectionPool.DB_PASSWORD, "testerp");
         
         runner.enableControllerService(service);
 
@@ -177,7 +177,7 @@ public class DBCPServiceTest {
     
     
     @Test
-    public void testDriverLaod() throws ClassNotFoundException {
+    public void testDriverLoad() throws ClassNotFoundException {
     	Class<?> clazz = Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
     	assertNotNull(clazz);
     }


[5/9] incubator-nifi git commit: JDBC driver can be loaded from external location using URLClassLoader

Posted by ma...@apache.org.
JDBC driver can be loaded from external location using URLClassLoader

Signed-off-by: Toivo Adams <to...@gmail.com>
Signed-off-by: Mark Payne <ma...@hotmail.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/1682d62d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/1682d62d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/1682d62d

Branch: refs/heads/develop
Commit: 1682d62d7f46ba854f77923352a77ff9f6a1b746
Parents: 864e099
Author: Toivo Adams <to...@gmail.com>
Authored: Sat Mar 14 12:34:40 2015 +0200
Committer: Mark Payne <ma...@hotmail.com>
Committed: Wed May 20 08:35:55 2015 -0400

----------------------------------------------------------------------
 .../apache/nifi/dbcp/DBCPConnectionPool.java    | 23 ++++--
 .../java/org/apache/nifi/dbcp/DriverShim.java   | 74 ++++++++++++++++++++
 .../org/apache/nifi/dbcp/DBCPServiceTest.java   | 35 +++++----
 3 files changed, 113 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/1682d62d/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DBCPConnectionPool.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DBCPConnectionPool.java b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DBCPConnectionPool.java
index c2511c3..e2c0fea 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DBCPConnectionPool.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DBCPConnectionPool.java
@@ -20,6 +20,8 @@ import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.DriverManager;
 import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -184,7 +186,7 @@ public class DBCPConnectionPool extends AbstractControllerService implements DBC
         
         // Optional driver URL, when exist, this URL will be used to locate driver jar file location
         String urlString	= context.getProperty(DB_DRIVER_JAR_URL).getValue();
-        dataSource.setDriverClassLoader( getDriverClassLoader(urlString) );
+        dataSource.setDriverClassLoader( getDriverClassLoader(urlString, drv) );
         
         String dburl  = dbsystem.buildUrl(host, port, dbname);
         
@@ -210,14 +212,27 @@ public class DBCPConnectionPool extends AbstractControllerService implements DBC
      * 	using Thread.currentThread().getContextClassLoader();
      * will ensure that you are using the ClassLoader for you NAR.
      * @throws InitializationException 
-     */    
-    protected ClassLoader getDriverClassLoader(String urlString) throws InitializationException {
+     */
+    protected ClassLoader getDriverClassLoader(String urlString, String drvName) throws InitializationException {
         if (urlString!=null && urlString.length()>0) {
         	try {
 				URL[] urls = new URL[] { new URL(urlString) };
-				return new URLClassLoader(urls);
+				URLClassLoader ucl = new URLClassLoader(urls);
+				
+				// Workaround which allows to use URLClassLoader for JDBC driver loading.
+				// (Because the DriverManager will refuse to use a driver not loaded by the system ClassLoader.) 
+		    	Class<?> clazz = Class.forName(drvName, true, ucl);
+		    	if (clazz==null)
+		    		throw new InitializationException("Can't load Database Driver " + drvName);
+		    	Driver driver = (Driver) clazz.newInstance();
+		    	DriverManager.registerDriver( new DriverShim(driver) );
+				
+				return ucl;
+				
 			} catch (MalformedURLException e) {
 				throw new InitializationException("Invalid Database Driver Jar Url", e);
+			} catch (Exception e) {
+				throw new InitializationException("Can't load Database Driver", e);
 			}
         }
         else 

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/1682d62d/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DriverShim.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DriverShim.java b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DriverShim.java
new file mode 100644
index 0000000..8905d9d
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DriverShim.java
@@ -0,0 +1,74 @@
+/*
+ * 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.nifi.dbcp;
+
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.DriverPropertyInfo;
+import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+import java.util.Properties;
+import java.util.logging.Logger;
+
+/**
+ *  Workaround which allows to use URLClassLoader for JDBC driver loading.
+ *  (Because the DriverManager will refuse to use a driver not loaded by the system ClassLoader.) 
+ *
+ */
+class DriverShim implements Driver {
+	private Driver driver;
+	
+	DriverShim(Driver d) {
+		this.driver = d;
+	}
+	
+	@Override
+	public boolean acceptsURL(String u) throws SQLException {
+		return this.driver.acceptsURL(u);
+	}
+	
+	@Override
+	public Connection connect(String u, Properties p) throws SQLException {
+		return this.driver.connect(u, p);
+	}
+	
+	@Override
+	public int getMajorVersion() {
+		return this.driver.getMajorVersion();
+	}
+	
+	@Override
+	public int getMinorVersion() {
+		return this.driver.getMinorVersion();
+	}
+	
+	@Override
+	public DriverPropertyInfo[] getPropertyInfo(String u, Properties p) throws SQLException {
+		return this.driver.getPropertyInfo(u, p);
+	}
+	
+	@Override
+	public boolean jdbcCompliant() {
+		return this.driver.jdbcCompliant();
+	}
+	
+	@Override
+	public Logger getParentLogger() throws SQLFeatureNotSupportedException {
+		return driver.getParentLogger();
+	}
+	
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/1682d62d/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java
index 07d1398..cb9c208 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/test/java/org/apache/nifi/dbcp/DBCPServiceTest.java
@@ -51,7 +51,7 @@ public class DBCPServiceTest {
 	 *	Unknown database system.  
 	 * 
 	 */
-//    @Test
+    @Test
     public void testUnknownDatabaseSystem() throws InitializationException {
         final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
         final DBCPConnectionPool service = new DBCPConnectionPool();
@@ -64,7 +64,7 @@ public class DBCPServiceTest {
     /**
      *  Missing property values.
      */    
-//    @Test
+    @Test
     public void testMissingPropertyValues() throws InitializationException {
         final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
         final DBCPConnectionPool service = new DBCPConnectionPool();
@@ -78,7 +78,7 @@ public class DBCPServiceTest {
      * Connect, create table, insert, select, drop table. 
      * 
      */
-//    @Test
+    @Test
     public void testCreateInsertSelect() throws InitializationException, SQLException {
         final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
         final DBCPConnectionPool service = new DBCPConnectionPool();
@@ -120,7 +120,7 @@ public class DBCPServiceTest {
      * Connect, create table, insert, select, drop table. 
      * 
      */
-//    @Test
+    @Test
     public void testExternalJDBCDriverUsage() throws InitializationException, SQLException {
         final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
         final DBCPConnectionPool service = new DBCPConnectionPool();
@@ -136,7 +136,7 @@ public class DBCPServiceTest {
         runner.setProperty(service, DBCPConnectionPool.DB_DRIVER_JAR_URL, "file:///var/tmp/mariadb-java-client-1.1.7.jar");
         
         
-        runner.setProperty(service, DBCPConnectionPool.DB_HOST, "127.0.0.1");	// localhost
+        runner.setProperty(service, DBCPConnectionPool.DB_HOST, "localhost");	// localhost
         runner.setProperty(service, DBCPConnectionPool.DB_NAME, "testdb");
         runner.setProperty(service, DBCPConnectionPool.DB_USER, 	"tester");
         runner.setProperty(service, DBCPConnectionPool.DB_PASSWORD, "testerp");
@@ -163,7 +163,7 @@ public class DBCPServiceTest {
      * Get many times, after a while pool should not contain any available connection
      * and getConnection should fail.    
      */
-//    @Test
+    @Test
     public void testExhaustPool() throws InitializationException, SQLException {
         final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
         final DBCPConnectionPool service = new DBCPConnectionPool();
@@ -197,7 +197,7 @@ public class DBCPServiceTest {
      * Get many times, release immediately
      * and getConnection should not fail.    
      */
-//    @Test
+    @Test
     public void testGetManyNormal() throws InitializationException, SQLException {
         final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
         final DBCPConnectionPool service = new DBCPConnectionPool();
@@ -226,7 +226,7 @@ public class DBCPServiceTest {
     }
     
     
-//    @Test
+    @Test
     public void testDriverLoad() throws ClassNotFoundException {
     	Class<?> clazz = Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
     	assertNotNull(clazz);
@@ -244,29 +244,36 @@ public class DBCPServiceTest {
     	
     	ClassLoader parent = Thread.currentThread().getContextClassLoader();
     	URLClassLoader ucl = new URLClassLoader(urls,parent);
+//    	URLClassLoader ucl = new URLClassLoader(urls);
     	
     	Class<?> clazz = Class.forName("org.mariadb.jdbc.Driver", true, ucl);
     	assertNotNull(clazz);
     	
     	Driver driver = (Driver) clazz.newInstance();
+    	Driver shim   = new DriverShim(driver);
+    	DriverManager.registerDriver( shim );
     	
     	// Driver is found when using URL ClassLoader
     	assertTrue( isDriverAllowed(driver, ucl) );
     	
     	// Driver is not found when using parent ClassLoader
     	// unfortunately DriverManager will use caller ClassLoadar and driver is not found !!!  
-    	assertTrue( isDriverAllowed(driver, parent) );
+//    	assertTrue( isDriverAllowed(driver, parent) );
     	
-//    	DriverManager.registerDriver( (Driver) clazz.newInstance());
     	Enumeration<Driver> drivers = DriverManager.getDrivers();
     	while (drivers.hasMoreElements()) {
 			driver = (Driver) drivers.nextElement();
 			System.out.println(driver);
 		}
+
+    	Driver driver2 = DriverManager.getDriver("jdbc:mariadb://localhost:3306/testdb");
+    	assertNotNull(driver2);
     	
+    	Connection connection = DriverManager.getConnection("jdbc:mariadb://localhost:3306/testdb","tester","testerp");
+    	assertNotNull(connection);
+    	connection.close();
     	
-   // 	Driver driver = DriverManager.getDriver("jdbc:mariadb://127.0.0.1:3306/testdb");
-   // 	assertNotNull(driver);
+    	DriverManager.deregisterDriver(shim);
     }
 
     
@@ -299,7 +306,7 @@ public class DBCPServiceTest {
     }
 
     //==================================== problem solving - no suitable driver found, mariadb =========================================
-    
+    // method isDriverAllowed is from DriverManager
     private static boolean isDriverAllowed(Driver driver, ClassLoader classLoader) {
         boolean result = false;
         if(driver != null) {
@@ -318,6 +325,4 @@ public class DBCPServiceTest {
     }
     
     
-    
-    
 }