loadDriver();
String defaultdburl = orgurl + ";create=true";
// Test that we loaded the right driver by making a connection
Driver driver = DriverManager.getDriver(defaultdburl);
int frameworkOffset;
int EMBEDDED_OFFSET = 0;
int DERBYNETCLIENT_OFFSET = 1;
if (usingDerbyNetClient())
frameworkOffset = DERBYNETCLIENT_OFFSET;
else // assume (usingEmbedded())
frameworkOffset = EMBEDDED_OFFSET;
// URLS to check. New urls need to also be added to the acceptsUrl table
String EMBEDDED_URL = "jdbc:derby:";
String INVALID_URL = "jdbc:db2j:";
String hostName = TestConfiguration.getCurrent().getHostName();
int port = TestConfiguration.getCurrent().getPort();
String CLIENT_URL =
"jdbc:derby://"+hostName+":"+port+"/"+dbName+";create=true";
String[] urls = new String[]
{
EMBEDDED_URL,
CLIENT_URL,
INVALID_URL,
};
// Table that shows whether tested urls should return true for
// acceptsURL under the given framework
// The acceptsURLTable uses the frameworkOffset column int he table
// to check for valid results for each framework
boolean[][] acceptsURLTable = new boolean[][]
{
// Framework/url EMBEDDED DERBYNETCLIENT
/* EMBEDDED_URL*/ { true , false },
/* CLIENT_URL */ { false , true },
/* INVALID_URL */ { false , false }
};
for (int u = 0; u < urls.length;u++)
{
String url = urls[u];
boolean expectedAcceptance = acceptsURLTable[u][frameworkOffset];
boolean actualAcceptance = driver.acceptsURL(url);
assertEquals(expectedAcceptance, actualAcceptance);
}
}