private <T extends CloseTracked<T>> void printRegistryOpenTransactions(
CloseTrackedRegistry<T> registry, PrintStream ps, String indent) {
- Set<CloseTrackedRegistryReportEntry<T>> entries = registry.getAllUnique();
+ Set<CloseTrackedRegistryReportEntry<T>> unsorted = registry.getAllUnique();
+
+ List<CloseTrackedRegistryReportEntry<T>> entries = new ArrayList<>(unsorted);
+ entries.sort((o1, o2) -> Long.compare(o2.getNumberAddedNotRemoved(), o1.getNumberAddedNotRemoved()));
+
if (!entries.isEmpty()) {
ps.println(indent + registry.getAnchor() + " : " + registry.getCreateDescription());
}
BindingNormalizedNodeSerializer codec = mock(BindingNormalizedNodeSerializer.class);
TracingBroker tracingBroker = new TracingBroker(domDataBroker, config, codec);
- DOMDataReadWriteTransaction tx = tracingBroker.newReadWriteTransaction();
+ for (int i = 0; i < 3; i++) {
+ DOMDataReadWriteTransaction tx = tracingBroker.newReadWriteTransaction();
+ }
+ DOMDataReadWriteTransaction anotherTx = tracingBroker.newReadWriteTransaction();
+
DOMTransactionChain txChain = tracingBroker.createTransactionChain(null);
DOMDataReadWriteTransaction txFromChain = txChain.newReadWriteTransaction();
String output = new String(baos.toByteArray(), UTF_8);
assertThat(printReturnValue).isTrue();
- // Assert expections about stack trace
+ // Assert expectations about stack trace
assertThat(output).contains("testPrintOpenTransactions(TracingBrokerTest.java");
assertThat(output).doesNotContain(TracingBroker.class.getName());
previousLine = line;
}
+ // assert that the sorting works - the x3 is shown before the x1
+ assertThat(output).contains(" DataBroker : newReadWriteTransaction()\n 3x");
+
// We don't do any verify/times on the mocks,
// because the main point of the test is just to verify that
// printOpenTransactions runs through without any exceptions