mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Phase 2 of the client config re-org
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2298 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -22,9 +22,11 @@ import java.util.Map;
|
||||
|
||||
import org.alfresco.config.Config;
|
||||
import org.alfresco.config.ConfigElement;
|
||||
import org.alfresco.config.ConfigException;
|
||||
import org.alfresco.config.source.FileConfigSource;
|
||||
import org.alfresco.config.xml.XMLConfigService;
|
||||
import org.alfresco.util.BaseTest;
|
||||
import org.alfresco.web.config.AdvancedSearchConfigElement.CustomProperty;
|
||||
import org.alfresco.web.config.PropertySheetConfigElement.ItemConfig;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -37,16 +39,12 @@ import org.apache.commons.logging.LogFactory;
|
||||
*/
|
||||
public class WebClientConfigTest extends BaseTest
|
||||
{
|
||||
private static Log logger = LogFactory.getLog(WebClientConfigTest.class);
|
||||
|
||||
/**
|
||||
* @see junit.framework.TestCase#setUp()
|
||||
*/
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
logger.info("******************************************************");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,7 +67,6 @@ public class WebClientConfigTest extends BaseTest
|
||||
// get the property names from the global section and make sure it is the
|
||||
// name property
|
||||
List<String> propNames = ((PropertySheetConfigElement) globalPropSheet).getItemNamesToShow();
|
||||
logger.info("propNames = " + propNames);
|
||||
assertTrue("There should only be one property in the list", propNames.size() == 1);
|
||||
assertTrue("The property name should be 'name'", propNames.get(0).equals("name"));
|
||||
|
||||
@@ -81,7 +78,6 @@ public class WebClientConfigTest extends BaseTest
|
||||
.getConfigElement("property-sheet");
|
||||
assertNotNull("Space aspect property config should not be null", spacePropConfig);
|
||||
propNames = spacePropConfig.getItemNamesToShow();
|
||||
logger.info("propNames = " + propNames);
|
||||
assertTrue("There should be 5 properties in the list", propNames.size() == 5);
|
||||
|
||||
// make sure the property sheet config has come back with the correct data
|
||||
@@ -130,7 +126,6 @@ public class WebClientConfigTest extends BaseTest
|
||||
propNames.add(propName);
|
||||
}
|
||||
|
||||
logger.info("propNames = " + propNames);
|
||||
assertTrue("There should be 5 properties", propNames.size() == 5);
|
||||
assertFalse("The id attribute should not be present", propsToDisplay.hasAttribute("id"));
|
||||
}
|
||||
@@ -160,30 +155,10 @@ public class WebClientConfigTest extends BaseTest
|
||||
assertNotNull("kids should not be null", kids);
|
||||
assertTrue("There should be more than one child", kids.size() > 1);
|
||||
|
||||
logger.info("propNames = " + propNames);
|
||||
assertEquals("There should be 5 properties", propNames.size() == 5, true);
|
||||
assertFalse("The id attribute should not be present", propsToDisplay.hasAttribute("id"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the custom server configuration objects
|
||||
*/
|
||||
public void testServerConfig()
|
||||
{
|
||||
// setup the config service
|
||||
String configFiles = getResourcesDir() + "test-config.xml";
|
||||
XMLConfigService svc = new XMLConfigService(new FileConfigSource(configFiles));
|
||||
svc.init();
|
||||
|
||||
// get the global config and from that the server config
|
||||
ServerConfigElement serverConfig = (ServerConfigElement)svc.getGlobalConfig().
|
||||
getConfigElement(ServerConfigElement.CONFIG_ELEMENT_ID);
|
||||
assertNotNull("server config should not be null", serverConfig);
|
||||
|
||||
String errorPage = serverConfig.getErrorPage();
|
||||
assertTrue("error page should be '/jsp/error.jsp'", errorPage.equals("/jsp/error.jsp"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the custom client configuration objects
|
||||
*/
|
||||
@@ -197,46 +172,46 @@ public class WebClientConfigTest extends BaseTest
|
||||
// get the global config and from that the client config
|
||||
ClientConfigElement clientConfig = (ClientConfigElement)svc.getGlobalConfig().
|
||||
getConfigElement(ClientConfigElement.CONFIG_ELEMENT_ID);
|
||||
assertNotNull("client config should not be null", clientConfig);
|
||||
assertNotNull("client config", clientConfig);
|
||||
|
||||
List<String> views = clientConfig.getViews();
|
||||
assertEquals("There should be 2 configured views", 2, views.size());
|
||||
String renderer = views.get(1);
|
||||
assertEquals("Renderer for the icons view should be 'org.alfresco.web.ui.common.renderer.data.RichListRenderer.IconViewRenderer'",
|
||||
"org.alfresco.web.ui.common.renderer.data.RichListRenderer.IconViewRenderer", renderer);
|
||||
assertEquals("error page", "/jsp/error.jsp", clientConfig.getErrorPage());
|
||||
assertEquals("login page", "/jsp/login.jsp", clientConfig.getLoginPage());
|
||||
assertEquals("home space permission", "Guest", clientConfig.getHomeSpacePermission());
|
||||
assertEquals("help url", "http://www.alfresco.org/help/webclient", clientConfig.getHelpUrl());
|
||||
assertEquals("edit link type", "http", clientConfig.getEditLinkType());
|
||||
assertEquals("from address", "alfresco@alfresco.org", clientConfig.getFromEmailAddress());
|
||||
assertEquals("recent spaces", 6, clientConfig.getRecentSpacesItems());
|
||||
assertEquals("search minimum", 3, clientConfig.getSearchMinimum());
|
||||
assertTrue("shelf visible", clientConfig.isShelfVisible());
|
||||
}
|
||||
|
||||
public void testClientOverride()
|
||||
{
|
||||
// setup the config service
|
||||
List<String> configFiles = new ArrayList<String>(2);
|
||||
configFiles.add(getResourcesDir() + "test-config.xml");
|
||||
configFiles.add(getResourcesDir() + "test-config-override.xml");
|
||||
XMLConfigService svc = new XMLConfigService(new FileConfigSource(configFiles));
|
||||
svc.init();
|
||||
|
||||
// try and get the global config section
|
||||
Config globalSection = svc.getGlobalConfig();
|
||||
assertNotNull("global section", globalSection);
|
||||
|
||||
String defaultView = clientConfig.getDefaultView("topic");
|
||||
assertEquals("Default view for topic should be 'bubble'", "bubble", defaultView);
|
||||
// get the client config
|
||||
ClientConfigElement clientConfig = (ClientConfigElement)globalSection.
|
||||
getConfigElement(ClientConfigElement.CONFIG_ELEMENT_ID);
|
||||
assertNotNull("client config", clientConfig);
|
||||
|
||||
// get the defualt view for something that doesn't exist
|
||||
defaultView = clientConfig.getDefaultView("not-there");
|
||||
assertEquals("Default view for missing view should be 'details'", "details", defaultView);
|
||||
|
||||
// get the default page size for the forum details view
|
||||
int pageSize = clientConfig.getDefaultPageSize("forum", "details");
|
||||
assertEquals("Page size for forum details should be 20", 20, pageSize);
|
||||
|
||||
// get the defualt page size for a non existent view
|
||||
pageSize = clientConfig.getDefaultPageSize("not", "there");
|
||||
assertEquals("Page size for forum details should be 10", 10, pageSize);
|
||||
|
||||
// get the default page size for a non existent screen and valid view
|
||||
pageSize = clientConfig.getDefaultPageSize("not-there", "icons");
|
||||
assertEquals("Page size for icons view should be 9", 9, pageSize);
|
||||
|
||||
// test the sort column
|
||||
String column = clientConfig.getDefaultSortColumn("browse");
|
||||
assertEquals("Sort column for browse should be 'name'", "name", column);
|
||||
|
||||
column = clientConfig.getDefaultSortColumn("topic");
|
||||
assertEquals("Sort column for topic should be 'created'", "created", column);
|
||||
|
||||
// test the sorting direction
|
||||
boolean sortDescending = clientConfig.hasDescendingSort("browse");
|
||||
assertFalse("browse screen should use an ascending sort", sortDescending);
|
||||
|
||||
sortDescending = clientConfig.hasDescendingSort("topic");
|
||||
assertTrue("topic screen should use a descending sort", sortDescending);
|
||||
assertEquals("error page", "/jsp/error-override.jsp", clientConfig.getErrorPage());
|
||||
assertEquals("login page", "/jsp/login-override.jsp", clientConfig.getLoginPage());
|
||||
assertEquals("home space permission", "Editor", clientConfig.getHomeSpacePermission());
|
||||
assertEquals("help url", "http://www.somewhere.com/help", clientConfig.getHelpUrl());
|
||||
assertEquals("edit link type", "webdav", clientConfig.getEditLinkType());
|
||||
assertEquals("from address", "me@somewhere.com", clientConfig.getFromEmailAddress());
|
||||
assertEquals("recent spaces", 1, clientConfig.getRecentSpacesItems());
|
||||
assertEquals("search minimum", 10, clientConfig.getSearchMinimum());
|
||||
assertFalse("shelf visible", clientConfig.isShelfVisible());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -350,16 +325,10 @@ public class WebClientConfigTest extends BaseTest
|
||||
String toViewId = child.getAttribute("to-view-id");
|
||||
String toOutcome = child.getAttribute("to-outcome");
|
||||
|
||||
logger.info("fromViewId = " + fromViewId);
|
||||
logger.info("fromOutcome = " + fromOutcome);
|
||||
logger.info("toViewId = " + toViewId);
|
||||
logger.info("toOutcome = " + toOutcome);
|
||||
|
||||
assertNull(fromOutcome);
|
||||
assertNull(toOutcome);
|
||||
|
||||
assertEquals("/jsp/browse/browse.jsp", fromViewId);
|
||||
assertEquals("/jsp/forums/forums.jsp", toViewId);
|
||||
assertNull("fromOutcome", fromOutcome);
|
||||
assertNull("toOutcome", toOutcome);
|
||||
assertEquals("fromViewId", "/jsp/browse/browse.jsp", fromViewId);
|
||||
assertEquals("toViewId", "/jsp/forums/forums.jsp", toViewId);
|
||||
|
||||
// get the second child and make sure the attributes are correct,
|
||||
// from-outcome should be 'browse' and to-outcome should be 'newOutcome'
|
||||
@@ -369,15 +338,163 @@ public class WebClientConfigTest extends BaseTest
|
||||
toViewId = child.getAttribute("to-view-id");
|
||||
toOutcome = child.getAttribute("to-outcome");
|
||||
|
||||
logger.info("fromViewId = " + fromViewId);
|
||||
logger.info("fromOutcome = " + fromOutcome);
|
||||
logger.info("toViewId = " + toViewId);
|
||||
logger.info("toOutcome = " + toOutcome);
|
||||
assertNull("fromViewId", fromViewId);
|
||||
assertNull("toViewId", toViewId);
|
||||
assertEquals("fromOutcome", "browse", fromOutcome);
|
||||
assertEquals("toOutcome", "newOutcome", toOutcome);
|
||||
}
|
||||
|
||||
public void testLanguages()
|
||||
{
|
||||
// setup the config service
|
||||
List<String> configFiles = new ArrayList<String>(2);
|
||||
configFiles.add(getResourcesDir() + "test-config.xml");
|
||||
configFiles.add(getResourcesDir() + "test-config-override.xml");
|
||||
XMLConfigService svc = new XMLConfigService(new FileConfigSource(configFiles));
|
||||
svc.init();
|
||||
|
||||
assertNull(fromViewId);
|
||||
assertNull(toViewId);
|
||||
LanguagesConfigElement config = (LanguagesConfigElement)svc.getConfig("Languages").
|
||||
getConfigElement(LanguagesConfigElement.CONFIG_ELEMENT_ID);
|
||||
assertNotNull("languages config", config);
|
||||
|
||||
assertEquals("browse", fromOutcome);
|
||||
assertEquals("newOutcome", toOutcome);
|
||||
// make sure there are 3 languages returned
|
||||
assertEquals("number of languages", 4, config.getLanguages().size());
|
||||
|
||||
// make sure they are returned in order
|
||||
assertEquals("first language", "en_US", config.getLanguages().get(0));
|
||||
assertEquals("second language", "fr_FR", config.getLanguages().get(1));
|
||||
assertEquals("third language", "de_DE", config.getLanguages().get(2));
|
||||
assertEquals("fourth language", "ja_JP", config.getLanguages().get(3));
|
||||
|
||||
// make sure the labels are correct too
|
||||
assertEquals("en_US", "English", config.getLabelForLanguage("en_US"));
|
||||
assertEquals("fr_FR", "French", config.getLabelForLanguage("fr_FR"));
|
||||
assertEquals("de_DE", "German", config.getLabelForLanguage("de_DE"));
|
||||
assertEquals("ja_JP", "Japanese", config.getLabelForLanguage("ja_JP"));
|
||||
|
||||
// make sure the getChildren method throws an exception
|
||||
try
|
||||
{
|
||||
config.getChildren();
|
||||
fail("getChildren() did not throw an excpetion");
|
||||
}
|
||||
catch (ConfigException ce)
|
||||
{
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
public void testAdvancedSearch()
|
||||
{
|
||||
// setup the config service
|
||||
List<String> configFiles = new ArrayList<String>(2);
|
||||
configFiles.add(getResourcesDir() + "test-config.xml");
|
||||
configFiles.add(getResourcesDir() + "test-config-override.xml");
|
||||
XMLConfigService svc = new XMLConfigService(new FileConfigSource(configFiles));
|
||||
svc.init();
|
||||
|
||||
AdvancedSearchConfigElement config = (AdvancedSearchConfigElement)svc.getConfig("Advanced Search").
|
||||
getConfigElement(AdvancedSearchConfigElement.CONFIG_ELEMENT_ID);
|
||||
assertNotNull("advanced search config", config);
|
||||
|
||||
// make sure there are 2 custom types
|
||||
assertEquals("number of content types", 2, config.getContentTypes().size());
|
||||
|
||||
// make sure they are correct
|
||||
assertEquals("first type", "cm:dictionaryModel", config.getContentTypes().get(0));
|
||||
assertEquals("second type", "fm:post", config.getContentTypes().get(1));
|
||||
|
||||
// make sure there are 3 custom properties
|
||||
assertEquals("number of content properties", 3, config.getCustomProperties().size());
|
||||
|
||||
CustomProperty property = config.getCustomProperties().get(0);
|
||||
assertTrue("first property is type", property.Type != null);
|
||||
|
||||
property = config.getCustomProperties().get(1);
|
||||
assertTrue("second property is aspect", property.Type == null);
|
||||
assertTrue("second property is aspect", property.Aspect != null);
|
||||
assertEquals("second property aspect", "app:simpleworkflow", property.Aspect);
|
||||
assertEquals("second property name", "app:approveStep", property.Property);
|
||||
|
||||
property = config.getCustomProperties().get(2);
|
||||
assertEquals("third property name", "app:rejectStep", property.Property);
|
||||
assertEquals("third property display id", "reject_step", property.LabelId);
|
||||
|
||||
// make sure the getChildren method throws an exception
|
||||
try
|
||||
{
|
||||
config.getChildren();
|
||||
fail("getChildren() did not throw an excpetion");
|
||||
}
|
||||
catch (ConfigException ce)
|
||||
{
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
public void testViews()
|
||||
{
|
||||
// setup the config service
|
||||
List<String> configFiles = new ArrayList<String>(2);
|
||||
configFiles.add(getResourcesDir() + "test-config.xml");
|
||||
configFiles.add(getResourcesDir() + "test-config-override.xml");
|
||||
XMLConfigService svc = new XMLConfigService(new FileConfigSource(configFiles));
|
||||
svc.init();
|
||||
|
||||
ViewsConfigElement config = (ViewsConfigElement)svc.getConfig("Views").
|
||||
getConfigElement(ViewsConfigElement.CONFIG_ELEMENT_ID);
|
||||
assertNotNull("views config", config);
|
||||
|
||||
// make sure there are 4 views
|
||||
List<String> views = config.getViews();
|
||||
assertEquals("configured views", 4, views.size());
|
||||
|
||||
// make sure the views are correct
|
||||
assertEquals("details view renderer",
|
||||
"org.alfresco.web.ui.common.renderer.data.RichListRenderer$DetailsViewRenderer",
|
||||
views.get(0));
|
||||
assertEquals("icons view renderer",
|
||||
"org.alfresco.web.ui.common.renderer.data.RichListRenderer$IconViewRenderer",
|
||||
views.get(1));
|
||||
assertEquals("list view renderer",
|
||||
"org.alfresco.web.ui.common.renderer.data.RichListRenderer$ListViewRenderer",
|
||||
views.get(2));
|
||||
assertEquals("bubble view renderer",
|
||||
"org.alfresco.web.bean.ForumsBean$TopicBubbleViewRenderer", views.get(3));
|
||||
|
||||
// test default views
|
||||
assertEquals("default view", "details", config.getDefaultView("not-there"));
|
||||
assertEquals("default view for topic", "bubble", config.getDefaultView("topic"));
|
||||
|
||||
// test page sizes
|
||||
assertEquals("default page size", 10, config.getDefaultPageSize("not", "there"));
|
||||
assertEquals("forums icons page size", 20, config.getDefaultPageSize("forums", "icons"));
|
||||
assertEquals("forum details page size", 50, config.getDefaultPageSize("forum", "details"));
|
||||
assertEquals("icons view page size", 9, config.getDefaultPageSize("not-there", "icons"));
|
||||
|
||||
// test the sort columns
|
||||
assertEquals("default sort column", "name", config.getDefaultSortColumn("not-there"));
|
||||
assertEquals("browse page sort column", "name", config.getDefaultSortColumn("browse"));
|
||||
assertEquals("forum page sort column", "modified", config.getDefaultSortColumn("forum"));
|
||||
assertEquals("topic page sort column", "created", config.getDefaultSortColumn("topic"));
|
||||
|
||||
// test the sorting direction
|
||||
assertFalse("default sort direction should be ascending", config.hasDescendingSort("not-there"));
|
||||
assertFalse("browse screen should use an ascending sort", config.hasDescendingSort("browse"));
|
||||
assertTrue("topic screen should use a descending sort", config.hasDescendingSort("forum"));
|
||||
|
||||
// TODO: uncomment this test once the override of descending sorts is fixed
|
||||
// assertFalse("topic screen should use a ascending sort", config.hasDescendingSort("topic"));
|
||||
|
||||
// make sure the getChildren method throws an exception
|
||||
try
|
||||
{
|
||||
config.getChildren();
|
||||
fail("getChildren() did not throw an excpetion");
|
||||
}
|
||||
catch (ConfigException ce)
|
||||
{
|
||||
// expected
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user