- String uri = createUri("/config/", "ietf-interfaces:interfaces/interface/0/yang-ext:mount/test-module:cont");
- Response response = target(uri).request(Draft02.MediaTypes.DATA + XML).put(entity);
- assertEquals(200, response.getStatus());
-
- uri = createUri("/config/", "ietf-interfaces:interfaces/yang-ext:mount/test-module:cont");
- response = target(uri).request(Draft02.MediaTypes.DATA + XML).put(entity);
- assertEquals(200, response.getStatus());
+ String uri = "/config/ietf-interfaces:interfaces/yang-ext:mount";
+ assertEquals(200, put(uri, MediaType.APPLICATION_XML, xmlData3));
+ }
+
+ @Test
+ public void putWithOptimisticLockFailedException() throws UnsupportedEncodingException {
+
+ String uri = "/config/ietf-interfaces:interfaces/interface/eth0";
+
+ doThrow(OptimisticLockFailedException.class).
+ when(brokerFacade).commitConfigurationDataPut(
+ any(YangInstanceIdentifier.class), any(NormalizedNode.class));
+
+ assertEquals(500, put(uri, MediaType.APPLICATION_XML, xmlData));
+
+ doThrow(OptimisticLockFailedException.class).doReturn(mock(CheckedFuture.class)).
+ when(brokerFacade).commitConfigurationDataPut(
+ any(YangInstanceIdentifier.class), any(NormalizedNode.class));
+
+ assertEquals(200, put(uri, MediaType.APPLICATION_XML, xmlData));
+ }
+
+ @Test
+ public void putWithTransactionCommitFailedException() throws UnsupportedEncodingException {
+
+ String uri = "/config/ietf-interfaces:interfaces/interface/eth0";
+
+ doThrow(TransactionCommitFailedException.class).
+ when(brokerFacade).commitConfigurationDataPut(
+ any(YangInstanceIdentifier.class), any(NormalizedNode.class));
+
+ assertEquals(500, put(uri, MediaType.APPLICATION_XML, xmlData));