/** * Failure test for method <code>createConnection</code>. * * <p>Verifies taht the <code>PersistenceException</code> will be thrown if fails to create the * connection. */ public void testCreateConnectionFailure() { try { Helper.createConnection(factory, "nosuchname"); fail("PersistenceException is expected."); } catch (PersistenceException pe) { // success } }
/** * Accuracy test for method <code>createConnection</code>. * * <p>Verifies that the <code>Connection</code> could be returned if the connection name is not * provided. * * @throws Exception if there is any problem. */ public void testCreateConnectionWithNullConnectionName() throws Exception { Connection conn = null; try { conn = Helper.createConnection(factory, null); assertNotNull("Fails to create connection.", conn); } finally { Helper.closeConnection(conn); } }