@@ -0,0 +1,2525 @@
+/*%0A *    GeoTools - The Open Source Java GIS Toolkit%0A *    http://geotools.org%0A *%0A *    (C) 2016, Open Source Geospatial Foundation (OSGeo)%0A *%0A *    This library is free software; you can redistribute it and/or%0A *    modify it under the terms of the GNU Lesser General Public%0A *    License as published by the Free Software Foundation;%0A *    version 2.1 of the License.%0A *%0A *    This library is distributed in the hope that it will be useful,%0A *    but WITHOUT ANY WARRANTY; without even the implied warranty of%0A *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU%0A *    Lesser General Public License for more details.%0A */%0Apackage org.geotools.data.sqlserver.jdts;%0A%0Aimport java.io.IOException;%0Aimport java.util.Properties;%0Aimport static junit.framework.TestCase.assertNotNull;%0Aimport static junit.framework.TestCase.fail;%0Aimport org.geotools.data.DataStoreFinder;%0Aimport org.geotools.jdbc.JDBCDataStore;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0Apublic class SQLServerJTDSJNDITest %7B%0A%0A    private final Properties jndiProps = new Properties();%0A%0A    private static final String JNDINAME = %22java:comp/env/jdbc/geotools%22;%0A%0A    @Before%0A    public void setUp() %7B%0A        jndiProps.put(%22jndiReferenceName%22, JNDINAME);%0A        jndiProps.put(%22schema%22, %22dbo%22);%0A    %7D%0A%0A    /**%0A     * This test should fail with an with an IOException because there is%0A     * actually no such JNDI to connect to, however the datastore is%0A     * %7B@code null%7D so that never happens...%0A     *%0A     * @throws IOException%0A     */%0A    @Test(expected = IOException.class)%0A    public void testCanGetJTDSdataStore() throws IOException %7B%0A        jndiProps.put(%22dbtype%22, %22jtds-sqlserver%22);%0A%0A        JDBCDataStore dataStore = (JDBCDataStore) DataStoreFinder.getDataStore(jndiProps);%0A        assertNotNull(%22The datastore should not be 'null'%22, dataStore);%0A        fail(%22Expected exception was not thrown%22);%0A    %7D%0A%0A    /**%0A     * This test will fail with an IOException because there is actually no such%0A     * JNDI to connect to, but the factory lookup will have succeeded before%0A     * throwing.%0A     *%0A     * @throws IOException%0A     */%0A    @Test(expected = IOException.class)%0A    public void testCanGetMSdataStore() throws IOException %7B%0A        jndiProps.put(%22dbtype%22, %22sqlserver%22);%0A%0A        // this will fail with the message: %22Cannot find JNDI data source: java:comp/env/jdbc/geotools%22%0A        JDBCDataStore dataStore = (JDBCDataStore) DataStoreFinder.getDataStore(jndiProps);%0A        fail(%22Expected exception was not thrown%22);%0A    %7D%0A%7D%0A

add a testcase to illustrate jDTS jndi failure