+
+ @Test
+ public void testExistsForExistingData() throws Exception {
+
+ DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
+ assertNotNull( writeTx );
+
+ ContainerNode containerNode = ImmutableContainerNodeBuilder.create()
+ .withNodeIdentifier( new NodeIdentifier( TestModel.TEST_QNAME ) )
+ .addChild( ImmutableNodes.mapNodeBuilder( TestModel.OUTER_LIST_QNAME )
+ .addChild( ImmutableNodes.mapEntry( TestModel.OUTER_LIST_QNAME,
+ TestModel.ID_QNAME, 1 ) ).build() ).build();
+
+ writeTx.merge( TestModel.TEST_PATH, containerNode );
+
+ CheckedFuture<Boolean, ReadFailedException> exists =
+ writeTx.exists(TestModel.TEST_PATH);
+
+ assertEquals(true, exists.checkedGet());
+
+ DOMStoreThreePhaseCommitCohort ready = writeTx.ready();
+
+ ready.preCommit().get();
+
+ ready.commit().get();
+
+ DOMStoreReadTransaction readTx = domStore.newReadOnlyTransaction();
+ assertNotNull( readTx );
+
+ exists =
+ readTx.exists(TestModel.TEST_PATH);
+
+ assertEquals(true, exists.checkedGet());
+ }
+
+ @Test
+ public void testExistsForNonExistingData() throws Exception {
+
+ DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
+ assertNotNull( writeTx );
+
+ CheckedFuture<Boolean, ReadFailedException> exists =
+ writeTx.exists(TestModel.TEST_PATH);
+
+ assertEquals(false, exists.checkedGet());
+
+ DOMStoreReadTransaction readTx = domStore.newReadOnlyTransaction();
+ assertNotNull( readTx );
+
+ exists =
+ readTx.exists(TestModel.TEST_PATH);
+
+ assertEquals(false, exists.checkedGet());
+ }
+
+ @Test(expected=ReadFailedException.class)
+ public void testExistsThrowsReadFailedException() throws Exception {
+
+ DOMStoreReadTransaction readTx = domStore.newReadOnlyTransaction();
+ assertNotNull( readTx );
+
+ readTx.close();
+
+ readTx.exists(TestModel.TEST_PATH).checkedGet();
+ }
+
+
+