RepositoryConfiguration { public Properties getAsProperties() { final Properties properties = new Properties(); properties.put(PROPERTY_KEY_REPOSITORY_URL, getRepositoryUrl()); properties.put(PROPERTY_KEY_REPOSITORY_DISPLAY_URL, getRepositoryDisplayUrl()); if (userCredentials != null) { properties.put(PROPERTY_KEY_USER_NAME, userCredentials.getUserName()); properties.put(PROPERTY_KEY_USER_PASSWORD, userCredentials.getPassword()); } if (cacheCredentials != null) { properties.put(PROPERTY_KEY_CACHE_USER_NAME, cacheCredentials.getUserName()); properties.put(PROPERTY_KEY_CACHE_USER_PASSWORD, cacheCredentials.getPassword()); } properties.put(PROPERTY_KEY_USE_CACHE, isCacheUsed() ? "true" : "false"); properties.put(PROPERTY_KEY_ALLOW_ZIP_DOWNLOADS, isZippedDownloadsAllowed() ? "true" : "false"); properties.put(PROPERTY_KEY_ENABLE_ACCESS_CONTROL, isAccessControlEnabled() ? "true" : "false"); properties.put(PROPERTY_KEY_ENABLE_ENTRY_TRAY, isEntryTrayEnabled() ? "true" : "false"); properties.put(PROPERTY_KEY_ENABLE_ISSUE_TRACKER_INTEGRATION, isIssueTrackerIntegrationEnabled() ? "true" : "false"); properties.put(PROPERTY_KEY_RSS_ITEMS_COUNT, String.valueOf(getRssItemsCount())); properties.put(PROPERTY_KEY_RSS_TEMPLATE_FILE, getRssTemplateFile()); properties.put(PROPERTY_KEY_MAIL_TEMPLATE_FILE, getMailTemplateFile()); return properties; } RepositoryConfiguration(final String repositoryName); static RepositoryConfiguration create(final String repositoryName, final Properties properties); Properties getAsProperties(); Credentials getUserCredentials(); void setUserCredentials(final Credentials userCredentials); Credentials getCacheCredentials(); void setCacheCredentials(final Credentials cacheCredentials); String getRepositoryUrl(); void setRepositoryUrl(String repositoryUrl); void setRepositoryDisplayUrl(final String repositoryDisplayUrl); String getRepositoryDisplayUrl(); SVNURL getSVNURL(); void setCacheUsed(final boolean useCache); boolean isCacheUsed(); boolean isAccessControlEnabled(); boolean isEntryTrayEnabled(); void setEnableEntryTray(final boolean enableEntryTray); void setEnableAccessControl(final boolean enableAccessControl); void setZippedDownloadsAllowed(final boolean zipDownloadsAllowed); boolean isZippedDownloadsAllowed(); int getRssItemsCount(); RepositoryName getName(); boolean isIssueTrackerIntegrationEnabled(); void setEnableIssueTrackerIntegration(final boolean enableIssueTrackerIntegration); void setRssTemplateFile(final String rssTemplateFile); void setMailTemplateFile(final String mailTemplateFile); String getRssTemplateFile(); String getMailTemplateFile(); String getRssTemplate(); String getMailTemplate(); void setPersisted(); boolean isPersisted(); @Override String toString(); static final int DEFAULT_RSS_ITEMS_COUNT; static final String DEFAULT_RSS_TEMPLATE_FILE; static final String DEFAULT_MAIL_TEMPLATE_FILE; static final String PROPERTY_KEY_REPOSITORY_URL; static final String PROPERTY_KEY_REPOSITORY_DISPLAY_URL; static final String PROPERTY_KEY_USER_NAME; static final String PROPERTY_KEY_USER_PASSWORD; static final String PROPERTY_KEY_USE_CACHE; static final String PROPERTY_KEY_CACHE_USER_NAME; static final String PROPERTY_KEY_CACHE_USER_PASSWORD; static final String PROPERTY_KEY_ALLOW_ZIP_DOWNLOADS; static final String PROPERTY_KEY_ENABLE_ACCESS_CONTROL; static final String PROPERTY_KEY_ENABLE_ISSUE_TRACKER_INTEGRATION; static final String PROPERTY_KEY_RSS_ITEMS_COUNT; static final String PROPERTY_KEY_RSS_TEMPLATE_FILE; static final String PROPERTY_KEY_MAIL_TEMPLATE_FILE; static final String PROPERTY_KEY_ENABLE_ENTRY_TRAY; }
@Test public void testGetAsProperties() throws Exception { final RepositoryConfiguration conf = new RepositoryConfiguration("test"); try { conf.getAsProperties(); fail("Should throw NPE"); } catch (NullPointerException npe) { } conf.setRepositoryUrl("http: final Properties props = conf.getAsProperties(); assertEquals(10, props.size()); assertEquals("http: assertEquals("http: assertNull(props.get(PROPERTY_KEY_USER_NAME)); assertNull(props.get(PROPERTY_KEY_USER_PASSWORD)); assertEquals("false", props.get(PROPERTY_KEY_USE_CACHE)); assertEquals("false", props.get(PROPERTY_KEY_ALLOW_ZIP_DOWNLOADS)); assertEquals("false", props.get(PROPERTY_KEY_ENABLE_ISSUE_TRACKER_INTEGRATION)); assertEquals("false", props.get(PROPERTY_KEY_ENABLE_ACCESS_CONTROL)); assertEquals("20", props.get(PROPERTY_KEY_RSS_ITEMS_COUNT)); assertEquals("/rsstemplate.html", props.get(PROPERTY_KEY_RSS_TEMPLATE_FILE)); assertEquals("/mailtemplate.html", props.get(PROPERTY_KEY_MAIL_TEMPLATE_FILE)); }