Skip to content

Commit 03ad61e

Browse files
georgeajitgeorgeajit
georgeajit
authored and
georgeajit
committed
#1168 - Test corrected to have operation flag when default meta data and
doc URI is used
1 parent 54bbbd4 commit 03ad61e

File tree

1 file changed

+22
-15
lines changed
  • marklogic-client-api-functionaltests/src/test/java/com/marklogic/client/datamovement/functionaltests

1 file changed

+22
-15
lines changed

marklogic-client-api-functionaltests/src/test/java/com/marklogic/client/datamovement/functionaltests/WriteHostBatcherTest.java

+22-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2019 MarkLogic Corporation
2+
* Copyright 2014-2020 MarkLogic Corporation
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -246,14 +246,22 @@ private void replenishStream() throws Exception {
246246
// the callback receives the output stream
247247
public void write(OutputStream out) throws IOException {
248248
// acquire the content
249-
InputStream docStreamwrongjson = new FileInputStream(
250-
WriteHostBatcherTest.class.getResource(TEST_DIR_PREFIX + "WrongFormat.json").getPath());
249+
InputStream docStreamwrongjson = null;
250+
try {
251+
docStreamwrongjson = new FileInputStream(
252+
WriteHostBatcherTest.class.getResource(TEST_DIR_PREFIX + "WrongFormat.json").getPath());
251253

252-
// copy content to the output stream
253-
byte[] buf = new byte[1024];
254-
int byteCount = 0;
255-
while ((byteCount = docStreamwrongjson.read(buf)) != -1) {
256-
out.write(buf, 0, byteCount);
254+
// copy content to the output stream
255+
byte[] buf = new byte[1024];
256+
int byteCount = 0;
257+
while ((byteCount = docStreamwrongjson.read(buf)) != -1) {
258+
out.write(buf, 0, byteCount);
259+
}
260+
} catch (Exception e) {
261+
e.printStackTrace();
262+
}
263+
finally {
264+
docStreamwrongjson.close();
257265
}
258266

259267
}
@@ -1434,7 +1442,7 @@ public void run() {
14341442
// TODO Auto-generated catch block
14351443
e.printStackTrace();
14361444
}
1437-
Set threads = Thread.getAllStackTraces().keySet();
1445+
Set<Thread> threads = Thread.getAllStackTraces().keySet();
14381446
Iterator<Thread> iter = threads.iterator();
14391447
while (iter.hasNext()) {
14401448
Thread t = iter.next();
@@ -1519,7 +1527,7 @@ public void run() {
15191527
// TODO Auto-generated catch block
15201528
e.printStackTrace();
15211529
}
1522-
Set threads = Thread.getAllStackTraces().keySet();
1530+
Set<Thread> threads = Thread.getAllStackTraces().keySet();
15231531
Iterator<Thread> iter = threads.iterator();
15241532
while (iter.hasNext()) {
15251533
Thread t = iter.next();
@@ -1611,7 +1619,7 @@ public void run() {
16111619
// TODO Auto-generated catch block
16121620
e.printStackTrace();
16131621
}
1614-
Set threads = Thread.getAllStackTraces().keySet();
1622+
Set<Thread> threads = Thread.getAllStackTraces().keySet();
16151623
Iterator<Thread> iter = threads.iterator();
16161624
while (iter.hasNext()) {
16171625
Thread t = iter.next();
@@ -1762,7 +1770,7 @@ public void run() {
17621770
}
17631771
Iterator<Entry<String, Integer>> it = threadMap.entrySet().iterator();
17641772
while (it.hasNext()) {
1765-
Map.Entry<String, Integer> pair = (Map.Entry) it.next();
1773+
Map.Entry<String, Integer> pair = (Entry<String, Integer>) it.next();
17661774
System.out.println("Thread pool: " + pair.getKey() + " = " + pair.getValue() + " Threads");
17671775
if (pair.getValue() == 20) {
17681776
count.set(true);
@@ -1823,6 +1831,7 @@ public void testNPESuccessCallBack() throws Exception {
18231831
System.out.println("Job writes " + batch.getJobWritesSoFar());
18241832
successCount.getAndAdd(batch.getItems().length);
18251833
String s = null;
1834+
// s.length is called purposefully to set off NEE.
18261835
s.length();
18271836

18281837
}).onBatchFailure((batch, throwable) -> {
@@ -2364,8 +2373,6 @@ public void testNullConfig() throws Exception {
23642373

23652374
final String query1 = "fn:count(fn:doc())";
23662375

2367-
DocumentMetadataHandle meta6 = new DocumentMetadataHandle().withCollections("NoHost").withQuality(0);
2368-
23692376
Assert.assertTrue(dbClient.newServerEval().xquery(query1).eval().next().getNumber().intValue() == 0);
23702377

23712378
WriteBatcher ihb2 = dmManager.newWriteBatcher();
@@ -2910,7 +2917,7 @@ public void testDocumentWriteOperationAdd() throws Exception {
29102917

29112918
metadataHandle.setQuality(23);
29122919
DocumentWriteOperationImpl docWriteOpsImp4 = new DocumentWriteOperationImpl(
2913-
OperationType.DISABLE_METADATA_DEFAULT,
2920+
OperationType.DOCUMENT_WRITE,
29142921
docId[4],
29152922
metadataHandle,
29162923
contHandle5

0 commit comments

Comments
 (0)