@@ -1220,7 +1220,7 @@ public void testQueryBatcherFailures() throws IOException, InterruptedException
1220
1220
}
1221
1221
1222
1222
@ Test
1223
- public void testServerXQueryTransform () throws IOException , ParserConfigurationException , SAXException , TransformerException , InterruptedException , XPathExpressionException
1223
+ public void testServerXQueryTransform () throws InterruptedException , XPathExpressionException
1224
1224
{
1225
1225
System .out .println ("Running testServerXQueryTransform" );
1226
1226
try {
@@ -1272,8 +1272,7 @@ public void testServerXQueryTransform() throws IOException, ParserConfigurationE
1272
1272
batcher .flushAndWait ();
1273
1273
dmManager .stopJob (batcher );
1274
1274
1275
- StringBuffer batchResults = new StringBuffer ();
1276
- StringBuffer batchFailResults = new StringBuffer ();
1275
+ List <String > uris = new ArrayList <>();
1277
1276
1278
1277
// create query def
1279
1278
QueryManager queryMgr = client .newQueryManager ();
@@ -1285,56 +1284,34 @@ public void testServerXQueryTransform() throws IOException, ParserConfigurationE
1285
1284
queryBatcher1 .withBatchSize (5 );
1286
1285
1287
1286
queryBatcher1 .onUrisReady (batch -> {
1288
- for (String str : batch .getItems ()) {
1289
- batchResults .append (str );
1290
- batchResults .append ("|" );
1287
+ for (String item : batch .getItems ()) {
1288
+ uris .add (item );
1291
1289
}
1292
1290
});
1293
- queryBatcher1 .onQueryFailure (throwable -> {
1294
- System .out .println ("Exceptions thrown from callback onQueryFailure" );
1295
- throwable .printStackTrace ();
1296
- batchFailResults .append ("Test has Exceptions" );
1297
- });
1298
1291
dmManager .startJob (queryBatcher1 );
1299
- queryBatcher1 .awaitCompletion (3 , TimeUnit .MINUTES );
1300
- while (!queryBatcher1 .isStopped ()) {
1301
- // Do nothing. Wait for batcher to complete.
1302
- }
1303
-
1304
- if (queryBatcher1 .isStopped ()) {
1305
- // Verify the batch results now.
1306
- String [] res = batchResults .toString ().split ("\\ |" );
1307
- assertEquals (res .length , 20 );
1308
-
1309
- // Get a random URI, since the URIs returned are not ordered. Get the 3rd
1310
- // URI.
1311
- assertTrue ( res [2 ].contains ("foo" ) || res [2 ].contains ("bar" ));
1312
-
1313
- // do a lookup with the first URI using the client to verify transforms
1314
- // are done.
1315
- DOMHandle readHandle = readDocumentUsingDOMHandle (client , res [0 ], "XML" );
1316
- String contents = readHandle .evaluateXPath ("/foo/text()" , String .class );
1317
- String attribute = readHandle .evaluateXPath ("/foo/@Lang" , String .class );
1318
- // Verify that the contents are of xmlStr1 or xmlStr2.
1319
-
1320
- System .out .println ("Contents are : " + contents );
1321
- System .out .println ("Contents are : " + attribute );
1322
- assertTrue ( xmlStr1 .contains (contents ) || xmlStr2 .contains (contents ));
1323
- assertTrue ( attribute .equalsIgnoreCase ("English" ));
1324
- }
1325
- else {
1326
- fail ("testServerXQueryTransform method failed" );
1327
- }
1328
- } catch (Exception e ) {
1329
- e .printStackTrace ();
1330
- fail ("testServerXQueryTransform method failed" );
1292
+ queryBatcher1 .awaitCompletion ();
1293
+
1294
+ // Verify the batch results now.
1295
+ assertEquals (20 , uris .size ());
1296
+
1297
+ // Get a random URI, since the URIs returned are not ordered. Get the 3rd
1298
+ // URI.
1299
+ String thirdUri = uris .get (2 );
1300
+ assertTrue ( thirdUri .contains ("foo" ) || thirdUri .contains ("bar" ), "Unexpected URI: " + thirdUri );
1301
+
1302
+ // do a lookup with the first URI using the client to verify transforms
1303
+ // are done.
1304
+ DOMHandle readHandle = readDocumentUsingDOMHandle (client , uris .get (0 ), "XML" );
1305
+ String contents = readHandle .evaluateXPath ("/foo/text()" , String .class );
1306
+ String attribute = readHandle .evaluateXPath ("/foo/@Lang" , String .class );
1307
+ // Verify that the contents are of xmlStr1 or xmlStr2.
1308
+ System .out .println ("Contents are : " + contents );
1309
+ System .out .println ("Contents are : " + attribute );
1310
+ assertTrue ( xmlStr1 .contains (contents ) || xmlStr2 .contains (contents ));
1311
+ assertTrue ( attribute .equalsIgnoreCase ("English" ));
1331
1312
}
1332
1313
finally {
1333
- try {
1334
- clearDB ();
1335
- } catch (Exception e ) {
1336
- e .printStackTrace ();
1337
- }
1314
+ clearDB ();
1338
1315
}
1339
1316
}
1340
1317
0 commit comments