Search in sources :

Example 1 with StubDriver

use of util.StubDriver in project jdk8u_jdk by JetBrains.

the class DriverManagerTests method test13.

/**
     * Validate that SQLException is thrown when the URL is not valid for any of
     * the registered drivers
     */
@Test(expectedExceptions = SQLException.class)
public void test13() throws Exception {
    DriverManager.registerDriver(new StubDriver());
    DriverManager.getDriver(InvalidURL);
}
Also used : StubDriver(util.StubDriver) Test(org.testng.annotations.Test)

Example 2 with StubDriver

use of util.StubDriver in project jdk8u_jdk by JetBrains.

the class DriverManagerTests method test14.

/**
     * Validate that a Connection object is returned when a valid URL is
     * specified to getConnection
     *
     */
@Test
public void test14() throws Exception {
    DriverManager.registerDriver(new StubDriver());
    assertTrue(DriverManager.getConnection(StubDriverURL) != null);
    assertTrue(DriverManager.getConnection(StubDriverURL, "LuckyDog", "tennisanyone") != null);
    Properties props = new Properties();
    props.put("user", "LuckyDog");
    props.put("password", "tennisanyone");
    assertTrue(DriverManager.getConnection(StubDriverURL, props) != null);
}
Also used : StubDriver(util.StubDriver) Properties(java.util.Properties) Test(org.testng.annotations.Test)

Example 3 with StubDriver

use of util.StubDriver in project jdk8u_jdk by JetBrains.

the class DriverManagerTests method test15.

/**
     * Register a driver and make sure you find it via its URL. Deregister the
     * driver and validate it is not longer registered
     *
     * @throws Exception
     */
@Test()
public void test15() throws Exception {
    DriverManager.registerDriver(new StubDriver());
    Driver d = DriverManager.getDriver(StubDriverURL);
    assertTrue(d != null);
    assertTrue(isDriverRegistered(d));
    DriverManager.deregisterDriver(d);
    assertFalse(isDriverRegistered(d));
}
Also used : StubDriver(util.StubDriver) StubDriver(util.StubDriver) Driver(java.sql.Driver) Test(org.testng.annotations.Test)

Example 4 with StubDriver

use of util.StubDriver in project jdk8u_jdk by JetBrains.

the class DriverManagerPermissionsTests method test8.

/*
     * Validate that deregisterDriver succeeds if
     * SQLPermission("deregisterDriver") has been granted
     */
@Test
public void test8() throws SQLException {
    setPolicy(new TestPolicy("deregisterDriver"));
    DriverManager.deregisterDriver(new StubDriver());
}
Also used : TestPolicy(util.TestPolicy) StubDriver(util.StubDriver) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 5 with StubDriver

use of util.StubDriver in project jdk8u_jdk by JetBrains.

the class DriverManagerPermissionsTests method test9.

/*
     * Validate that deregisterDriver succeeds if AllPermissions has been
     * granted
     */
@Test
public void test9() throws SQLException {
    setPolicy(new TestPolicy("all"));
    DriverManager.deregisterDriver(new StubDriver());
}
Also used : TestPolicy(util.TestPolicy) StubDriver(util.StubDriver) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Aggregations

Test (org.testng.annotations.Test)7 StubDriver (util.StubDriver)7 BaseTest (util.BaseTest)3 TestPolicy (util.TestPolicy)3 Driver (java.sql.Driver)1 Properties (java.util.Properties)1