public String getProperty(String name) { String value = subsystem.getProperty(name); if (value == null) { value = globalProperties.getProperty(name); if (value == null) { name = alias(name, JOD_CONVERTER, OPEN_OFFICE); value = globalProperties.getProperty(name); } } return value; }
/** * Mock up the responses from the subsystem so that it returns all the supplied * property names and values. * @param subsystem to mock the return values * @param namesAndValues a sequence of property names and values. * @throws IllegalStateException if there is not a value for every property */ public static void mockProperties(ChildApplicationContextFactory subsystem, String... namesAndValues) { if (namesAndValues.length % 2 != 0) { // Not using IllegalArgumentException as this is thrown by classes under test throw new java.lang.IllegalStateException("There should be a value for every property"); } final Set<String> propertyNames = new TreeSet<String>(); for (int i=0; i < namesAndValues.length; i+=2) { propertyNames.add(namesAndValues[i]); when(subsystem.getProperty(namesAndValues[i])).thenReturn(namesAndValues[i+1]); } when(subsystem.getPropertyNames()).thenReturn(propertyNames); }
public String getProperty(String name) { String value = subsystem.getProperty(name); if (value == null) { value = globalProperties.getProperty(name); if (value == null) { name = alias(name, JOD_CONVERTER, OPEN_OFFICE); value = globalProperties.getProperty(name); } } return value; }
return super.getProperty(name);
configurationValues.put("serverReadOnly", readOnly); configurationValues.put("serverMode", serverModeProvider.getServerMode().toString()); boolean ftpEnabled = Boolean.valueOf(fileServersSubsystem.getProperty("ftp.enabled")); configurationValues.put("ftpEnabled", ftpEnabled); configurationValues.put("webDAVEnabled", webdavService.getEnabled()); configurationValues.put("thumbnailsEnabled", thumbnailService.getThumbnailsEnabled()); boolean activitiesFeedEnabled = Boolean.valueOf(activitiesFeedSubsystem.getProperty("activities.feed.notifier.enabled")); configurationValues.put("activitiesFeedEnabled", activitiesFeedEnabled); configurationValues.put("activitiEngineEnabled", workflowAdminService.isEngineEnabled(ActivitiConstants.ENGINE_ID)); boolean inboundEnabled = Boolean.valueOf(inboundSMTPSubsystem.getProperty("email.inbound.enabled")); boolean emailServerEnabled = Boolean.valueOf(inboundSMTPSubsystem.getProperty("email.server.enabled")); boolean inboundServerEnabled = inboundEnabled && emailServerEnabled; configurationValues.put("inboundServerEnabled", inboundServerEnabled); boolean imapEnabled = Boolean.valueOf(imapSubsystem.getProperty("imap.server.enabled")); configurationValues.put("imapEnabled", imapEnabled); replicationInfo.put("enabled", replicationSubsystem.getProperty("replication.enabled")); replicationInfo.put("readOnly", replicationSubsystem.getProperty("replication.transfer.readonly")); configurationValues.put("replication", replicationInfo);
configurationValues.put("serverReadOnly", readOnly); configurationValues.put("serverMode", serverModeProvider.getServerMode().toString()); boolean ftpEnabled = Boolean.valueOf(fileServersSubsystem.getProperty("ftp.enabled")); configurationValues.put("ftpEnabled", ftpEnabled); configurationValues.put("webDAVEnabled", webdavService.getEnabled()); configurationValues.put("thumbnailsEnabled", thumbnailService.getThumbnailsEnabled()); boolean activitiesFeedEnabled = Boolean.valueOf(activitiesFeedSubsystem.getProperty("activities.feed.notifier.enabled")); configurationValues.put("activitiesFeedEnabled", activitiesFeedEnabled); configurationValues.put("activitiEngineEnabled", workflowAdminService.isEngineEnabled(ActivitiConstants.ENGINE_ID)); boolean inboundEnabled = Boolean.valueOf(inboundSMTPSubsystem.getProperty("email.inbound.enabled")); boolean emailServerEnabled = Boolean.valueOf(inboundSMTPSubsystem.getProperty("email.server.enabled")); boolean inboundServerEnabled = inboundEnabled && emailServerEnabled; configurationValues.put("inboundServerEnabled", inboundServerEnabled); boolean imapEnabled = Boolean.valueOf(imapSubsystem.getProperty("imap.server.enabled")); configurationValues.put("imapEnabled", imapEnabled); replicationInfo.put("enabled", replicationSubsystem.getProperty("replication.enabled")); replicationInfo.put("readOnly", replicationSubsystem.getProperty("replication.transfer.readonly")); configurationValues.put("replication", replicationInfo);
return super.getProperty(name);
@Test public void getPropertyTest() { when(subsystem.getProperty("abc")).thenReturn("xyz"); String actual = config.getProperty("abc"); assertEquals("xyz", actual); }
@Test public void aliasOpenOfficeToJodTest() { when(subsystem.getProperty(Matchers.any())).thenReturn(null); // Should be picked up as normal globalProperties.setProperty("content.transformer.complex.JodConverter.Image.priority", "150"); // JodConverter value should override the OpenOffice value globalProperties.setProperty("content.transformer.complex.OpenOffice.Image.extensions.docx.txt.supported", "true"); globalProperties.setProperty("content.transformer.complex.JodConverter.Image.extensions.docx.txt.supported", "false"); // Should be picked up as a JodConverter value globalProperties.setProperty("content.transformer.complex.OpenOffice.Image.extensions.xlsb.txt.maxSourceSizeKBytes", "1024"); Set<String> propertyNames = transformerProperties.getPropertyNames(); assertEquals("The combined settings should be seen as only three entries", 3, propertyNames.size()); assertTrue(propertyNames.contains("content.transformer.complex.JodConverter.Image.priority")); assertTrue(propertyNames.contains("content.transformer.complex.JodConverter.Image.extensions.docx.txt.supported")); assertTrue(propertyNames.contains("content.transformer.complex.JodConverter.Image.extensions.xlsb.txt.maxSourceSizeKBytes")); assertEquals("150", transformerProperties.getProperty("content.transformer.complex.JodConverter.Image.priority")); assertEquals("false", transformerProperties.getProperty("content.transformer.complex.JodConverter.Image.extensions.docx.txt.supported")); assertEquals("1024", transformerProperties.getProperty("content.transformer.complex.JodConverter.Image.extensions.xlsb.txt.maxSourceSizeKBytes")); } }
String groupName = sysAdminSubsystem.getProperty(sitePublicGroupPropName); assertEquals(sitePublicGroupPropName + " was not the pristine value", originalSitePublicGroup, groupName);