- @Test
- public void postOperationsStatusCodes() throws UnsupportedEncodingException {
- controllerContext.setSchemas(schemaContextTestModule);
- mockInvokeRpc(cnSnDataOutput, true);
- String uri = createUri("/operations/", "test-module:rpc-test");
- assertEquals(200, post(uri, MediaType.APPLICATION_XML, xmlDataRpcInput));
-
- mockInvokeRpc(null, true);
- assertEquals(204, post(uri, MediaType.APPLICATION_XML, xmlDataRpcInput));
-
- mockInvokeRpc(null, false);
- assertEquals(500, post(uri, MediaType.APPLICATION_XML, xmlDataRpcInput));
-
- uri = createUri("/operations/", "test-module:rpc-wrongtest");
- assertEquals(404, post(uri, MediaType.APPLICATION_XML, xmlDataRpcInput));
- }
-
- @Test
- public void postConfigOnlyStatusCodes() throws UnsupportedEncodingException {
- controllerContext.setSchemas(schemaContextYangsIetf);
- mockCommitConfigurationDataPostMethod(TransactionStatus.COMMITED);
- String uri = createUri("/config", "");
- assertEquals(204, post(uri, MediaType.APPLICATION_XML, xmlDataAbsolutePath));
-
- mockCommitConfigurationDataPostMethod(null);
- assertEquals(202, post(uri, MediaType.APPLICATION_XML, xmlDataAbsolutePath));
-
- mockCommitConfigurationDataPostMethod(TransactionStatus.FAILED);
- assertEquals(500, post(uri, MediaType.APPLICATION_XML, xmlDataAbsolutePath));
- }
-
- @Test
- public void postConfigStatusCodes() throws UnsupportedEncodingException {
- controllerContext.setSchemas(schemaContextYangsIetf);
- mockCommitConfigurationDataPostMethod(TransactionStatus.COMMITED);
- String uri = createUri("/config/", "ietf-interfaces:interfaces");
- assertEquals(204, post(uri, MediaType.APPLICATION_XML, xmlDataInterfaceAbsolutePath));
-
- mockCommitConfigurationDataPostMethod(null);
- assertEquals(202, post(uri, MediaType.APPLICATION_XML, xmlDataInterfaceAbsolutePath));
-
- mockCommitConfigurationDataPostMethod(TransactionStatus.FAILED);
- assertEquals(500, post(uri, MediaType.APPLICATION_XML, xmlDataInterfaceAbsolutePath));
- }
-
- @Test
- public void postDatastoreStatusCodes() throws UnsupportedEncodingException {
- controllerContext.setSchemas(schemaContextYangsIetf);
- mockCommitConfigurationDataPostMethod(TransactionStatus.COMMITED);
- String uri = createUri("/datastore/", "ietf-interfaces:interfaces");
- assertEquals(204, post(uri, MediaType.APPLICATION_XML, xmlDataInterfaceAbsolutePath));
-
- mockCommitConfigurationDataPostMethod(null);
- assertEquals(202, post(uri, MediaType.APPLICATION_XML, xmlDataInterfaceAbsolutePath));
-
- mockCommitConfigurationDataPostMethod(TransactionStatus.FAILED);
- assertEquals(500, post(uri, MediaType.APPLICATION_XML, xmlDataInterfaceAbsolutePath));