|
14 | 14 | * limitations under the License. |
15 | 15 | */ |
16 | 16 |
|
17 | | -package com.marklogic.client.datamovement.functionaltests; |
| 17 | +package com.marklogic.client.fastfunctest.datamovement; |
18 | 18 |
|
19 | 19 | import static org.junit.jupiter.api.Assertions.assertEquals; |
20 | 20 | import static org.junit.jupiter.api.Assertions.assertTrue; |
|
41 | 41 | import com.marklogic.client.query.QueryManager; |
42 | 42 | import com.marklogic.client.query.StringQueryDefinition; |
43 | 43 |
|
44 | | -/** |
45 | | - * This is a "fast" test but it's also brittle, with testOnBatchFailure failing intermittently. |
46 | | - */ |
47 | 44 | public class ExportListenerTest extends AbstractFunctionalTest { |
48 | 45 |
|
49 | 46 | private static DataMovementManager dmManager = null; |
@@ -426,71 +423,4 @@ public void testPointInTimeQueryNonDeterministicSet() { |
426 | 423 | // Doc count should be zero after both batchers are done. |
427 | 424 | assertEquals(0, dbClient.newServerEval().xquery(query1).eval().next().getNumber().intValue()); |
428 | 425 | } |
429 | | - |
430 | | - /* |
431 | | - * Trigger batch failure by calling incorrect meta data values |
432 | | - */ |
433 | | - |
434 | | - @Test |
435 | | - public void testOnBatchFailure() { |
436 | | - String jsonDoc = "{" + |
437 | | - "\"employees\": [" + |
438 | | - "{ \"firstName\":\"Will\" , \"lastName\":\"Kirkham\" }," + |
439 | | - "{ \"firstName\":\"Hus\" , \"lastName\":\"Wattan\" }," + |
440 | | - "{ \"firstName\":\"Rod\" , \"lastName\":\"Mendez\" }]" + |
441 | | - "}"; |
442 | | - |
443 | | - // Use WriteBatcher to write the files. |
444 | | - WriteBatcher wbatcher = dmManager.newWriteBatcher(); |
445 | | - |
446 | | - wbatcher.withBatchSize(1000); |
447 | | - StringHandle handle = new StringHandle(); |
448 | | - handle.set(jsonDoc); |
449 | | - String uri = null; |
450 | | - |
451 | | - // Insert 100 documents |
452 | | - for (int i = 0; i < 100; i++) { |
453 | | - uri = "lastname" + i + ".json"; |
454 | | - wbatcher.add(uri, handle); |
455 | | - } |
456 | | - wbatcher.flushAndWait(); |
457 | | - |
458 | | - List<String> docExporterList = Collections.synchronizedList(new ArrayList<String>()); |
459 | | - |
460 | | - QueryManager queryMgr = dbClient.newQueryManager(); |
461 | | - StringQueryDefinition querydef = queryMgr.newStringDefinition(); |
462 | | - querydef.setCriteria("Will AND Hus"); |
463 | | - StringBuilder onBatchFailureStr = new StringBuilder(); |
464 | | - |
465 | | - QueryBatcher exportBatcher = dmManager.newQueryBatcher(querydef) |
466 | | - .withBatchSize(50) |
467 | | - .onUrisReady( |
468 | | - new ExportListener() |
469 | | - .withMetadataCategory(DocumentManager.Metadata.METADATAVALUES) |
470 | | - .onDocumentReady(doc -> { |
471 | | - String uriOfDoc = doc.getUri(); |
472 | | - docExporterList.add(uriOfDoc); |
473 | | - } |
474 | | - ) |
475 | | - .onFailure((batch, throwable) -> { |
476 | | - onBatchFailureStr.append("From onBatchFailure QA Exception"); |
477 | | - System.out.println("From onBatchFailure " + throwable.getMessage()); |
478 | | - System.out.println("From onBatchFailure QA Exception"); |
479 | | - } |
480 | | - ) |
481 | | - ) |
482 | | - .onUrisReady(batch -> { |
483 | | - System.out.println("Batch Numer is " + batch.getJobBatchNumber()); |
484 | | - }) |
485 | | - .onQueryFailure(exception -> { |
486 | | - System.out.println("Exceptions thrown from testOnBatchFailure callback onQueryFailure"); |
487 | | - exception.printStackTrace(); |
488 | | - }); |
489 | | - dmManager.startJob(exportBatcher); |
490 | | - |
491 | | - exportBatcher.awaitCompletion(); |
492 | | - |
493 | | - assertTrue(onBatchFailureStr.toString().contains("From onBatchFailure QA Exception"), |
494 | | - "Unexpected exception: " + onBatchFailureStr); |
495 | | - } |
496 | 426 | } |
0 commit comments