[hg] main-silver: #229250: Unittest/reproducer for the bug

  • From: Jaroslav Havlin < >
  • To:
  • Subject: [hg] main-silver: #229250: Unittest/reproducer for the bug
  • Date: Tue, 04 Jun 2013 13:34:10 -0700

changeset 8e048bb87ddf in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/8e048bb87ddf
description:
        #229250: Unittest/reproducer for the bug

        Patch by Matthias42.

diffstat:

 db/test/unit/src/org/netbeans/modules/db/util/DriverListUtilTest.java |  42 
++++++++-
 1 files changed, 36 insertions(+), 6 deletions(-)

diffs (80 lines):

diff --git 
a/db/test/unit/src/org/netbeans/modules/db/util/DriverListUtilTest.java 
b/db/test/unit/src/org/netbeans/modules/db/util/DriverListUtilTest.java
--- a/db/test/unit/src/org/netbeans/modules/db/util/DriverListUtilTest.java
+++ b/db/test/unit/src/org/netbeans/modules/db/util/DriverListUtilTest.java
@@ -43,11 +43,15 @@
 package org.netbeans.modules.db.util;
 
 import java.net.MalformedURLException;
+import java.net.URL;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import static junit.framework.Assert.assertEquals;
 import junit.framework.TestCase;
+import org.netbeans.api.db.explorer.JDBCDriver;
 import org.openide.util.NbBundle;
 
 /**
@@ -66,11 +70,9 @@
     private static final String DSN = "mydsn";
     private static final String TNSNAME = "mytns";
     
-    private static final HashMap<String, String> ALLPROPS = 
-            new HashMap<String, String>();
+    private static final HashMap<String, String> ALLPROPS = new HashMap<>();
     
-    private static final ArrayList<String> STD_SUPPORTED_PROPS =
-            new ArrayList<String>();
+    private static final ArrayList<String> STD_SUPPORTED_PROPS = new 
ArrayList<>();
     
     static {
         ALLPROPS.put(JdbcUrl.TOKEN_HOST, HOST);
@@ -95,7 +97,7 @@
     }
     
     public void testNonParsedJdbcUrls() throws Exception {
-        List<JdbcUrl> urls = DriverListUtil.getJdbcUrls();
+        Collection<JdbcUrl> urls = DriverListUtil.getJdbcUrls();
         for ( JdbcUrl url : urls ) {
             if (! url.isParseUrl()) {
                 testNonParsedUrl(url);
@@ -103,8 +105,36 @@
         }
     }
     
+    /**
+     * Reproducer for bug #229250. - Single URL
+     *
+     * @throws MalformedURLException
+     */
+    public void testGetJdbcUrls() throws MalformedURLException {
+        JDBCDriver driver = JDBCDriver.create("Mysql 1", "Mysql 1", 
"com.mysql.jdbc.Driver", new URL[] {new URL("file://demo1")});
+        JDBCDriver driver2 = JDBCDriver.create("Mysql 2", "Mysql 2", 
"com.mysql.jdbc.Driver", new URL[] {new URL("file://demo1")});
+        assertEquals(1, DriverListUtil.getJdbcUrls(driver).size());
+        assertEquals(1, DriverListUtil.getJdbcUrls(driver2).size());
+        assertEquals(1, DriverListUtil.getJdbcUrls(driver).size());
+        assertEquals(1, DriverListUtil.getJdbcUrls(driver2).size());
+    }
+
+    /**
+     * Reproducer for bug #229250. - Multiple URLs
+     *
+     * @throws MalformedURLException
+     */
+    public void testGetJdbcUrlsMultiple() throws MalformedURLException {
+        JDBCDriver driver = JDBCDriver.create("PB 1", "PB 1", 
"com.pointbase.jdbc.jdbcUniversalDriver", new URL[] {new 
URL("file://demo1")});
+        JDBCDriver driver2 = JDBCDriver.create("PB 2", "PB 2", 
"com.pointbase.jdbc.jdbcUniversalDriver", new URL[] {new 
URL("file://demo1")});
+        assertEquals(3, DriverListUtil.getJdbcUrls(driver).size());
+        assertEquals(3, DriverListUtil.getJdbcUrls(driver2).size());
+        assertEquals(3, DriverListUtil.getJdbcUrls(driver).size());
+        assertEquals(3, DriverListUtil.getJdbcUrls(driver2).size());
+    }
+
     private JdbcUrl getJdbcUrl(String name, String type) throws Exception {
-        List<JdbcUrl> urls = DriverListUtil.getJdbcUrls();
+        Collection<JdbcUrl> urls = DriverListUtil.getJdbcUrls();
         for (JdbcUrl url : urls) {
             if (url.getName().equals(name) &&
                     isEqual(url.getType(), type)) {

[hg] main-silver: #229250: Unittest/reproducer for the bug

Jaroslav Havlin 06/04/2013

Project Features

About this Project

DB was started in November 2009, is owned by Antonin Nebuzelsky, and has 113 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20140418.2d69abc). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close