1
1
/*
2
- * Copyright 2002-2019 the original author or authors.
2
+ * Copyright 2002-2021 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
25
25
26
26
import org .junit .jupiter .api .Test ;
27
27
28
+ import org .springframework .jdbc .support .incrementer .DataFieldMaxValueIncrementer ;
28
29
import org .springframework .jdbc .support .incrementer .HanaSequenceMaxValueIncrementer ;
29
30
import org .springframework .jdbc .support .incrementer .HsqlMaxValueIncrementer ;
30
31
import org .springframework .jdbc .support .incrementer .MySQLMaxValueIncrementer ;
38
39
import static org .mockito .Mockito .verify ;
39
40
40
41
/**
42
+ * Unit tests for {@link DataFieldMaxValueIncrementer} implementations.
43
+ *
41
44
* @author Juergen Hoeller
45
+ * @author Sam Brannen
42
46
* @since 27.02.2004
43
47
*/
44
- public class DataFieldMaxValueIncrementerTests {
48
+ class DataFieldMaxValueIncrementerTests {
45
49
46
50
private final DataSource dataSource = mock (DataSource .class );
47
51
@@ -53,7 +57,7 @@ public class DataFieldMaxValueIncrementerTests {
53
57
54
58
55
59
@ Test
56
- public void testHanaSequenceMaxValueIncrementer () throws SQLException {
60
+ void hanaSequenceMaxValueIncrementer () throws SQLException {
57
61
given (dataSource .getConnection ()).willReturn (connection );
58
62
given (connection .createStatement ()).willReturn (statement );
59
63
given (statement .executeQuery ("select myseq.nextval from dummy" )).willReturn (resultSet );
@@ -75,7 +79,7 @@ public void testHanaSequenceMaxValueIncrementer() throws SQLException {
75
79
}
76
80
77
81
@ Test
78
- public void testHsqlMaxValueIncrementer () throws SQLException {
82
+ void hsqlMaxValueIncrementer () throws SQLException {
79
83
given (dataSource .getConnection ()).willReturn (connection );
80
84
given (connection .createStatement ()).willReturn (statement );
81
85
given (statement .executeQuery ("select max(identity()) from myseq" )).willReturn (resultSet );
@@ -105,7 +109,7 @@ public void testHsqlMaxValueIncrementer() throws SQLException {
105
109
}
106
110
107
111
@ Test
108
- public void testHsqlMaxValueIncrementerWithDeleteSpecificValues () throws SQLException {
112
+ void hsqlMaxValueIncrementerWithDeleteSpecificValues () throws SQLException {
109
113
given (dataSource .getConnection ()).willReturn (connection );
110
114
given (connection .createStatement ()).willReturn (statement );
111
115
given (statement .executeQuery ("select max(identity()) from myseq" )).willReturn (resultSet );
@@ -136,7 +140,7 @@ public void testHsqlMaxValueIncrementerWithDeleteSpecificValues() throws SQLExce
136
140
}
137
141
138
142
@ Test
139
- public void testMySQLMaxValueIncrementer () throws SQLException {
143
+ void mySQLMaxValueIncrementer () throws SQLException {
140
144
given (dataSource .getConnection ()).willReturn (connection );
141
145
given (connection .createStatement ()).willReturn (statement );
142
146
given (statement .executeQuery ("select last_insert_id()" )).willReturn (resultSet );
@@ -156,14 +160,14 @@ public void testMySQLMaxValueIncrementer() throws SQLException {
156
160
assertThat (incrementer .nextStringValue ()).isEqualTo ("3" );
157
161
assertThat (incrementer .nextLongValue ()).isEqualTo (4 );
158
162
159
- verify (statement , times (2 )).executeUpdate ("update myseq set seq = last_insert_id(seq + 2)" );
163
+ verify (statement , times (2 )).executeUpdate ("update myseq set seq = last_insert_id(seq + 2) limit 1 " );
160
164
verify (resultSet , times (2 )).close ();
161
165
verify (statement , times (2 )).close ();
162
166
verify (connection , times (2 )).close ();
163
167
}
164
168
165
169
@ Test
166
- public void testOracleSequenceMaxValueIncrementer () throws SQLException {
170
+ void oracleSequenceMaxValueIncrementer () throws SQLException {
167
171
given (dataSource .getConnection ()).willReturn (connection );
168
172
given (connection .createStatement ()).willReturn (statement );
169
173
given (statement .executeQuery ("select myseq.nextval from dual" )).willReturn (resultSet );
@@ -185,7 +189,7 @@ public void testOracleSequenceMaxValueIncrementer() throws SQLException {
185
189
}
186
190
187
191
@ Test
188
- public void testPostgresSequenceMaxValueIncrementer () throws SQLException {
192
+ void postgresSequenceMaxValueIncrementer () throws SQLException {
189
193
given (dataSource .getConnection ()).willReturn (connection );
190
194
given (connection .createStatement ()).willReturn (statement );
191
195
given (statement .executeQuery ("select nextval('myseq')" )).willReturn (resultSet );
0 commit comments