This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 229250
Collapse All | Expand All

(-)db/test/unit/src/org/netbeans/modules/db/util/DriverListUtilTest.java (-6 / +36 lines)
Lines 43-53 Link Here
43
package org.netbeans.modules.db.util;
43
package org.netbeans.modules.db.util;
44
44
45
import java.net.MalformedURLException;
45
import java.net.MalformedURLException;
46
import java.net.URL;
46
import java.util.ArrayList;
47
import java.util.ArrayList;
48
import java.util.Collection;
47
import java.util.HashMap;
49
import java.util.HashMap;
48
import java.util.List;
50
import java.util.List;
49
import java.util.Map;
51
import java.util.Map;
52
import static junit.framework.Assert.assertEquals;
50
import junit.framework.TestCase;
53
import junit.framework.TestCase;
54
import org.netbeans.api.db.explorer.JDBCDriver;
51
import org.openide.util.NbBundle;
55
import org.openide.util.NbBundle;
52
56
53
/**
57
/**
Lines 66-76 Link Here
66
    private static final String DSN = "mydsn";
70
    private static final String DSN = "mydsn";
67
    private static final String TNSNAME = "mytns";
71
    private static final String TNSNAME = "mytns";
68
    
72
    
69
    private static final HashMap<String, String> ALLPROPS = 
73
    private static final HashMap<String, String> ALLPROPS = new HashMap<>();
70
            new HashMap<String, String>();
71
    
74
    
72
    private static final ArrayList<String> STD_SUPPORTED_PROPS =
75
    private static final ArrayList<String> STD_SUPPORTED_PROPS = new ArrayList<>();
73
            new ArrayList<String>();
74
    
76
    
75
    static {
77
    static {
76
        ALLPROPS.put(JdbcUrl.TOKEN_HOST, HOST);
78
        ALLPROPS.put(JdbcUrl.TOKEN_HOST, HOST);
Lines 95-101 Link Here
95
    }
97
    }
96
    
98
    
97
    public void testNonParsedJdbcUrls() throws Exception {
99
    public void testNonParsedJdbcUrls() throws Exception {
98
        List<JdbcUrl> urls = DriverListUtil.getJdbcUrls();
100
        Collection<JdbcUrl> urls = DriverListUtil.getJdbcUrls();
99
        for ( JdbcUrl url : urls ) {
101
        for ( JdbcUrl url : urls ) {
100
            if (! url.isParseUrl()) {
102
            if (! url.isParseUrl()) {
101
                testNonParsedUrl(url);
103
                testNonParsedUrl(url);
Lines 103-110 Link Here
103
        }
105
        }
104
    }
106
    }
105
    
107
    
108
    /**
109
     * Reproducer for bug #229250. - Single URL
110
     * 
111
     * @throws MalformedURLException 
112
     */
113
    public void testGetJdbcUrls() throws MalformedURLException {
114
        JDBCDriver driver = JDBCDriver.create("Mysql 1", "Mysql 1", "com.mysql.jdbc.Driver", new URL[] {new URL("file://demo1")});
115
        JDBCDriver driver2 = JDBCDriver.create("Mysql 2", "Mysql 2", "com.mysql.jdbc.Driver", new URL[] {new URL("file://demo1")});
116
        assertEquals(1, DriverListUtil.getJdbcUrls(driver).size());
117
        assertEquals(1, DriverListUtil.getJdbcUrls(driver2).size());
118
        assertEquals(1, DriverListUtil.getJdbcUrls(driver).size());
119
        assertEquals(1, DriverListUtil.getJdbcUrls(driver2).size());
120
    }
121
122
    /**
123
     * Reproducer for bug #229250. - Multiple URLs
124
     * 
125
     * @throws MalformedURLException 
126
     */
127
    public void testGetJdbcUrlsMultiple() throws MalformedURLException {
128
        JDBCDriver driver = JDBCDriver.create("PB 1", "PB 1", "com.pointbase.jdbc.jdbcUniversalDriver", new URL[] {new URL("file://demo1")});
129
        JDBCDriver driver2 = JDBCDriver.create("PB 2", "PB 2", "com.pointbase.jdbc.jdbcUniversalDriver", new URL[] {new URL("file://demo1")});
130
        assertEquals(3, DriverListUtil.getJdbcUrls(driver).size());
131
        assertEquals(3, DriverListUtil.getJdbcUrls(driver2).size());
132
        assertEquals(3, DriverListUtil.getJdbcUrls(driver).size());
133
        assertEquals(3, DriverListUtil.getJdbcUrls(driver2).size());
134
    }
135
    
106
    private JdbcUrl getJdbcUrl(String name, String type) throws Exception {
136
    private JdbcUrl getJdbcUrl(String name, String type) throws Exception {
107
        List<JdbcUrl> urls = DriverListUtil.getJdbcUrls();
137
        Collection<JdbcUrl> urls = DriverListUtil.getJdbcUrls();
108
        for (JdbcUrl url : urls) {
138
        for (JdbcUrl url : urls) {
109
            if (url.getName().equals(name) &&
139
            if (url.getName().equals(name) &&
110
                    isEqual(url.getType(), type)) {
140
                    isEqual(url.getType(), type)) {

Return to bug 229250