### Question:
PropertiesAdminService extends RegistryAbstractAdmin implements
        IPropertiesAdminService<PropertiesBean,RetentionBean> { public void setProperty(String path, String name, String value) throws RegistryException { if(name != null && name.startsWith("registry.")) { throw new RegistryException("Property cannot start with the \"registry.\" prefix. " + "Property name " + name + ". Resource path = " + path); } UserRegistry registry = (UserRegistry) getRootRegistry(); if (RegistryUtils.isRegistryReadOnly(registry.getRegistryContext())) { return; } Resource resource = registry.get(path); if(resource.getProperties().keySet().contains(name)) { throw new RegistryException("Cannot duplicate property name. Please choose a different name. " + "Property name " + name + ". Resource path = " + path); } resource.addProperty(name, value); registry.put(resource.getPath(), resource); resource.discard(); }  PropertiesBean getProperties(String path, String viewProps); void setProperty(String path, String name, String value); void updateProperty(String path, String name, String value, String oldName); void removeProperty(String path, String name); boolean setRetentionProperties(String path, RetentionBean bean); RetentionBean getRetentionProperties(String path);  }### Answer:
@Test(expected = RegistryException.class) public void testSetPropertyRegistryProperty() throws Exception { PropertiesAdminService adminService = new PropertiesAdminService(); adminService.setProperty(resourcePath, "registry.mount.path", "_system_governance"); }
@Test public void testSetProperty() throws RegistryException { System.setProperty("carbon.repo.write.mode", "true"); PropertiesAdminService adminService = new PropertiesAdminService(); adminService.setProperty(resourcePath, "mount.path", "_system_governance"); PropertiesBean propertiesBean = adminService.getProperties(resourcePath, "true"); assertArrayEquals(new String[]{}, propertiesBean.getLifecycleProperties()); assertEquals(1, propertiesBean.getProperties().length); assertArrayEquals(new String[]{"mount.path"}, propertiesBean.getSysProperties()); assertArrayEquals(new String[]{}, propertiesBean.getValidationProperties()); System.clearProperty("carbon.repo.write.mode"); }
@Test(expected = RegistryException.class) public void testSetDuplicateProperty() throws RegistryException { System.setProperty("carbon.repo.write.mode", "true"); resource.setProperty("mount.path", "_system_config"); PropertiesAdminService adminService = new PropertiesAdminService(); adminService.setProperty(resourcePath, "mount.path", "_system_governance"); System.clearProperty("carbon.repo.write.mode"); }