this.maxRetriesPerExecute = getNumStatementRetries(info);
/** * Creates an AvaticaConnection. * * <p>Not public; method is called only from the driver or a derived * class.</p> * * @param driver Driver * @param factory Factory for JDBC objects * @param url Server URL * @param info Other connection properties */ protected AvaticaConnection(UnregisteredDriver driver, AvaticaFactory factory, String url, Properties info) { this.id = UUID.randomUUID().toString(); this.handle = new Meta.ConnectionHandle(this.id); this.driver = driver; this.factory = factory; this.url = url; this.info = info; this.meta = driver.createMeta(this); this.metaData = factory.newDatabaseMetaData(this); this.holdability = metaData.getResultSetHoldability(); this.maxRetriesPerExecute = getNumStatementRetries(info); }
this.maxRetriesPerExecute = getNumStatementRetries(info);
@Test public void testNumExecuteRetries() { AvaticaConnection statement = Mockito.mock(AvaticaConnection.class); Mockito.when(statement.getNumStatementRetries(Mockito.any(Properties.class))) .thenCallRealMethod(); // Bad argument should throw an exception try { statement.getNumStatementRetries(null); Assert.fail("Calling getNumStatementRetries with a null object should throw an exception"); } catch (NullPointerException e) { // Pass } Properties props = new Properties(); // Verify the default value Assert.assertEquals(Long.valueOf(AvaticaConnection.NUM_EXECUTE_RETRIES_DEFAULT).longValue(), statement.getNumStatementRetries(props)); // Set a non-default value props.setProperty(AvaticaConnection.NUM_EXECUTE_RETRIES_KEY, "10"); // Verify that we observe that value Assert.assertEquals(10, statement.getNumStatementRetries(props)); }
@Test public void testNumExecuteRetries() { AvaticaConnection connection = Mockito.mock(AvaticaConnection.class, Mockito.CALLS_REAL_METHODS); // Bad argument should throw an exception try { connection.getNumStatementRetries(null); Assert.fail("Calling getNumStatementRetries with a null object should throw an exception"); } catch (NullPointerException e) { // Pass } Properties props = new Properties(); // Verify the default value Assert.assertEquals(Long.parseLong(AvaticaConnection.NUM_EXECUTE_RETRIES_DEFAULT), connection.getNumStatementRetries(props)); // Set a non-default value props.setProperty(AvaticaConnection.NUM_EXECUTE_RETRIES_KEY, "10"); // Verify that we observe that value Assert.assertEquals(10, connection.getNumStatementRetries(props)); }
@Test public void testNumExecuteRetries() { AvaticaConnection connection = Mockito.mock(AvaticaConnection.class, Mockito.CALLS_REAL_METHODS); // Bad argument should throw an exception try { connection.getNumStatementRetries(null); Assert.fail("Calling getNumStatementRetries with a null object should throw an exception"); } catch (NullPointerException e) { // Pass } Properties props = new Properties(); // Verify the default value Assert.assertEquals(Long.parseLong(AvaticaConnection.NUM_EXECUTE_RETRIES_DEFAULT), connection.getNumStatementRetries(props)); // Set a non-default value props.setProperty(AvaticaConnection.NUM_EXECUTE_RETRIES_KEY, "10"); // Verify that we observe that value Assert.assertEquals(10, connection.getNumStatementRetries(props)); }