2626import java .sql .ResultSet ;
2727import java .sql .Statement ;
2828import java .util .List ;
29- import java .util .stream .Stream ;
3029import org .apache .hop .core .BlockingRowSet ;
3130import org .apache .hop .core .HopClientEnvironment ;
3231import org .apache .hop .core .HopEnvironment ;
5150import org .junit .jupiter .api .AfterAll ;
5251import org .junit .jupiter .api .BeforeAll ;
5352import org .junit .jupiter .api .BeforeEach ;
53+ import org .junit .jupiter .api .Test ;
5454import org .junit .jupiter .api .condition .DisabledIfSystemProperty ;
55- import org .junit .jupiter .params .ParameterizedTest ;
56- import org .junit .jupiter .params .provider .Arguments ;
57- import org .junit .jupiter .params .provider .MethodSource ;
5855import org .mockito .Mockito ;
5956import org .testcontainers .cratedb .CrateDBContainer ;
60- import org .testcontainers .junit .jupiter .Container ;
6157import org .testcontainers .junit .jupiter .Testcontainers ;
6258
6359@ Testcontainers (disabledWithoutDocker = true )
6460class CrateDBBulkImportTest {
6561
66- @ Container public static CrateDBContainer crateDBContainer = new CrateDBContainer ( "crate " );
67-
62+ private static final String SKIP_TEST_CONTAINERS = System . getProperty ( "SkipTestContainers " );
63+ public static CrateDBContainer crateDBContainer ;
6864 private static Connection connection ;
6965
7066 @ BeforeAll
7167 static void init () throws Exception {
72- String skipTestContainers = System .getProperty ("SkipTestContainers" );
73- if (skipTestContainers == null ) {
68+ if (SKIP_TEST_CONTAINERS == null ) {
69+ crateDBContainer = new CrateDBContainer ("crate" );
70+ crateDBContainer .start ();
7471 HopClientEnvironment .init (
7572 List .of (
7673 DatabasePluginType .getInstance (),
@@ -99,9 +96,9 @@ static void init() throws Exception {
9996
10097 @ AfterAll
10198 static void shutdown () throws Exception {
102- String skipTestContainers = System .getProperty ("SkipTestContainers" );
103- if (skipTestContainers == null ) {
99+ if (SKIP_TEST_CONTAINERS == null ) {
104100 executeUpdate ("DROP TABLE doc.person;" );
101+ crateDBContainer .stop ();
105102 }
106103 }
107104
@@ -112,39 +109,160 @@ private static int executeUpdate(String query) throws Exception {
112109 }
113110
114111 private static ResultSet executeQuery (String query ) throws Exception {
115- Statement statement = connection .createStatement ();
116- return statement .executeQuery (query );
117- }
118-
119- private static Stream <Arguments > getBatchSize () {
120- return Stream .of (
121- Arguments .of (1 ),
122- Arguments .of (2 ),
123- Arguments .of (3 ),
124- Arguments .of (4 ),
125- Arguments .of (5 ),
126- Arguments .of (6 ),
127- Arguments .of (7 ),
128- Arguments .of (8 ),
129- Arguments .of (9 ),
130- Arguments .of (10 ),
131- Arguments .of (20 ),
132- Arguments .of (30 ),
133- Arguments .of (40 ),
134- Arguments .of (50 ));
112+ if (SKIP_TEST_CONTAINERS == null ) {
113+ Statement statement = connection .createStatement ();
114+ return statement .executeQuery (query );
115+ }
116+ return null ;
117+ }
118+
119+ @ Test
120+ @ DisabledIfSystemProperty (named = "SkipTestContainers" , matches = "true" )
121+ void testBatchSize1 () {
122+ try {
123+ given_batch_size__when_http_insert__should_persist_all_items (1 );
124+ } catch (Exception e ) {
125+ e .printStackTrace ();
126+ }
127+ }
128+
129+ @ Test
130+ @ DisabledIfSystemProperty (named = "SkipTestContainers" , matches = "true" )
131+ void testBatchSize2 () {
132+ try {
133+ given_batch_size__when_http_insert__should_persist_all_items (2 );
134+ } catch (Exception e ) {
135+ e .printStackTrace ();
136+ }
137+ }
138+
139+ @ Test
140+ @ DisabledIfSystemProperty (named = "SkipTestContainers" , matches = "true" )
141+ void testBatchSize3 () {
142+ try {
143+ given_batch_size__when_http_insert__should_persist_all_items (3 );
144+ } catch (Exception e ) {
145+ e .printStackTrace ();
146+ }
147+ }
148+
149+ @ Test
150+ @ DisabledIfSystemProperty (named = "SkipTestContainers" , matches = "true" )
151+ void testBatchSize4 () {
152+ try {
153+ given_batch_size__when_http_insert__should_persist_all_items (4 );
154+ } catch (Exception e ) {
155+ e .printStackTrace ();
156+ }
157+ }
158+
159+ @ Test
160+ @ DisabledIfSystemProperty (named = "SkipTestContainers" , matches = "true" )
161+ void testBatchSize5 () {
162+ try {
163+ given_batch_size__when_http_insert__should_persist_all_items (5 );
164+ } catch (Exception e ) {
165+ e .printStackTrace ();
166+ }
167+ }
168+
169+ @ Test
170+ @ DisabledIfSystemProperty (named = "SkipTestContainers" , matches = "true" )
171+ void testBatchSize6 () {
172+ try {
173+ given_batch_size__when_http_insert__should_persist_all_items (6 );
174+ } catch (Exception e ) {
175+ e .printStackTrace ();
176+ }
177+ }
178+
179+ @ Test
180+ @ DisabledIfSystemProperty (named = "SkipTestContainers" , matches = "true" )
181+ void testBatchSize7 () {
182+ try {
183+ given_batch_size__when_http_insert__should_persist_all_items (7 );
184+ } catch (Exception e ) {
185+ e .printStackTrace ();
186+ }
187+ }
188+
189+ @ Test
190+ @ DisabledIfSystemProperty (named = "SkipTestContainers" , matches = "true" )
191+ void testBatchSize8 () {
192+ try {
193+ given_batch_size__when_http_insert__should_persist_all_items (8 );
194+ } catch (Exception e ) {
195+ e .printStackTrace ();
196+ }
197+ }
198+
199+ @ Test
200+ @ DisabledIfSystemProperty (named = "SkipTestContainers" , matches = "true" )
201+ void testBatchSize9 () {
202+ try {
203+ given_batch_size__when_http_insert__should_persist_all_items (9 );
204+ } catch (Exception e ) {
205+ e .printStackTrace ();
206+ }
207+ }
208+
209+ @ Test
210+ @ DisabledIfSystemProperty (named = "SkipTestContainers" , matches = "true" )
211+ void testBatchSize10 () {
212+ try {
213+ given_batch_size__when_http_insert__should_persist_all_items (10 );
214+ } catch (Exception e ) {
215+ e .printStackTrace ();
216+ }
217+ }
218+
219+ @ Test
220+ @ DisabledIfSystemProperty (named = "SkipTestContainers" , matches = "true" )
221+ void testBatchSize20 () {
222+ try {
223+ given_batch_size__when_http_insert__should_persist_all_items (20 );
224+ } catch (Exception e ) {
225+ e .printStackTrace ();
226+ }
227+ }
228+
229+ @ Test
230+ @ DisabledIfSystemProperty (named = "SkipTestContainers" , matches = "true" )
231+ void testBatchSize30 () {
232+ try {
233+ given_batch_size__when_http_insert__should_persist_all_items (30 );
234+ } catch (Exception e ) {
235+ e .printStackTrace ();
236+ }
237+ }
238+
239+ @ Test
240+ @ DisabledIfSystemProperty (named = "SkipTestContainers" , matches = "true" )
241+ void testBatchSize40 () {
242+ try {
243+ given_batch_size__when_http_insert__should_persist_all_items (40 );
244+ } catch (Exception e ) {
245+ e .printStackTrace ();
246+ }
247+ }
248+
249+ @ Test
250+ @ DisabledIfSystemProperty (named = "SkipTestContainers" , matches = "true" )
251+ void testBatchSize50 () {
252+ try {
253+ given_batch_size__when_http_insert__should_persist_all_items (50 );
254+ } catch (Exception e ) {
255+ e .printStackTrace ();
256+ }
135257 }
136258
137259 @ BeforeEach
138260 void setup () throws Exception {
139- String skipTestContainers = System .getProperty ("SkipTestContainers" );
140- if (skipTestContainers == null ) {
261+ if (SKIP_TEST_CONTAINERS == null ) {
141262 executeUpdate ("DELETE FROM doc.person" );
142263 }
143264 }
144265
145- @ ParameterizedTest
146- @ MethodSource ("getBatchSize" )
147- @ DisabledIfSystemProperty (named = "SkipTestContainers" , matches = "true" )
148266 void given_batch_size__when_http_insert__should_persist_all_items (Integer batchSize )
149267 throws Exception {
150268 Mockito .mock (Pipeline .class );
0 commit comments