Polish contribution

See gh-29379
This commit is contained in:
Sam Brannen 2022-11-01 11:41:41 +01:00
parent 39f24f0244
commit 210019cad1
2 changed files with 26 additions and 26 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2022 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -19,11 +19,11 @@ package org.springframework.jdbc.support.incrementer;
import javax.sql.DataSource;
/**
* {@link DataFieldMaxValueIncrementer} that retrieves the next value
* of a given MariaDB sequence.
* {@link DataFieldMaxValueIncrementer} that retrieves the next value of a given
* MariaDB sequence.
*
* @author Mahmoud Ben Hassine
* @since 6.0.0
* @since 6.0
*/
public class MariaDBSequenceMaxValueIncrementer extends AbstractSequenceMaxValueIncrementer {

View File

@ -168,6 +168,28 @@ class DataFieldMaxValueIncrementerTests {
verify(connection, times(2)).close();
}
@Test
void mariaDBSequenceMaxValueIncrementer() throws SQLException {
given(dataSource.getConnection()).willReturn(connection);
given(connection.createStatement()).willReturn(statement);
given(statement.executeQuery("select next value for myseq")).willReturn(resultSet);
given(resultSet.next()).willReturn(true);
given(resultSet.getLong(1)).willReturn(10L, 12L);
MariaDBSequenceMaxValueIncrementer incrementer = new MariaDBSequenceMaxValueIncrementer();
incrementer.setDataSource(dataSource);
incrementer.setIncrementerName("myseq");
incrementer.setPaddingLength(5);
incrementer.afterPropertiesSet();
assertThat(incrementer.nextStringValue()).isEqualTo("00010");
assertThat(incrementer.nextIntValue()).isEqualTo(12);
verify(resultSet, times(2)).close();
verify(statement, times(2)).close();
verify(connection, times(2)).close();
}
@Test
void oracleSequenceMaxValueIncrementer() throws SQLException {
given(dataSource.getConnection()).willReturn(connection);
@ -212,26 +234,4 @@ class DataFieldMaxValueIncrementerTests {
verify(connection, times(2)).close();
}
@Test
void mariaDBSequenceMaxValueIncrementer() throws SQLException {
given(dataSource.getConnection()).willReturn(connection);
given(connection.createStatement()).willReturn(statement);
given(statement.executeQuery("select next value for myseq")).willReturn(resultSet);
given(resultSet.next()).willReturn(true);
given(resultSet.getLong(1)).willReturn(10L, 12L);
MariaDBSequenceMaxValueIncrementer incrementer = new MariaDBSequenceMaxValueIncrementer();
incrementer.setDataSource(dataSource);
incrementer.setIncrementerName("myseq");
incrementer.setPaddingLength(5);
incrementer.afterPropertiesSet();
assertThat(incrementer.nextStringValue()).isEqualTo("00010");
assertThat(incrementer.nextIntValue()).isEqualTo(12);
verify(resultSet, times(2)).close();
verify(statement, times(2)).close();
verify(connection, times(2)).close();
}
}