JBoss Portal SVN: r12834 - in branches/JBoss_Portal_Branch_2_7/core-admin/src: main/org/jboss/portal/core/admin/ui/actions and 2 other directories.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2009-02-18 19:48:22 -0500 (Wed, 18 Feb 2009)
New Revision: 12834
Added:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/Action.java
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/DisplayNameAction.java
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/AddPageAction.java
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/CreateInstanceAction.java
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PortalAction.java
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PortalInstanceDisplayNameAction.java
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PortalObjectDisplayNameAction.java
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PropertyAction.java
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/RenameAction.java
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/WEB-INF/classes/Resource.properties
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml
Log:
- JBPORTAL-2317: Added more validation to prevent creating objects with invalid names
+ What constitutes an invalid name should be documented somewhere... Right now valid names match ParameterValidation.XSS_CHECK.
+ Re-factor JSF actions so that validation behavior and error message handling can be factored in Action superclass.
+ Behavior associated with display names has been generified into DisplayNameAction with PortalInstanceDNA and PortalObjectDNA
as children, which are not much simpler
+ More localization of error messages
- Needs more test, in particular, it doesn't seem like targeted error messages are currently working (JSF id seems to be interfering)
Modified: branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java 2009-02-19 00:40:10 UTC (rev 12833)
+++ branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java 2009-02-19 00:48:22 UTC (rev 12834)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
* contributors as indicated by the @authors tag. See the *
* copyright.txt in the distribution for a full listing of *
* individual contributors. *
@@ -45,6 +45,7 @@
import org.jboss.portal.core.model.portal.PortalObjectPermission;
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.faces.component.portlet.PortletEventEvent;
+import org.jboss.portal.faces.gui.JSFBeanContext;
import org.jboss.portal.identity.RoleModule;
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletInvoker;
@@ -486,7 +487,7 @@
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Success",
- "'" + name + "' " + typeName + " was successfully set as default " + typeName);
+ "'" + name + "' " + typeName + " was successfully set as default " + typeName);
FacesContext.getCurrentInstance().addMessage("status", message);
}
}
@@ -559,7 +560,7 @@
// set the state from the id
PortalObjectId portalObjectId = null;
- if(id != null)
+ if (id != null)
{
portalObjectId = PortalObjectId.parse(id, PortalObjectPath.LEGACY_BASE64_FORMAT);
}
@@ -681,7 +682,10 @@
//
selectedProperties = new PropertiesBean(this);
controlProperties = new ControlPropertiesBean(this);
+
+ // it'd be better if propertyAction was injected in faces-config.xml so that we can also inject the shared beanContext
propertyAction = new PropertyAction(this);
+ propertyAction.setBeanContext(new JSFBeanContext());
//
theme = new ThemeBean(selectedObject);
@@ -800,10 +804,10 @@
public SelectItem[] getAvailableActions()
{
return new SelectItem[]{
- new SelectItem("view", "View"),
- new SelectItem("viewrecursive", "View Recursive"),
- new SelectItem("personalize", "Personalize"),
- new SelectItem("personalizerecursive", "Personalize Recursive")
+ new SelectItem("view", "View"),
+ new SelectItem("viewrecursive", "View Recursive"),
+ new SelectItem("personalize", "Personalize"),
+ new SelectItem("personalizerecursive", "Personalize Recursive")
};
}
Added: branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/Action.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/Action.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/Action.java 2009-02-19 00:48:22 UTC (rev 12834)
@@ -0,0 +1,97 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+
+package org.jboss.portal.core.admin.ui.actions;
+
+import org.jboss.portal.common.util.ParameterValidation;
+import org.jboss.portal.faces.gui.ManagedBean;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+public abstract class Action extends ManagedBean
+{
+ public static final String INVALID_NAME = "INVALID_NAME_ERROR";
+ public static final String DUPLICATE = "DUPLICATE_ERROR";
+ protected static final String INSTANCE_TYPE = "INSTANCE_TYPE";
+ protected static final String PAGE_TYPE = "PAGE_TYPE";
+ protected static final String PORTAL_TYPE = "PORTAL_TYPE";
+ protected static final String DISPLAY_NAME_TYPE = "DISPLAY_NAME_TYPE";
+ protected static final String PROPERTY_TYPE = "PROPERTY_TYPE";
+ protected static final String PORTAL_OBJECT_TYPE = "PORTAL_OBJECT_TYPE";
+
+ public String checkNameValidity(String name, String targetForErrorMessage)
+ {
+ if (ParameterValidation.isNullOrEmpty(name))
+ {
+ beanContext.createTargetedErrorMessage(targetForErrorMessage, INVALID_NAME, name, getLocalizedType());
+ return null;
+ }
+ else
+ {
+ // Trim name
+ name = name.trim();
+
+ ParameterValidation.sanitizeFromPatternWithHandler(name, ParameterValidation.XSS_CHECK,
+ new MessageValidationHandler(null, targetForErrorMessage, name));
+
+ // Check for duplicate
+ if (isAlreadyExisting(name))
+ {
+ beanContext.createTargetedErrorMessage(targetForErrorMessage, DUPLICATE, name, getLocalizedType());
+ return null;
+ }
+
+ return name;
+ }
+ }
+
+ private String getLocalizedType()
+ {
+ return beanContext.getMessageFromBundle(getObjectTypeName());
+ }
+
+ protected abstract String getObjectTypeName();
+
+ public abstract boolean isAlreadyExisting(String objectName);
+
+ private class MessageValidationHandler extends ParameterValidation.ValidationErrorHandler
+ {
+ private String targetForErrorMessage;
+ private String validatedName;
+
+ private MessageValidationHandler(String defaultValue, String targetForErrorMessage, String validatedName)
+ {
+ super(defaultValue);
+ this.targetForErrorMessage = targetForErrorMessage;
+ this.validatedName = validatedName;
+ }
+
+ protected String internalValidationErrorHandling(String s)
+ {
+ beanContext.createTargetedErrorMessage(targetForErrorMessage, INVALID_NAME, validatedName, getLocalizedType());
+ return null;
+ }
+ }
+}
Modified: branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/AddPageAction.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/AddPageAction.java 2009-02-19 00:40:10 UTC (rev 12833)
+++ branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/AddPageAction.java 2009-02-19 00:48:22 UTC (rev 12834)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
* contributors as indicated by the @authors tag. See the *
* copyright.txt in the distribution for a full listing of *
* individual contributors. *
@@ -26,31 +26,16 @@
import org.jboss.portal.core.model.portal.Page;
import org.jboss.portal.core.model.portal.PageContainer;
-import javax.faces.application.FacesMessage;
-import javax.faces.context.FacesContext;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public class AddPageAction
+public class AddPageAction extends Action
{
/** . */
private static final Logger log = Logger.getLogger(AddPageAction.class);
- /** . */
- private static final String ERROR_DUPE_NAME = "Duplicate Page name found on this portal!";
-
- /** . */
- private static final String ERROR_EMPTY_NAME = "Page name cannot be blank!";
-
- /** . */
- private static final String ERROR_NO_NAME = "Page name not specified!";
-
- /** . */
- private static final String ERROR_INTERNAL_ERROR = "An internal error happened!";
-
/** The page container that will create the child. */
public PageContainer pageContainer;
@@ -65,31 +50,9 @@
public void execute()
{
- FacesMessage message = null;
-
- //
- if (pageName == null)
+ pageName = checkNameValidity(pageName, messageTarget);
+ if (pageName != null)
{
- message = new FacesMessage(FacesMessage.SEVERITY_ERROR, ERROR_NO_NAME, ERROR_NO_NAME);
- }
- else
- {
- pageName = pageName.trim();
-
- //
- if (pageName.length() == 0)
- {
- message = new FacesMessage(FacesMessage.SEVERITY_ERROR, ERROR_EMPTY_NAME, ERROR_EMPTY_NAME);
- }
- else if (pageContainer.getChild(pageName) != null)
- {
- message = new FacesMessage(FacesMessage.SEVERITY_ERROR, ERROR_DUPE_NAME, ERROR_DUPE_NAME);
- }
- }
-
- //
- if (message == null)
- {
try
{
Page page = pageContainer.createPage(pageName);
@@ -102,16 +65,10 @@
}
catch (Exception e)
{
- log.error("An error happened during page creation", e);
- message = new FacesMessage(FacesMessage.SEVERITY_ERROR, ERROR_INTERNAL_ERROR, ERROR_INTERNAL_ERROR);
+ log.error("An error occurred during page creation", e);
+ beanContext.createErrorMessageFrom(messageTarget, e);
}
}
-
- //
- if (message != null && messageTarget != null)
- {
- FacesContext.getCurrentInstance().addMessage(messageTarget, message);
- }
}
public interface Listener
@@ -148,4 +105,14 @@
{
this.listener = listener;
}
+
+ protected String getObjectTypeName()
+ {
+ return PAGE_TYPE;
+ }
+
+ public boolean isAlreadyExisting(String objectName)
+ {
+ return pageContainer.getChild(objectName) != null;
+ }
}
Modified: branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/CreateInstanceAction.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/CreateInstanceAction.java 2009-02-19 00:40:10 UTC (rev 12833)
+++ branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/CreateInstanceAction.java 2009-02-19 00:48:22 UTC (rev 12834)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
* contributors as indicated by the @authors tag. See the *
* copyright.txt in the distribution for a full listing of *
* individual contributors. *
@@ -31,8 +31,6 @@
import org.jboss.portal.security.SecurityConstants;
import org.jboss.portal.security.spi.provider.DomainConfigurator;
-import javax.faces.application.FacesMessage;
-import javax.faces.context.FacesContext;
import java.util.Collections;
import java.util.Set;
@@ -40,7 +38,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public class CreateInstanceAction
+public class CreateInstanceAction extends Action
{
/** . */
@@ -51,6 +49,7 @@
/** . */
private InstanceManagerBean instanceMgr;
+ private static final String MESSAGE_TARGET = "add_instance_form:instanceId";
public String getInstanceId()
{
@@ -84,40 +83,10 @@
public String execute()
{
- FacesContext faces = FacesContext.getCurrentInstance();
-
// Validate instance id
+ instanceId = checkNameValidity(instanceId, MESSAGE_TARGET);
if (instanceId == null)
{
- FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "No instance id!", null);
- faces.addMessage("add_instance_form:instanceId", message);
- }
- else
- {
- // Trim name
- instanceId = instanceId.trim();
-
- // Check for empty string
- if (instanceId.length() == 0)
- {
- FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Instance id cannot be blank!", null);
- faces.addMessage("add_instance_form:instanceId", message);
- }
- else
- {
- // Check for duplicate instance
- Instance instance = instanceMgr.getInstanceContainer().getDefinition(instanceId);
- if (instance != null)
- {
- FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "An instance with the id " + instanceId + " already exist!", null);
- faces.addMessage("add_instance_form:instanceId", message);
- }
- }
- }
-
- //
- if (faces.getMessages().hasNext())
- {
return null;
}
@@ -125,8 +94,7 @@
Portlet portlet = portletMgr.getSelectedPortlet();
if (portlet == null)
{
- FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "No portlet was selected!", null);
- faces.addMessage("add_instance_form:instanceId", message);
+ beanContext.createTargetedErrorMessage(MESSAGE_TARGET, "NO_SELECTED_PORTLET_ERROR");
return null;
}
else
@@ -152,10 +120,20 @@
}
catch (Exception e)
{
- FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "An unexpected error happened!", null);
- faces.addMessage("add_instance_form:instanceId", message);
+ log.error("An error occurred during instance creation.", e);
+ beanContext.createErrorMessageFrom(MESSAGE_TARGET, e);
return null;
}
}
}
+
+ protected String getObjectTypeName()
+ {
+ return INSTANCE_TYPE;
+ }
+
+ public boolean isAlreadyExisting(String objectName)
+ {
+ return instanceMgr.getInstanceContainer().getDefinition(objectName) != null;
+ }
}
Added: branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/DisplayNameAction.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/DisplayNameAction.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/DisplayNameAction.java 2009-02-19 00:48:22 UTC (rev 12834)
@@ -0,0 +1,182 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+
+package org.jboss.portal.core.admin.ui.actions;
+
+import org.jboss.portal.common.i18n.LocaleFormat;
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.common.util.ConversionException;
+import org.jboss.portal.core.admin.ui.DisplayNameBean;
+import org.jboss.portal.core.model.HasDisplayName;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.SortedMap;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+public abstract class DisplayNameAction extends Action
+{
+ protected Object managerBean;
+ protected String newLocale;
+ protected String newText;
+ protected DisplayNameBean displayNameBean;
+ protected HasDisplayName target;
+
+ public Object getManagerBean()
+ {
+ return managerBean;
+ }
+
+ public void setManagerBean(Object managerBean)
+ {
+ checkManagerBean(managerBean);
+ this.managerBean = managerBean;
+ }
+
+ public String getNewText()
+ {
+ return newText;
+ }
+
+ public void setNewText(String newText)
+ {
+ this.newText = newText;
+ }
+
+ public SortedMap getLocales()
+ {
+ return getDisplayNameBean().getLocales();
+ }
+
+ public String getNewLocale()
+ {
+ return newLocale;
+ }
+
+ public void setNewLocale(String newLocale)
+ {
+ this.newLocale = newLocale;
+ }
+
+ public DisplayNameBean getDisplayNameBean()
+ {
+ if (displayNameBean == null)
+ {
+ displayNameBean = new DisplayNameBean();
+ }
+ return displayNameBean;
+ }
+
+ public void setDisplayNameBean(DisplayNameBean displayNameBean)
+ {
+ this.displayNameBean = displayNameBean;
+ }
+
+ public void addDisplayName() throws ConversionException
+ {
+ newText = checkNameValidity(newText, null);
+ if (newText != null)
+ {
+ HasDisplayName hasDisplayName = getTarget();
+ Map map = getDisplayNameBean().createLocalizedStringMap(LocaleFormat.DEFAULT.getLocale(newLocale), hasDisplayName.getDisplayName(), newText);
+ LocalizedString newLocalizedString = new LocalizedString(map, Locale.ENGLISH);
+ target.setDisplayName(newLocalizedString);
+ }
+ }
+
+ public List<DisplayNameBean.Value> getCurrentLocales()
+ {
+ target = getTarget();
+ if (target != null && target.getDisplayName() != null)
+ {
+ return (List<DisplayNameBean.Value>)getDisplayNameBean().populateCurrentLocales(target.getDisplayName().getValues());
+ }
+ return null;
+ }
+
+ public void editDisplayName()
+ {
+ String locale = beanContext.getParameter("locale");
+ String editAction = beanContext.getParameter("editAction");
+
+ target = getTarget();
+ LocalizedString displayName = target.getDisplayName();
+ Map<Locale, String> map = new HashMap<Locale, String>();
+ if (displayName != null)
+ {
+ Map<Locale, LocalizedString.Value> oldMap = displayName.getValues();
+ Collection<LocalizedString.Value> values = oldMap.values();
+ if (editAction.equals("delete"))
+ {
+ for (LocalizedString.Value value : values)
+ {
+ if (!value.getLocale().toString().equals(locale))
+ {
+ map.put(value.getLocale(), value.getString());
+ }
+ }
+ }
+ if (editAction.equals("rename"))
+ {
+ for (LocalizedString.Value value : values)
+ {
+ map.put(value.getLocale(), value.getString());
+ if (value.getLocale().toString().equals(locale))
+ {
+ newText = value.getString();
+ newLocale = value.getLocale().getLanguage();
+ }
+ }
+ }
+ }
+ LocalizedString newLocalizedString = new LocalizedString(map, Locale.ENGLISH);
+ target.setDisplayName(newLocalizedString);
+ }
+
+ public String editDisplayNames() throws ConversionException
+ {
+ getTarget();
+ getCurrentLocales();
+ return "editDisplayNames";
+ }
+
+ protected String getObjectTypeName()
+ {
+ return DISPLAY_NAME_TYPE;
+ }
+
+ public boolean isAlreadyExisting(String objectName)
+ {
+ return false; // we don't check for duplicates here
+ }
+
+ protected abstract HasDisplayName getTarget();
+
+ protected abstract void checkManagerBean(Object managerBean);
+}
Modified: branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PortalAction.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PortalAction.java 2009-02-19 00:40:10 UTC (rev 12833)
+++ branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PortalAction.java 2009-02-19 00:48:22 UTC (rev 12834)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
* contributors as indicated by the @authors tag. See the *
* copyright.txt in the distribution for a full listing of *
* individual contributors. *
@@ -24,6 +24,7 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
+import org.jboss.portal.common.util.ParameterValidation;
import org.jboss.portal.core.admin.ui.PortalObjectManagerBean;
import org.jboss.portal.core.model.portal.Page;
import org.jboss.portal.core.model.portal.Portal;
@@ -36,10 +37,6 @@
import org.jboss.portal.security.spi.provider.DomainConfigurator;
import org.jboss.portal.theme.ThemeConstants;
-import javax.faces.application.FacesMessage;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.validator.ValidatorException;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -49,7 +46,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public class PortalAction
+public class PortalAction extends Action
{
/** . */
@@ -58,14 +55,8 @@
/** . */
private String portalName;
- //private String defaultPageName;
+ private static final String MESSAGE_TARGET = "create-portal-form:name";
- /** . */
- private static final String ERROR_DUPE_NAME = "Duplicate Portal name found on this portal!";
-
- /** . */
- private static final String ERROR_EMPTY_NAME = "Portal name cannot be blank!";
-
public PortalObjectManagerBean getPortalObjectManager()
{
return pomgr;
@@ -93,87 +84,73 @@
public void setDefaultObjectName(String defaultObjectName)
{
- if (defaultObjectName != null && !defaultObjectName.equals(""))
+ if (!ParameterValidation.isNullOrEmpty(defaultObjectName))
{
pomgr.getSelectedObject().setDeclaredProperty(PortalObject.PORTAL_PROP_DEFAULT_OBJECT_NAME, defaultObjectName);
}
- else if (defaultObjectName == null || defaultObjectName.equals(""))
+ else
{
pomgr.getSelectedObject().setDeclaredProperty(PortalObject.PORTAL_PROP_DEFAULT_OBJECT_NAME, null);
}
}
-
- /**
- * Checks for duplicate portal names on the portal instance. Blank page names are not allowed and are controlled by
- * the required attribute in the presentation page.
- *
- * @param context
- * @param toValidate
- * @param value
- */
- public void validatePortalName(FacesContext context, UIComponent toValidate, Object value)
- {
- String portalName = (String)value;
-
- // check for empty string
- if (portalName.startsWith(" "))
- {
- FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, PortalAction.ERROR_EMPTY_NAME, PortalAction.ERROR_EMPTY_NAME);
- throw new ValidatorException(message);
- }
-
- // Check for duplicate child name
- if (pomgr.getSelectedObject().getChild(portalName) != null)
- {
- FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, PortalAction.ERROR_DUPE_NAME, PortalAction.ERROR_DUPE_NAME);
- throw new ValidatorException(message);
- }
- }
-
public void addPortal()
{
try
{
PortalContainer portalContainer = (PortalContainer)pomgr.getSelectedObject();
- Portal portal = portalContainer.createPortal(portalName);
- DomainConfigurator configurator = pomgr.getDomainConfigurator();
- // Initial portal permissions
- Set actions = new HashSet();
- actions.add(PortalObjectPermission.VIEW_RECURSIVE_ACTION);
- actions.add(PortalObjectPermission.PERSONALIZE_RECURSIVE_ACTION);
- RoleSecurityBinding binding = new RoleSecurityBinding(actions, SecurityConstants.UNCHECKED_ROLE_NAME);
- Set constraints = Collections.singleton(binding);
- configurator.setSecurityBindings(portal.getId().toString(PortalObjectPath.CANONICAL_FORMAT), constraints);
+ portalName = checkNameValidity(portalName, MESSAGE_TARGET);
+ if (portalName != null)
+ {
+ Portal portal = portalContainer.createPortal(portalName);
+ DomainConfigurator configurator = pomgr.getDomainConfigurator();
- // We need to add initial layout sets to avoid problems...
- portal.setDeclaredProperty(ThemeConstants.PORTAL_PROP_LAYOUT, "generic");
- // portal.setDeclaredProperty(ThemeConstants.PORTAL_PROP_THEME, "Nphalanx");
- portal.setDeclaredProperty(ThemeConstants.PORTAL_PROP_RENDERSET, "divRenderer");
+ // Initial portal permissions
+ Set actions = new HashSet();
+ actions.add(PortalObjectPermission.VIEW_RECURSIVE_ACTION);
+ actions.add(PortalObjectPermission.PERSONALIZE_RECURSIVE_ACTION);
+ RoleSecurityBinding binding = new RoleSecurityBinding(actions, SecurityConstants.UNCHECKED_ROLE_NAME);
+ Set constraints = Collections.singleton(binding);
+ configurator.setSecurityBindings(portal.getId().toString(PortalObjectPath.CANONICAL_FORMAT), constraints);
- //
- portal.getSupportedWindowStates().add(WindowState.MAXIMIZED);
- portal.getSupportedWindowStates().add(WindowState.MINIMIZED);
- portal.getSupportedWindowStates().add(WindowState.NORMAL);
+ // We need to add initial layout sets to avoid problems...
+ portal.setDeclaredProperty(ThemeConstants.PORTAL_PROP_LAYOUT, "generic");
+ portal.setDeclaredProperty(ThemeConstants.PORTAL_PROP_RENDERSET, "divRenderer");
- //
- portal.getSupportedModes().add(Mode.EDIT);
- portal.getSupportedModes().add(Mode.HELP);
- portal.getSupportedModes().add(Mode.VIEW);
+ //
+ portal.getSupportedWindowStates().add(WindowState.MAXIMIZED);
+ portal.getSupportedWindowStates().add(WindowState.MINIMIZED);
+ portal.getSupportedWindowStates().add(WindowState.NORMAL);
- // Create the default page
- Page page = portal.createPage("default");
- constraints = Collections.singleton(new RoleSecurityBinding(PortalObjectPermission.VIEW_RECURSIVE_ACTION, SecurityConstants.UNCHECKED_ROLE_NAME));
- configurator.setSecurityBindings(page.getId().toString(PortalObjectPath.CANONICAL_FORMAT), constraints);
+ //
+ portal.getSupportedModes().add(Mode.EDIT);
+ portal.getSupportedModes().add(Mode.HELP);
+ portal.getSupportedModes().add(Mode.VIEW);
- portal.setDeclaredProperty(PortalObject.PORTAL_PROP_DEFAULT_OBJECT_NAME, page.getName());
+ // Create the default page
+ Page page = portal.createPage("default");
+ constraints = Collections.singleton(new RoleSecurityBinding(PortalObjectPermission.VIEW_RECURSIVE_ACTION, SecurityConstants.UNCHECKED_ROLE_NAME));
+ configurator.setSecurityBindings(page.getId().toString(PortalObjectPath.CANONICAL_FORMAT), constraints);
+ portal.setDeclaredProperty(PortalObject.PORTAL_PROP_DEFAULT_OBJECT_NAME, page.getName());
+ }
}
catch (Exception e)
{
- e.printStackTrace();
+ log.error("An error occurred during portal creation.", e);
+ beanContext.createErrorMessageFrom(MESSAGE_TARGET, e);
}
}
+
+ protected String getObjectTypeName()
+ {
+ return PORTAL_TYPE;
+ }
+
+ public boolean isAlreadyExisting(String objectName)
+ {
+ return pomgr.getSelectedObject().getChild(objectName) != null;
+ }
}
Modified: branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PortalInstanceDisplayNameAction.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PortalInstanceDisplayNameAction.java 2009-02-19 00:40:10 UTC (rev 12833)
+++ branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PortalInstanceDisplayNameAction.java 2009-02-19 00:48:22 UTC (rev 12834)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
* contributors as indicated by the @authors tag. See the *
* copyright.txt in the distribution for a full listing of *
* individual contributors. *
@@ -22,199 +22,27 @@
******************************************************************************/
package org.jboss.portal.core.admin.ui.actions;
-import org.jboss.portal.common.i18n.LocaleFormat;
-import org.jboss.portal.common.i18n.LocalizedString;
-import org.jboss.portal.common.util.ConversionException;
-import org.jboss.portal.core.admin.ui.DisplayNameBean;
import org.jboss.portal.core.admin.ui.InstanceManagerBean;
-import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.core.model.HasDisplayName;
-import javax.faces.application.FacesMessage;
-import javax.faces.context.FacesContext;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.SortedMap;
-
/**
* @author <a href="mailto:whales@redhat.com">Wesley Hales</a>
* @version $Revision: 630 $
*/
-public class PortalInstanceDisplayNameAction
+public class PortalInstanceDisplayNameAction extends DisplayNameAction
{
- private Instance selectedInstance;
-
- public Object bean;
-
- private String newLocale;
-
- private String newText;
-
- private SortedMap locales;
-
- private String displayNameByLocale;
-
- private InstanceManagerBean instanceManager;
-
- private DisplayNameBean displayNameBean;
-
- public Object getBean()
+ protected HasDisplayName getTarget()
{
- return bean;
- }
+ target = ((InstanceManagerBean)managerBean).getSelectedInstance();
- public void setBean(Object bean)
- {
- this.bean = bean;
+ return target;
}
- public void addDisplayName() throws ConversionException
+ protected void checkManagerBean(Object managerBean)
{
- if (newText != null)
+ if (!(managerBean instanceof InstanceManagerBean))
{
- Instance instance = getSelectedInstance();
- Map map = getDisplayNameBean().createLocalizedStringMap(LocaleFormat.DEFAULT.getLocale(newLocale),instance.getDisplayName(),newText);
- LocalizedString newLocalizedString = new LocalizedString(map, Locale.ENGLISH);
- selectedInstance.setDisplayName(newLocalizedString);
+ throw new IllegalArgumentException("Illegal manager bean property for PortalInstanceDisplayNameAction. Expecting an InstanceManagerBean instance. Got " + managerBean);
}
- else
- {
- FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "You must enter a name", "You must enter a name");
- FacesContext.getCurrentInstance().addMessage("status", message);
- }
}
-
- public Instance getSelectedInstance()
- {
- if (instanceManager instanceof InstanceManagerBean)
- {
- selectedInstance = instanceManager.getSelectedInstance();
- }
- return selectedInstance;
- }
-
- public void setSelectedInstance(Instance selectedInstance)
- {
- this.selectedInstance = selectedInstance;
- }
-
- public String getNewText()
- {
- return newText;
- }
-
- public void setNewText(String newText)
- {
- this.newText = newText;
- }
-
- public SortedMap getLocales()
- {
- return getDisplayNameBean().getLocales();
- }
-
- public void setLocales(SortedMap locales)
- {
- this.locales = locales;
- }
-
- public String getNewLocale()
- {
- return newLocale;
- }
-
- public void setNewLocale(String newLocale)
- {
- this.newLocale = newLocale;
- }
-
- public List<DisplayNameBean.Value> getCurrentLocales()
- {
- selectedInstance = getSelectedInstance();
- if (selectedInstance != null && selectedInstance.getDisplayName() != null)
- {
- List<DisplayNameBean.Value> currentLocales = getDisplayNameBean().populateCurrentLocales(selectedInstance.getDisplayName().getValues());
-
- return currentLocales;
- }
- return null;
- }
-
- public void editDisplayName()
- {
- String locale = getFacesParam("locale");
- String editAction = getFacesParam("editAction");
-
- Instance selectedInstance = getSelectedInstance();
- LocalizedString displayName = selectedInstance.getDisplayName();
- Map<Locale, String> map = new HashMap<Locale, String>();
- if (displayName != null)
- {
- Map<Locale, LocalizedString.Value> oldMap = displayName.getValues();
- Collection<LocalizedString.Value> values = oldMap.values();
- if (editAction.equals("delete"))
- {
- for (LocalizedString.Value value : values)
- {
- if (!value.getLocale().toString().equals(locale.toString()))
- {
- map.put(value.getLocale(), value.getString());
- }
- }
- }
- if (editAction.equals("rename"))
- {
- for (LocalizedString.Value value : values)
- {
- map.put(value.getLocale(), value.getString());
- if (value.getLocale().toString().equals(locale.toString()))
- {
- newText = value.getString();
- newLocale = value.getLocale().getLanguage();
- }
- }
- }
- }
- LocalizedString newLocalizedString = new LocalizedString(map, Locale.ENGLISH);
- selectedInstance.setDisplayName(newLocalizedString);
- }
-
-
- public String getFacesParam(String param)
- {
- return FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get(param);
- }
-
-
- public String editDisplayNames() throws ConversionException
- {
- getSelectedInstance();
- getCurrentLocales();
- return "editDisplayNames";
- }
-
- public InstanceManagerBean getInstanceManager()
- {
- return instanceManager;
- }
-
- public void setInstanceManager(InstanceManagerBean instanceManager)
- {
- this.instanceManager = instanceManager;
- }
-
- public DisplayNameBean getDisplayNameBean()
- {
- if(displayNameBean == null){
- displayNameBean = new DisplayNameBean();
- }
- return displayNameBean;
- }
-
- public void setDisplayNameBean(DisplayNameBean displayNameBean)
- {
- this.displayNameBean = displayNameBean;
- }
}
Modified: branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PortalObjectDisplayNameAction.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PortalObjectDisplayNameAction.java 2009-02-19 00:40:10 UTC (rev 12833)
+++ branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PortalObjectDisplayNameAction.java 2009-02-19 00:48:22 UTC (rev 12834)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
* contributors as indicated by the @authors tag. See the *
* copyright.txt in the distribution for a full listing of *
* individual contributors. *
@@ -22,188 +22,28 @@
******************************************************************************/
package org.jboss.portal.core.admin.ui.actions;
-import org.jboss.portal.common.i18n.LocaleFormat;
-import org.jboss.portal.common.i18n.LocalizedString;
-import org.jboss.portal.common.util.ConversionException;
-import org.jboss.portal.core.admin.ui.DisplayNameBean;
import org.jboss.portal.core.admin.ui.PortalObjectManagerBean;
-import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.core.model.HasDisplayName;
-import javax.faces.application.FacesMessage;
-import javax.faces.context.FacesContext;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.SortedMap;
-
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
* @author <a href="mailto:whales@redhat.com">Wesley Hales</a>
* @version $Revision$
*/
-public class PortalObjectDisplayNameAction {
-
- private PortalObject selectedObject;
-
- public Object bean;
-
- private String newLocale;
-
- private String newText;
-
- private SortedMap locales;
-
- private String displayNameByLocale;
-
- private DisplayNameBean displayNameBean;
-
- public Object getBean()
+public class PortalObjectDisplayNameAction extends DisplayNameAction
+{
+ protected HasDisplayName getTarget()
{
- return bean;
+ target = ((PortalObjectManagerBean)managerBean).getSelectedObject();
+ return target;
}
- public void setBean(Object bean)
+ protected void checkManagerBean(Object managerBean)
{
- this.bean = bean;
- }
-
- public void addDisplayName() throws ConversionException
- {
- if (newText != null)
+ if (!(managerBean instanceof PortalObjectManagerBean))
{
- PortalObject portalObject = getSelectedObject();
- Map map = getDisplayNameBean().createLocalizedStringMap(LocaleFormat.DEFAULT.getLocale(newLocale),portalObject.getDisplayName(),newText);
- LocalizedString newLocalizedString = new LocalizedString(map, Locale.ENGLISH);
- portalObject.setDisplayName(newLocalizedString);
+ throw new IllegalArgumentException("Illegal manager bean property for PortalObjectDisplayNameAction. Expecting a PortalObjectManagerBean instance. Got " + managerBean);
}
- else
- {
- FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "You must enter a name", "You must enter a name");
- FacesContext.getCurrentInstance().addMessage("status", message);
- }
}
-
-
- public PortalObject getSelectedObject()
- {
- if (bean instanceof PortalObjectManagerBean)
- {
- selectedObject = ((PortalObjectManagerBean) bean).getSelectedObject();
- }
- return selectedObject;
- }
-
- public void setSelectedObject(PortalObject selectedObject)
- {
- this.selectedObject = selectedObject;
- }
-
- public String getNewText()
- {
- return newText;
- }
-
- public void setNewText(String newText)
- {
- this.newText = newText;
- }
-
- public String getNewLocale()
- {
- return newLocale;
- }
-
- public void setNewLocale(String newLocale)
- {
- this.newLocale = newLocale;
- }
-
- public SortedMap getLocales()
- {
- return getDisplayNameBean().getLocales();
- }
-
- public void setLocales(SortedMap locales)
- {
- this.locales = locales;
- }
-
- public List<DisplayNameBean.Value> getCurrentLocales()
- {
- selectedObject = getSelectedObject();
- if (selectedObject != null && selectedObject.getDisplayName() != null)
- {
- List<DisplayNameBean.Value> currentLocales = getDisplayNameBean().populateCurrentLocales(selectedObject.getDisplayName().getValues());
- return currentLocales;
- }
- return null;
- }
-
- public void editDisplayName()
- {
- String locale = getFacesParam("locale");
- String editAction = getFacesParam("editAction");
-
- PortalObject portalObject = getSelectedObject();
- LocalizedString displayName = portalObject.getDisplayName();
- Map<Locale, String> map = new HashMap<Locale, String>();
- if (displayName != null)
- {
- Map<Locale, LocalizedString.Value> oldMap = displayName.getValues();
- Collection<LocalizedString.Value> values = oldMap.values();
- if (editAction.equals("delete"))
- {
- for (LocalizedString.Value value : values)
- {
- if (!value.getLocale().toString().equals(locale.toString()))
- {
- map.put(value.getLocale(), value.getString());
- }
- }
- }
- if (editAction.equals("rename"))
- {
- for (LocalizedString.Value value : values)
- {
- map.put(value.getLocale(), value.getString());
- if (value.getLocale().toString().equals(locale.toString()))
- {
- newText = value.getString();
- newLocale = value.getLocale().getLanguage();
- }
- }
- }
- }
- LocalizedString newLocalizedString = new LocalizedString(map, Locale.ENGLISH);
- selectedObject.setDisplayName(newLocalizedString);
- }
-
- public String getFacesParam(String param){
- return FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get(param);
- }
-
-
- public String editDisplayNames() throws ConversionException
- {
- getSelectedObject();
- getCurrentLocales();
- return "editDisplayNames";
- }
-
- public DisplayNameBean getDisplayNameBean()
- {
- if(displayNameBean == null){
- displayNameBean = new DisplayNameBean();
- }
- return displayNameBean;
- }
-
- public void setDisplayNameBean(DisplayNameBean displayNameBean)
- {
- this.displayNameBean = displayNameBean;
- }
-
}
Modified: branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PropertyAction.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PropertyAction.java 2009-02-19 00:40:10 UTC (rev 12833)
+++ branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PropertyAction.java 2009-02-19 00:48:22 UTC (rev 12834)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
* contributors as indicated by the @authors tag. See the *
* copyright.txt in the distribution for a full listing of *
* individual contributors. *
@@ -24,18 +24,13 @@
import org.jboss.portal.core.admin.ui.PortalObjectManagerBean;
import org.jboss.portal.core.impl.model.portal.PortalObjectImpl;
+import org.jboss.portal.faces.gui.BeanContext;
-import javax.faces.application.FacesMessage;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.validator.ValidatorException;
-import java.util.Map;
-
/**
* @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
* @version $Revision$
*/
-public class PropertyAction
+public class PropertyAction extends Action
{
/** . */
@@ -50,8 +45,6 @@
/** . */
private String otherPropertyName;
- /** . */
- private static final String ERROR_EMPTY_NAME = "Property name cannot be blank!";
public PropertyAction(PortalObjectManagerBean pomgr)
{
@@ -78,33 +71,19 @@
this.propertyValue = propertyValue;
}
-
- public void validatePropertyName(FacesContext context, UIComponent toValidate, Object value)
- {
- String propertyName = (String)value;
-
- // check for empty string
- if (propertyName == null || propertyName.startsWith(" ") || propertyName.equals(""))
- {
- FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, PropertyAction.ERROR_EMPTY_NAME, PropertyAction.ERROR_EMPTY_NAME);
- throw new ValidatorException(message);
- }
- }
-
public void selectProperty()
{
}
public void removeProperty()
{
- Map pmap = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
- String name = (String)pmap.get("name");
+ String name = beanContext.getParameter("name");
((PortalObjectImpl)pomgr.getSelectedObject()).setDeclaredProperty(name, null);
}
public void updateProperty()
{
- String propertyName = otherPropertyName.trim();
+ String propertyName = checkNameValidity(otherPropertyName, BeanContext.STATUS);
String value = "";
//
if (propertyName.length() == 0 && selectedProperty != null)
@@ -115,7 +94,8 @@
//
if (propertyName.length() > 0)
{
- if (getPropertyValue() != null){
+ if (getPropertyValue() != null)
+ {
value = getPropertyValue().trim();
}
pomgr.getSelectedObject().setDeclaredProperty(propertyName, value);
@@ -131,4 +111,14 @@
{
this.otherPropertyName = otherPropertyName;
}
+
+ protected String getObjectTypeName()
+ {
+ return PROPERTY_TYPE;
+ }
+
+ public boolean isAlreadyExisting(String objectName)
+ {
+ return pomgr.getSelectedObject().getDeclaredProperty(objectName) != null;
+ }
}
Modified: branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/RenameAction.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/RenameAction.java 2009-02-19 00:40:10 UTC (rev 12833)
+++ branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/RenameAction.java 2009-02-19 00:48:22 UTC (rev 12834)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
* contributors as indicated by the @authors tag. See the *
* copyright.txt in the distribution for a full listing of *
* individual contributors. *
@@ -24,22 +24,17 @@
import org.jboss.portal.core.admin.ui.PortalObjectManagerBean;
import org.jboss.portal.core.admin.ui.dashboard.DashboardBean;
-import org.jboss.portal.core.model.portal.DuplicatePortalObjectException;
-import org.jboss.portal.core.model.portal.NoSuchPortalObjectException;
-import org.jboss.portal.core.model.portal.PageContainer;
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.PortalObjectPath;
import org.jboss.portal.security.spi.provider.DomainConfigurator;
-import javax.faces.application.FacesMessage;
-import javax.faces.context.FacesContext;
import java.util.Set;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
* @version $Revision$
*/
-public class RenameAction
+public class RenameAction extends Action
{
private String newName;
@@ -49,6 +44,7 @@
private DomainConfigurator domainConfigurator;
private Object bean;
+ private static final String MESSAGE_TARGET = "renameForm:newName";
public void setNewName(String newName)
{
@@ -87,54 +83,49 @@
public String execute()
{
- PortalObject parent = pageContainer.getParent();
- PortalObject newObject = null;
- try
+ newName = checkNameValidity(newName, MESSAGE_TARGET);
+ if (newName != null)
{
- // TODO: Should be in a tx
+ PortalObject parent = pageContainer.getParent();
+ PortalObject newObject = null;
+ try
+ {
+ // TODO: Should be in a tx
- // Clone portal object
- newObject = pageContainer.copy(parent, newName, true);
+ // Clone portal object
+ newObject = pageContainer.copy(parent, newName, true);
- // Copy security settings
- Set set = domainConfigurator.getSecurityBindings(pageContainer.getId().toString(PortalObjectPath.CANONICAL_FORMAT));
- domainConfigurator.setSecurityBindings(newObject.getId().toString(PortalObjectPath.CANONICAL_FORMAT), set);
+ // Copy security settings
+ Set set = domainConfigurator.getSecurityBindings(pageContainer.getId().toString(PortalObjectPath.CANONICAL_FORMAT));
+ domainConfigurator.setSecurityBindings(newObject.getId().toString(PortalObjectPath.CANONICAL_FORMAT), set);
- String defaultObject = (String)parent.getDeclaredProperties().get(PortalObject.PORTAL_PROP_DEFAULT_OBJECT_NAME);
- if (pageContainer.getName().equals(defaultObject))
+ String defaultObject = parent.getDeclaredProperties().get(PortalObject.PORTAL_PROP_DEFAULT_OBJECT_NAME);
+ if (pageContainer.getName().equals(defaultObject))
+ {
+ parent.setDeclaredProperty(PortalObject.PORTAL_PROP_DEFAULT_OBJECT_NAME, newName);
+ }
+
+ // Destroy previous object
+ parent.destroyChild(pageContainer.getName());
+ }
+ catch (Exception e)
{
- parent.setDeclaredProperty(PortalObject.PORTAL_PROP_DEFAULT_OBJECT_NAME, newName);
+ log.error("An error occurred while attempting to rename " + pageContainer + "to " + newName);
+ beanContext.createErrorMessageFrom(MESSAGE_TARGET, e);
}
- // Destroy previous object
- parent.destroyChild(pageContainer.getName());
+ // TODO: This is not clean
+ if (bean instanceof PortalObjectManagerBean)
+ {
+ ((PortalObjectManagerBean)bean).selectObject(parent);
+ return "objects";
+ }
+ else if (bean instanceof DashboardBean)
+ {
+ ((DashboardBean)bean).selectedPageName = newObject.getName();
+ }
}
- catch (IllegalArgumentException e)
- {
- e.printStackTrace();
- }
- catch (DuplicatePortalObjectException e)
- {
- String message = "The name \"" + newName + "\" is already used, please choose a different one";
- FacesContext.getCurrentInstance().addMessage("renameForm:newName", new FacesMessage(FacesMessage.SEVERITY_ERROR, message, message));
- return null;
- }
- catch (NoSuchPortalObjectException e)
- {
- e.printStackTrace();
- }
- // TODO: This is not clean
- if (bean instanceof PortalObjectManagerBean)
- {
- ((PortalObjectManagerBean)bean).selectObject(parent);
- return "objects";
- }
- else if (bean instanceof DashboardBean)
- {
- ((DashboardBean)bean).selectedPageName = newObject.getName();
- }
-
return null;
}
@@ -148,5 +139,13 @@
this.bean = bean;
}
+ protected String getObjectTypeName()
+ {
+ return PORTAL_OBJECT_TYPE;
+ }
+ public boolean isAlreadyExisting(String objectName)
+ {
+ return pageContainer.getChild(objectName) != null;
+ }
}
Modified: branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/WEB-INF/classes/Resource.properties
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/WEB-INF/classes/Resource.properties 2009-02-19 00:40:10 UTC (rev 12833)
+++ branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/WEB-INF/classes/Resource.properties 2009-02-19 00:48:22 UTC (rev 12834)
@@ -1,6 +1,6 @@
################################################################################
# JBoss, a division of Red Hat #
-# Copyright 2006, Red Hat Middleware, LLC, and individual #
+# Copyright 2009, Red Hat Middleware, LLC, and individual #
# contributors as indicated by the @authors tag. See the #
# copyright.txt in the distribution for a full listing of #
# individual contributors. #
@@ -21,48 +21,7 @@
# 02110-1301 USA, or see the FSF site: http://www.fsf.org. #
################################################################################
-PORTLET_INSTANCES=Portlet Instances
-INSTANCE_DELETE=instance Delete
-PORTLET_CAUSING_REFERENCING_NOT_ABLE=portlet instance causing windows referencing it to not be able to display their content anymore
-ARE_YOU_SURE_DELETE=Are you sure you want to delete this portlet instance ?
-DASHBOARD_THEME_PROPERTIES=Dashboard theme properties
-CONFIGURE_DASHBOARD_SETTINGS=Configure dashboards settings
-DASHBOARDS=Dashboards
-ADD_DISPLAY_NAMES=Add Display Names
-CURRENT_DISPLAY_NAMES=Current Display Names
-SAVE=Save
-MANAGE=Manage
-PORTALS_NO_CAP=portals
-PORTAL=portal
-SUB_PORTALS=sub-portals
-PAGES_WITHIN=pages within
-CREATE_PORTAL_NAMED=Create a portal named
-PAGE_LAYOUT=Page layout
-SECURITY=Security
-THEME=Theme
-RENAME=Rename
-DISPLAY_NAMES=Display Names
-MANAGE_SUB_PAGES_WITHIN=Manage sub-pages within
-CREATE_PAGE_NAMED=Create a page named
-SET_PAGE_PERMISSIONS=Please set the page permissions
-PAGE_THEME_PROPERTIES=Page theme properties
-SET_PORTAL_PERMISSIONS=Please set the portal permissions
-PORTAL_THEME_PROPERTIES=Portal theme properties
-SETTINGS_ARE_INHERITED_BY_ALL_PAGES=These settings are inherited by all the pages and windows of this portal. You may override these settings by selecting the appropriate value on the respective Theme settings pages
-EVENT_LISTENER_BINDING=Event Listener Binding
-CHOOSE_ID_PORTALEVENTLISTENER=Choose the id of the PortalEventListener to bind to this
-SET_PERMISSIONS_FOR=Please set the permissions for the
-WINDOW_NO_CAP=window
-WINDOW_THEME_PROPERTIES=Window theme properties
-INSTANCE_ID=Instance id
-INSTANCE_NAME=Instance name
-ACTIONS=Actions
-PREFERENCES=Preferences
-PORTLET_DETAILS=portlet details
-ASSOCIATED_PORTLET_NOT_AVAILABLE=The associated portlet is not available
-PREFERENCES_NO_CAP=preferences
-SECURITY_SETTINGS=security settings
-MAKE_DEFAULT=Make Default
+ Default
MANAGE_WINDOWS_WITHIN=Manage windows within
PORTAL_OBJECTS=Portal Objects
PORTALS=Portals
@@ -320,8 +279,16 @@
COORDINATION_EVENT_CREATE_PREVIEW_STEP3=The produced window events will be wired to the following destination event:
COORDINATION_EVENT_CREATE_PREVIEW_STEP4=for the following destination windows:
-
-
COORDINATION_WIRING=event wiring
COORDINATION_PARAMETER=parameter binding
COORDINATION_ALIAS=alias binding
+
+INVALID_NAME_ERROR=''{0}'' is an invalid {1} name: Cannot be null, empty or contain '\' or '%5c'
+NO_SELECTED_PORTLET_ERROR=No portlet was selected!
+DUPLICATE_ERROR=A(n) {1} named ''{0}'' already exists!
+bean_support_unexpected_error=Unexpected error:
+bean_support_cause=Cause:
+
+INSTANCE_TYPE=instance
+PAGE_TYPE=page
+PORTAL_TYPE=portal
Modified: branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml 2009-02-19 00:40:10 UTC (rev 12833)
+++ branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml 2009-02-19 00:48:22 UTC (rev 12834)
@@ -1,24 +1,24 @@
<?xml version="1.0"?>
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ JBoss, a division of Red Hat ~
- ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
- ~ contributors as indicated by the @authors tag. See the ~
- ~ copyright.txt in the distribution for a full listing of ~
- ~ individual contributors. ~
- ~ ~
- ~ This is free software; you can redistribute it and/or modify it ~
- ~ under the terms of the GNU Lesser General Public License as ~
- ~ published by the Free Software Foundation; either version 2.1 of ~
- ~ the License, or (at your option) any later version. ~
- ~ ~
- ~ This software is distributed in the hope that it will be useful, ~
- ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
- ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
- ~ Lesser General Public License for more details. ~
- ~ ~
- ~ You should have received a copy of the GNU Lesser General Public ~
- ~ License along with this software; if not, write to the Free ~
- ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ Copyright 2009, Red Hat Middleware, LLC, and individual
+ ~ contributors as indicated by the @authors tag. See the
+ ~ copyright.txt in the distribution for a full listing of
+ ~ individual contributors.
+ ~
+ ~ This is free software; you can redistribute it and/or modify it
+ ~ under the terms of the GNU Lesser General Public License as
+ ~ published by the Free Software Foundation; either version 2.1 of
+ ~ the License, or (at your option) any later version.
+ ~
+ ~ This software is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ~ Lesser General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public
+ ~ License along with this software; if not, write to the Free
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
@@ -29,7 +29,7 @@
<application>
<view-handler>
- org.jboss.portletbridge.application.PortletViewHandler
+ org.jboss.portletbridge.application.PortletViewHandler
</view-handler>
<state-manager>org.jboss.portletbridge.application.PortletStateManager</state-manager>
<message-bundle>Resource</message-bundle>
@@ -112,6 +112,11 @@
<property-name>portalObjectManager</property-name>
<value>#{sessionScope.portalobjectmgr}</value>
</managed-property>
+ <managed-property>
+ <property-name>beanContext</property-name>
+ <property-class>org.jboss.portal.faces.gui.BeanContext</property-class>
+ <value>#{beanContext}</value>
+ </managed-property>
</managed-bean>
<managed-bean>
<managed-bean-name>addPageAction</managed-bean-name>
@@ -129,6 +134,11 @@
<property-name>listener</property-name>
<value>#{sessionScope.dashboard}</value>
</managed-property>
+ <managed-property>
+ <property-name>beanContext</property-name>
+ <property-class>org.jboss.portal.faces.gui.BeanContext</property-class>
+ <value>#{beanContext}</value>
+ </managed-property>
</managed-bean>
<managed-bean>
<managed-bean-name>assignContentToWindowAction</managed-bean-name>
@@ -266,13 +276,17 @@
<property-name>instanceManager</property-name>
<value>#{sessionScope.instancemgr}</value>
</managed-property>
+ <managed-property>
+ <property-name>beanContext</property-name>
+ <property-class>org.jboss.portal.faces.gui.BeanContext</property-class>
+ <value>#{beanContext}</value>
+ </managed-property>
</managed-bean>
-
<!--
- | Dashboard beans
- -->
+ | Dashboard beans
+ -->
<managed-bean>
<managed-bean-name>dashboard</managed-bean-name>
@@ -336,9 +350,14 @@
<managed-bean-class>org.jboss.portal.core.admin.ui.actions.PortalObjectDisplayNameAction</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
- <property-name>bean</property-name>
+ <property-name>managerBean</property-name>
<value>#{portalobjectmgr}</value>
</managed-property>
+ <managed-property>
+ <property-name>beanContext</property-name>
+ <property-class>org.jboss.portal.faces.gui.BeanContext</property-class>
+ <value>#{beanContext}</value>
+ </managed-property>
</managed-bean>
<managed-bean>
@@ -346,9 +365,14 @@
<managed-bean-class>org.jboss.portal.core.admin.ui.actions.PortalInstanceDisplayNameAction</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
- <property-name>instanceManager</property-name>
+ <property-name>managerBean</property-name>
<value>#{sessionScope.instancemgr}</value>
</managed-property>
+ <managed-property>
+ <property-name>beanContext</property-name>
+ <property-class>org.jboss.portal.faces.gui.BeanContext</property-class>
+ <value>#{beanContext}</value>
+ </managed-property>
</managed-bean>
<managed-bean>
@@ -599,7 +623,7 @@
<component-type>org.jboss.portal.Portlet</component-type>
<component-class>org.jboss.portal.faces.component.portlet.UIPortlet</component-class>
</component>
-
+
<render-kit>
<renderer>
<component-family>javax.faces.Input</component-family>
17 years, 2 months
JBoss Portal SVN: r12833 - branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2009-02-18 19:40:10 -0500 (Wed, 18 Feb 2009)
New Revision: 12833
Modified:
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/BeanContext.java
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/JSFBeanContext.java
Log:
- Added Javadoc and made parameter names more precise.
- JSFBeanContext.createMessage now uses BeanContext.STATUS as target if none is specified.
Modified: branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/BeanContext.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/BeanContext.java 2009-02-19 00:37:54 UTC (rev 12832)
+++ branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/BeanContext.java 2009-02-19 00:40:10 UTC (rev 12833)
@@ -60,24 +60,33 @@
protected abstract Locale getLocale();
- public void createErrorMessage(String message, Object... params)
+ public void createErrorMessage(String localizedMessageId, Object... params)
{
- createLocalizedMessage(STATUS, message, getErrorSeverity(), params);
+ createLocalizedMessage(STATUS, localizedMessageId, getErrorSeverity(), params);
}
- public void createTargetedErrorMessage(String target, String message, Object... params)
+ public void createTargetedErrorMessage(String target, String localizedMessageId, Object... params)
{
- createLocalizedMessage(target, message, getErrorSeverity(), params);
+ createLocalizedMessage(target, localizedMessageId, getErrorSeverity(), params);
}
- protected void createLocalizedMessage(String target, String message, Object severity, Object... params)
+ /**
+ * Adds a localized message using the appropriate severity to the identified target in the context. This method
+ * accepts an arbitrary number of arguments to be passed as parameters of localized strings.
+ *
+ * @param target the target in this context that will receive the new message
+ * @param localizedMessageId a resource bundle identifier identifying which the localized string to use as a message
+ * @param severity an object representing the severity of the message (typically FacesMessage.Severity)
+ * @param params additional parameters to be passed to replace tokens in localized strings
+ */
+ protected void createLocalizedMessage(String target, String localizedMessageId, Object severity, Object... params)
{
- createMessage(target, getMessageFromBundle(message, params), severity);
+ createMessage(target, getMessageFromBundle(localizedMessageId, params), severity);
}
- public String getMessageFromBundle(String message, Object... params)
+ public String getMessageFromBundle(String localizedMessageId, Object... params)
{
- return getLocalizedMessage(message, getLocale(), params);
+ return getLocalizedMessage(localizedMessageId, getLocale(), params);
}
public static String getLocalizedMessage(String localizationKey, Locale locale, Object... params)
@@ -91,6 +100,17 @@
createErrorMessageFrom(STATUS, e);
}
+ /**
+ * Creates a localized error message targeting the specified object in the context and using the specified error
+ * information. This method looks for two specific resource bundle entries to localize the message, {@link
+ * #UNEXPECTED_ERROR} and {@link #CAUSE}, using the following format for the message: <code>result of {@link
+ * #getLocalizedMessageOrExceptionName(Throwable)} for the exception\n[localized value associated with {@link
+ * #CAUSE}result of {@link #getLocalizedMessageOrExceptionName(Throwable)} for the exception's cause if the cause
+ * exists]
+ *
+ * @param target the contextual object target by the message to be created
+ * @param e the exception that we want to display as an error message
+ */
public void createErrorMessageFrom(String target, Exception e)
{
Throwable cause = e.getCause();
@@ -99,6 +119,14 @@
createMessage(target, message, getErrorSeverity());
}
+ /**
+ * Retrieves a localized message associated with the specified Throwable.
+ *
+ * @param e the Throwable for which a localized message is to be retrieved
+ * @return the localized message associated with the specified Throwable if it exists or the localized value
+ * associated with the {@link #UNEXPECTED_ERROR} resource bundle entry to which is appended the Throwable
+ * class name.
+ */
private String getLocalizedMessageOrExceptionName(Throwable e)
{
String localizedMessage = e.getLocalizedMessage();
@@ -109,14 +137,14 @@
return localizedMessage;
}
- protected void createInfoMessage(String target, String message)
+ protected void createInfoMessage(String target, String localizedMessageId)
{
- createLocalizedMessage(target, message, getInfoSeverity());
+ createLocalizedMessage(target, localizedMessageId, getInfoSeverity());
}
- public void createInfoMessage(String message)
+ public void createInfoMessage(String localizedMessageId)
{
- createInfoMessage(STATUS, message);
+ createInfoMessage(STATUS, localizedMessageId);
}
/**
Modified: branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/JSFBeanContext.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/JSFBeanContext.java 2009-02-19 00:37:54 UTC (rev 12832)
+++ branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/JSFBeanContext.java 2009-02-19 00:40:10 UTC (rev 12833)
@@ -23,6 +23,8 @@
package org.jboss.portal.faces.gui;
+import org.jboss.portal.common.util.ParameterValidation;
+
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import java.util.Locale;
@@ -58,6 +60,11 @@
protected void createMessage(String target, String message, Object severity)
{
+ if (ParameterValidation.isNullOrEmpty(target))
+ {
+ target = STATUS;
+ }
+
FacesMessage.Severity jsfSeverity;
if (severity instanceof FacesMessage.Severity)
{
17 years, 2 months
JBoss Portal SVN: r12832 - in branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model: instance and 1 other directories.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2009-02-18 19:37:54 -0500 (Wed, 18 Feb 2009)
New Revision: 12832
Added:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/HasDisplayName.java
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/instance/Instance.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/PortalObject.java
Log:
- Extracted display name behavior from Instance and PortalObject into a HasDisplayName interface.
Added: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/HasDisplayName.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/HasDisplayName.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/HasDisplayName.java 2009-02-19 00:37:54 UTC (rev 12832)
@@ -0,0 +1,47 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+
+package org.jboss.portal.core.model;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+public interface HasDisplayName
+{
+ /**
+ * Return the localized string used to represent that object.
+ *
+ * @return the localized display name
+ */
+ LocalizedString getDisplayName();
+
+ /**
+ * Set the localized string used to represent that object.
+ *
+ * @param localizedString the localized display name
+ */
+ void setDisplayName(LocalizedString localizedString);
+}
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/instance/Instance.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/instance/Instance.java 2009-02-19 00:10:12 UTC (rev 12831)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/instance/Instance.java 2009-02-19 00:37:54 UTC (rev 12832)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
* contributors as indicated by the @authors tag. See the *
* copyright.txt in the distribution for a full listing of *
* individual contributors. *
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.core.model.instance;
-import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.core.model.HasDisplayName;
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.invocation.PortletInvocation;
@@ -38,7 +38,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public interface Instance
+public interface Instance extends HasDisplayName
{
/** The attribute name under which the instance id can be accessed. */
String INSTANCE_ID_ATTRIBUTE = "instanceid";
@@ -51,20 +51,6 @@
String getId();
/**
- * Return the display name
- *
- * @return the display name
- */
- LocalizedString getDisplayName();
-
- /**
- * Set the display name
- *
- * @param localizedString
- */
- void setDisplayName(LocalizedString localizedString);
-
- /**
* Return the runtime metadata for this portlet.
*
* @return the info
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/PortalObject.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/PortalObject.java 2009-02-19 00:10:12 UTC (rev 12831)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/PortalObject.java 2009-02-19 00:37:54 UTC (rev 12832)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
* contributors as indicated by the @authors tag. See the *
* copyright.txt in the distribution for a full listing of *
* individual contributors. *
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.core.model.portal;
-import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.core.model.HasDisplayName;
import java.util.Collection;
import java.util.Map;
@@ -33,7 +33,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public interface PortalObject extends Comparable
+public interface PortalObject extends Comparable, HasDisplayName
{
/** Portal property name that indicates the name of the default portal to lookup. */
@@ -86,22 +86,8 @@
* @return the object name
*/
String getName();
-
- /**
- * Return the localized string used to represent that object.
- *
- * @return the localized display name
- */
- LocalizedString getDisplayName();
/**
- * Set the localized string used to represent that object.
- *
- * @param localizedString the localized display name
- */
- void setDisplayName(LocalizedString localizedString);
-
- /**
* Returns the listener id or null if there is none.
*
* @return the listener
@@ -146,7 +132,7 @@
/**
* Returns the child of the specified type and with the given name or <code>null</code> if it cannot be found.
*
- * @param name the child's name
+ * @param name the child's name
* @param expectedType the expected type of the child to be retrieved
* @param <T> a class extending PortalObject
* @return the named child or <code>null</code> if it cannot be found
17 years, 2 months
JBoss Portal SVN: r12831 - in modules/common/trunk/common/src: test/java/org/jboss/portal/test/common/util and 1 other directory.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2009-02-18 19:10:12 -0500 (Wed, 18 Feb 2009)
New Revision: 12831
Modified:
modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/ParameterValidation.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/util/ParameterValidationTestCase.java
Log:
- Improved XSS detection pattern.
- Added test case.
Modified: modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/ParameterValidation.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/ParameterValidation.java 2009-02-18 15:51:04 UTC (rev 12830)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/ParameterValidation.java 2009-02-19 00:10:12 UTC (rev 12831)
@@ -36,7 +36,7 @@
public class ParameterValidation
{
public final static Pattern CSS_DISTANCE = Pattern.compile("\\d+\\W*(em|ex|px|in|cm|mm|pt|pc|%)?");
- public final static Pattern XSS_CHECK = Pattern.compile("[^<>\\(\\)=]*");
+ public final static Pattern XSS_CHECK = Pattern.compile("([^<>\\(\\)=\\\\](?!%5c))*", Pattern.CASE_INSENSITIVE);
/**
* Implements a behavior to be executed in case a value fails to be validated. Uses the Chain of responsibility
Modified: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/util/ParameterValidationTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/util/ParameterValidationTestCase.java 2009-02-18 15:51:04 UTC (rev 12830)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/util/ParameterValidationTestCase.java 2009-02-19 00:10:12 UTC (rev 12831)
@@ -97,6 +97,19 @@
assertEquals(defaultValue, ParameterValidation.sanitizeFromPattern("", ParameterValidation.CSS_DISTANCE, defaultValue));
}
+ public void testSanitizeFromPatternXSSCheck()
+ {
+ String defaultValue = "default";
+ assertEquals(defaultValue, ParameterValidation.sanitizeFromPattern("/foo/bar/\\/baz", ParameterValidation.XSS_CHECK, defaultValue));
+ assertEquals(defaultValue, ParameterValidation.sanitizeFromPattern("/foo/bar/%5c/baz", ParameterValidation.XSS_CHECK, defaultValue));
+ assertEquals(defaultValue, ParameterValidation.sanitizeFromPattern("/foo/bar/%5C/baz", ParameterValidation.XSS_CHECK, defaultValue));
+ assertEquals(defaultValue, ParameterValidation.sanitizeFromPattern("http://qa.cwcportal.aviation.ge.com:80/portal/auth/portal/main/cwcportal-" +
+ "Home/cwcportal-Home-LeftNavigationPortletWindow?action=1&org.apache.myfaces.portlet.MyFacesGenericPortlet.VIEW_ID=/pages/h" +
+ "omeleftnavigation.jsp<script>window.open(\"http://3.211.64.16/XSS/ \", \"XSS\",\"width=550,height=290\")</script>",
+ ParameterValidation.XSS_CHECK, defaultValue));
+ assertEquals(defaultValue, ParameterValidation.sanitizeFromPattern("/foo/bar/</baz", ParameterValidation.XSS_CHECK, defaultValue));
+ }
+
public void testSanitizeFromValuesNullValue()
{
String defaultValue = "default";
17 years, 2 months
JBoss Portal SVN: r12830 - modules/common/trunk/common/src/main/java/org/jboss/portal/common/util.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2009-02-18 10:51:04 -0500 (Wed, 18 Feb 2009)
New Revision: 12830
Modified:
modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/ParameterValidation.java
Log:
- Javadoc for isNullOrEmpty.
Modified: modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/ParameterValidation.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/ParameterValidation.java 2009-02-18 15:47:58 UTC (rev 12829)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/ParameterValidation.java 2009-02-18 15:51:04 UTC (rev 12830)
@@ -131,7 +131,14 @@
}
}
- /** @since 2.6 */
+ /**
+ * Determines whether the given String is <code>null</code> or empty (after all extra whitespaces have been trimmed,
+ * if any).
+ *
+ * @param valueToCheck the String to test
+ * @return <code>true</code> if the the given String is <code>null</code> or empty (after being trimmed),
+ * <code>false</code> otherwise.
+ */
public static boolean isNullOrEmpty(String valueToCheck)
{
return valueToCheck == null || valueToCheck.trim().length() == 0;
17 years, 2 months
JBoss Portal SVN: r12829 - in modules/common/trunk/common/src: test/java/org/jboss/portal/test/common/util and 1 other directory.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2009-02-18 10:47:58 -0500 (Wed, 18 Feb 2009)
New Revision: 12829
Modified:
modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/ParameterValidation.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/util/ParameterValidationTestCase.java
Log:
- ParameterValidation.isNullOrEmpty now trims tested String if not null.
Modified: modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/ParameterValidation.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/ParameterValidation.java 2009-02-17 10:46:18 UTC (rev 12828)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/ParameterValidation.java 2009-02-18 15:47:58 UTC (rev 12829)
@@ -134,7 +134,7 @@
/** @since 2.6 */
public static boolean isNullOrEmpty(String valueToCheck)
{
- return valueToCheck == null || valueToCheck.length() == 0;
+ return valueToCheck == null || valueToCheck.trim().length() == 0;
}
public static void throwIllegalArgExceptionIfNull(Object objectToTest, String name)
Modified: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/util/ParameterValidationTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/util/ParameterValidationTestCase.java 2009-02-17 10:46:18 UTC (rev 12828)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/util/ParameterValidationTestCase.java 2009-02-18 15:47:58 UTC (rev 12829)
@@ -41,6 +41,14 @@
appender = "";
}
+ public void testIsNullOrEmpty()
+ {
+ assertTrue(ParameterValidation.isNullOrEmpty(null));
+ assertTrue(ParameterValidation.isNullOrEmpty(""));
+ assertTrue(ParameterValidation.isNullOrEmpty(" \t\n"));
+ assertFalse(ParameterValidation.isNullOrEmpty(" test "));
+ }
+
public void testSanitizeFromPatternNullPattern()
{
try
17 years, 2 months
JBoss Portal SVN: r12828 - branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests.
by portal-commits@lists.jboss.org
Author: vrockai
Date: 2009-02-17 05:46:18 -0500 (Tue, 17 Feb 2009)
New Revision: 12828
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/testng.xml
Log:
portal end to end test in suite
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/testng.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/testng.xml 2009-02-17 10:44:45 UTC (rev 12827)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/testng.xml 2009-02-17 10:46:18 UTC (rev 12828)
@@ -28,52 +28,58 @@
<class name="org.jboss.portal.test.selenium.UserInterceptorPortletTestCase"></class></classes>
</test>
- <test name="org.jboss.portal.test.selenium.cms.CMSFileTestCase"
+ <test name="org.jboss.portal.test.selenium.DashboardTestCase"
verbose="2" annotations="JDK">
<classes>
- <class name="org.jboss.portal.test.selenium.cms.CMSFileTestCase"></class></classes>
+ <class name="org.jboss.portal.test.selenium.DashboardTestCase"></class></classes>
</test>
- <test name="org.jboss.portal.test.selenium.cms.CMSSecureTestCase"
+ <test name="org.jboss.portal.test.selenium.portal.AdminPortalTestCase"
verbose="2" annotations="JDK">
<classes>
- <class name="org.jboss.portal.test.selenium.cms.CMSSecureTestCase"></class></classes>
+ <class name="org.jboss.portal.test.selenium.portal.AdminPortalTestCase"></class></classes>
</test>
-
- <test name="org.jboss.portal.test.selenium.cms.CMSDirectoryTestCase"
+
+ <test name="org.jboss.portal.test.selenium.portal.PortletDefinitionsTestCase"
verbose="2" annotations="JDK">
<classes>
- <class name="org.jboss.portal.test.selenium.cms.CMSDirectoryTestCase"></class></classes>
+ <class name="org.jboss.portal.test.selenium.portal.PortletDefinitionsTestCase"></class></classes>
</test>
- <test name="org.jboss.portal.test.selenium.cms.CMSFileUploadTestCase"
+ <test name="org.jboss.portal.test.selenium.portal.PortletInstancesTestCase"
verbose="2" annotations="JDK">
<classes>
- <class name="org.jboss.portal.test.selenium.cms.CMSFileUploadTestCase"></class></classes>
+ <class name="org.jboss.portal.test.selenium.portal.PortletInstancesTestCase"></class></classes>
</test>
- <test name="org.jboss.portal.test.selenium.DashboardTestCase"
+ <test verbose="2" name="org.jboss.portal.test.selenium.usecase.NewPortalUsecaseTestCase" annotations="JDK">
+ <classes>
+ <class name="org.jboss.portal.test.selenium.usecase.NewPortalUsecaseTestCase"/>
+ </classes>
+ </test>
+
+ <test name="org.jboss.portal.test.selenium.cms.CMSFileTestCase"
verbose="2" annotations="JDK">
<classes>
- <class name="org.jboss.portal.test.selenium.DashboardTestCase"></class></classes>
+ <class name="org.jboss.portal.test.selenium.cms.CMSFileTestCase"></class></classes>
</test>
- <test name="org.jboss.portal.test.selenium.portal.AdminPortalTestCase"
+ <test name="org.jboss.portal.test.selenium.cms.CMSSecureTestCase"
verbose="2" annotations="JDK">
<classes>
- <class name="org.jboss.portal.test.selenium.portal.AdminPortalTestCase"></class></classes>
+ <class name="org.jboss.portal.test.selenium.cms.CMSSecureTestCase"></class></classes>
</test>
-
- <test name="org.jboss.portal.test.selenium.portal.PortletDefinitionsTestCase"
+
+ <test name="org.jboss.portal.test.selenium.cms.CMSDirectoryTestCase"
verbose="2" annotations="JDK">
<classes>
- <class name="org.jboss.portal.test.selenium.portal.PortletDefinitionsTestCase"></class></classes>
+ <class name="org.jboss.portal.test.selenium.cms.CMSDirectoryTestCase"></class></classes>
</test>
- <test name="org.jboss.portal.test.selenium.portal.PortletInstancesTestCase"
+ <test name="org.jboss.portal.test.selenium.cms.CMSFileUploadTestCase"
verbose="2" annotations="JDK">
<classes>
- <class name="org.jboss.portal.test.selenium.portal.PortletInstancesTestCase"></class></classes>
+ <class name="org.jboss.portal.test.selenium.cms.CMSFileUploadTestCase"></class></classes>
</test>
<test name="org.jboss.portal.test.selenium.cms.CMSArchiveUploadTestCase"
17 years, 2 months
JBoss Portal SVN: r12827 - in branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests: src/org/jboss/portal/test/selenium and 2 other directories.
by portal-commits@lists.jboss.org
Author: vrockai
Date: 2009-02-17 05:44:45 -0500 (Tue, 17 Feb 2009)
New Revision: 12827
Added:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/EndtoEndPortalAdminTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/usecaseng.xml
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/build.xml
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserLoginTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/WSRPTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSDirectoryTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/AdminPortalTestCase.java
Log:
portal end to end test
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/build.xml 2009-02-16 05:00:41 UTC (rev 12826)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/build.xml 2009-02-17 10:44:45 UTC (rev 12827)
@@ -1,184 +1,212 @@
+
<project name="Tests" default="compile" basedir="." xmlns:server="http://jboss.org/ns/test/ant/server">
- <property environment="env" />
+ <property environment="env" />
- <property name="workspace" location="build.xml" />
- <property name="java.home" location="${env.JAVA_HOME}" />
+ <property name="workspace" location="build.xml" />
+ <property name="java.home" location="${env.JAVA_HOME}" />
- <property name="suitename" location="testng-files" />
- <property name="testname" location="testng-files" />
+ <property name="suitename" location="testng-files" />
+ <property name="testname" location="testng-files" />
- <property name="testng.dir" location="testng-files" />
- <property name="testng.output.dir" location="test-output" />
- <property name="test.build.dir" location="output/classes" />
- <property name="test.src.dir" location="src" />
- <property name="lib.dir" location="lib" />
- <property name="hudson.lib.dir" location="/qa/tools/opt/" />
- <property name="jboss-test.jar" location="${hudson.lib.dir}/jboss-test.jar" />
- <available file="${jboss-test.jar}" property="jboss-test.jar.present" />
- <property name="junit.report.dir" location="test-report" />
+ <property name="testng.dir" location="testng-files" />
+ <property name="testng.output.dir" location="test-output" />
+ <property name="test.build.dir" location="output/classes" />
+ <property name="test.src.dir" location="src" />
+ <property name="lib.dir" location="lib" />
+ <property name="hudson.lib.dir" location="/qa/tools/opt/" />
+ <property name="jboss-test.jar" location="${hudson.lib.dir}/jboss-test.jar" />
+ <available file="${jboss-test.jar}" property="jboss-test.jar.present" />
+ <property name="junit.report.dir" location="test-report" />
- <property name="selsrv.dir" location="selenium-rc-server" />
- <property name="node0" value="localhost" />
- <property name="jboss.test.home" value="${env.JBOSS_TEST_HOME}" />
- <property name="jboss.home" value="${env.JBOSS_HOME}" />
- <property name="jboss.test.jar" value="lib/jboss-test.jar" />
- <property name="jboss.portal.dir" value="${env.JBOSS_UNZIPED_DIR}" />
- <property name="portal_archive" value="${env.JBOSS_ARCHIVE}" />
- <property name="portal.instance" value="default" />
+ <property name="selsrv.dir" location="selenium-rc-server" />
+ <property name="node0" value="localhost" />
+ <property name="jboss.test.home" value="${env.JBOSS_TEST_HOME}" />
+ <property name="jboss.home" value="${env.JBOSS_HOME}" />
+ <property name="jboss.test.jar" value="lib/jboss-test.jar" />
+ <property name="jboss.portal.dir" value="${env.JBOSS_UNZIPED_DIR}" />
+ <property name="portal_archive" value="${env.JBOSS_ARCHIVE}" />
+ <property name="portal.instance" value="default" />
- <path id="jboss.test.classpath">
- <pathelement path="${jboss.test.jar}" />
- </path>
+ <property name="test.suite" value="testng.xml" />
+ <property name="usecase.suite" value="usecaseng.xml" />
- <path id="libraries.cp">
- <fileset dir="${lib.dir}">
- <include name="*.jar" />
- </fileset>
+ <path id="jboss.test.classpath">
+ <pathelement path="${jboss.test.jar}" />
+ </path>
- </path>
+ <path id="libraries.cp">
+ <fileset dir="${lib.dir}">
+ <include name="*.jar" />
+ </fileset>
- <path id="test.cp">
- <pathelement location="${test.build.dir}" />
- <path refid="libraries.cp" />
- </path>
+ </path>
- <taskdef name="testng" classpathref="libraries.cp" classname="org.testng.TestNGAntTask" />
- <taskdef name="config" classname="org.jboss.ant.taskdefs.server.ConfigManagerTask" uri="http://jboss.org/ns/test/ant/server" loaderref="server.loader">
- <classpath id="server.taskdef.classpath">
- <path refid="jboss.test.classpath" />
- </classpath>
- </taskdef>
- <taskdef name="start" classname="org.jboss.ant.taskdefs.server.StartServerTask" uri="http://jboss.org/ns/test/ant/server" loaderref="server.loader">
- <classpath refid="server.taskdef.classpath" />
- </taskdef>
- <taskdef name="stop" classname="org.jboss.ant.taskdefs.server.StopServerTask" uri="http://jboss.org/ns/test/ant/server" loaderref="server.loader">
- <classpath refid="server.taskdef.classpath" />
- </taskdef>
+ <path id="test.cp">
+ <pathelement location="${test.build.dir}" />
+ <path refid="libraries.cp" />
+ </path>
- <target name="init">
- <echo message="Browser : ${browser}" />
- <echo message="Screenshot : ${screenshot}" />
- <echo message="Deleting testng report directory" />
- <delete dir="${testng.output.dir}" />
- </target>
+ <taskdef name="testng" classpathref="libraries.cp" classname="org.testng.TestNGAntTask" />
+ <taskdef name="config" classname="org.jboss.ant.taskdefs.server.ConfigManagerTask" uri="http://jboss.org/ns/test/ant/server" loaderref="server.loader">
+ <classpath id="server.taskdef.classpath">
+ <path refid="jboss.test.classpath" />
+ </classpath>
+ </taskdef>
+ <taskdef name="start" classname="org.jboss.ant.taskdefs.server.StartServerTask" uri="http://jboss.org/ns/test/ant/server" loaderref="server.loader">
+ <classpath refid="server.taskdef.classpath" />
+ </taskdef>
+ <taskdef name="stop" classname="org.jboss.ant.taskdefs.server.StopServerTask" uri="http://jboss.org/ns/test/ant/server" loaderref="server.loader">
+ <classpath refid="server.taskdef.classpath" />
+ </taskdef>
+ <target name="init">
+ <echo message="Browser : ${browser}" />
+ <echo message="Screenshot : ${screenshot}" />
+ <echo message="Deleting testng report directory" />
+ <delete dir="${testng.output.dir}" />
+ </target>
- <target name="compile" depends="">
- <echo message="Compiling testsuite" />
- <mkdir dir="${test.build.dir}" />
- <javac srcdir="${test.src.dir}" destdir="${test.build.dir}" classpathref="libraries.cp" debug="on" />
- </target>
- <target name="run-src">
- <echo message="Starting Selenium Remote Control" />
- <java jar="${selsrv.dir}/selenium-server.jar" fork="true" spawn="true">
- <arg value="-multiWindow" />
- <arg value="-port" />
- <arg value="44444" />
- <arg value="-log" />
- <arg value="selenium.log" />
- <arg value="-debug" />
- <arg value="-userExtensions" />
- <arg value="${selsrv.dir}/user-extensions.js" />
- </java>
- <sleep seconds="20" />
- </target>
+ <target name="compile" depends="">
+ <echo message="Compiling testsuite" />
+ <mkdir dir="${test.build.dir}" />
+ <javac srcdir="${test.src.dir}" destdir="${test.build.dir}" classpathref="libraries.cp" debug="on" />
+ </target>
- <target name="stop-src">
- <get taskname="selenium-shutdown" src="http://localhost:44444/selenium-server/driver/?cmd=shutDown" dest="result.txt" ignoreerrors="true" />
- <echo taskname="selenium-shutdown" message="DGF Errors during shutdown are expected" />
- </target>
+ <target name="run-src">
+ <echo message="Starting Selenium Remote Control" />
+ <java jar="${selsrv.dir}/selenium-server.jar" fork="true" spawn="true">
+ <arg value="-multiWindow" />
+ <arg value="-port" />
+ <arg value="44444" />
+ <arg value="-log" />
+ <arg value="selenium.log" />
+ <arg value="-debug" />
+ <arg value="-userExtensions" />
+ <arg value="${selsrv.dir}/user-extensions.js" />
+ </java>
+ <sleep seconds="20" />
+ </target>
- <target name="copyApps">
- <echo message="Copying userInterceptor portlet into the ${portal.instance} server" />
- <copy file="apps/userDetail-portlet.war" tofile="${jboss.home}/server/${portal.instance}/deploy/userDetail-portlet.war" />
- </target>
+ <target name="stop-src">
+ <get taskname="selenium-shutdown" src="http://localhost:44444/selenium-server/driver/?cmd=shutDown" dest="result.txt" ignoreerrors="true" />
+ <echo taskname="selenium-shutdown" message="DGF Errors during shutdown are expected" />
+ </target>
- <target name="clean">
- <echo message="Going to delete directory ${test.build.dir}" />
- <delete dir="${test.build.dir}" />
- </target>
+ <target name="copyApps">
+ <echo message="Copying userInterceptor portlet into the ${portal.instance} server" />
+ <copy file="apps/userDetail-portlet.war" tofile="${jboss.home}/server/${portal.instance}/deploy/userDetail-portlet.war" />
+ </target>
- <server:config javaHome="${java.home}" jbossHome="${jboss.home}">
- <server name="${portal.instance}" host="${node0}">
+ <target name="clean">
+ <echo message="Going to delete directory ${test.build.dir}" />
+ <delete dir="${test.build.dir}" />
+ </target>
+
+ <server:config javaHome="${java.home}" jbossHome="${jboss.home}">
+ <server name="${portal.instance}" host="${node0}">
<!-- jvmarg value="${jpda.cmdline}" / -->
- <jvmarg value="-Xmx512m" />
- <jvmarg value="-XX:MaxPermSize=128m" />
- <sysproperty key="java.endorsed.dirs" value="${jboss.home}/lib/endorsed" />
- </server>
- </server:config>
+ <jvmarg value="-Xmx512m" />
+ <jvmarg value="-XX:MaxPermSize=128m" />
+ <sysproperty key="java.endorsed.dirs" value="${jboss.home}/lib/endorsed" />
+ </server>
+ </server:config>
- <target name="cleanup">
- <echo message="Cleaning up..." />
- <antcall target="stop-src" />
+ <target name="cleanup">
+ <echo message="Cleaning up..." />
+ <antcall target="stop-src" />
- </target>
+ </target>
- <target name="run-and-build" depends="init, compile, run-src">
- <echo message="Starting portal instance : ${portal.instance}" />
- <server:start name="${portal.instance}" />
+ <target name="run-and-build" depends="init, compile, run-src">
+ <echo message="Starting portal instance : ${portal.instance}" />
+ <server:start name="${portal.instance}" />
- <echo message="Runing TestNG" />
- <mkdir dir="test-output" />
- <testng classpathref="test.cp" sourcedir="${test.src.dir}" outputdir="test-output" listeners="org.testng.reporters.JUnitXMLReporter" suitename="SeleniumSuite">
+ <echo message="Runing TestNG" />
+ <mkdir dir="test-output" />
+ <testng classpathref="test.cp" sourcedir="${test.src.dir}" outputdir="test-output" listeners="org.testng.reporters.JUnitXMLReporter" suitename="SeleniumSuite">
- <xmlfileset dir="." includes="testng.xml" />
+ <xmlfileset dir="." includes="${testng.suite}" />
+ <sysproperty key="browser" value="${browser}" />
+ <sysproperty key="screenshot" value="${screenshot}" />
+ <sysproperty key="workspace" value="${workspace}" />
+ <sysproperty key="userCount" value="${userCount}" />
+ <sysproperty key="html-src" value="${html-src}" />
+ <jvmarg value="-ea" />
- <!--classfileset dir="${test.build.dir}"
- includes="org/jboss/portal/test/selenium/*Test.class" / -->
- <sysproperty key="browser" value="${browser}" />
- <sysproperty key="screenshot" value="${screenshot}" />
- <sysproperty key="workspace" value="${workspace}" />
- <sysproperty key="userCount" value="${userCount}" />
- <sysproperty key="html-src" value="${html-src}" />
- <jvmarg value="-ea" />
+ </testng>
+ <echo message="Stoping portal instance : ${portal.instance}" />
+ <server:stop name="${portal.instance}" />
+ <antcall target="cleanup" />
+ </target>
- </testng>
- <echo message="Stoping portal instance : ${portal.instance}" />
- <server:stop name="${portal.instance}" />
- <antcall target="cleanup" />
- </target>
+ <target name="single-test" depends="init, compile, run-src, copyApps">
+ <echo message="Runing TestNG" />
- <target name="single-test" depends="init, compile, run-src, copyApps">
- <echo message="Runing TestNG" />
+ <mkdir dir="test-output" />
+ <testng classpathref="test.cp" sourcedir="${test.src.dir}" outputdir="${testng.output.dir}" listeners="org.jboss.portal.test.selenium.JBossSeleniumTestListener" suitename="SeleniumSingleTest" verbose="2">
- <mkdir dir="test-output" />
- <testng classpathref="test.cp" sourcedir="${test.src.dir}" outputdir="${testng.output.dir}" listeners="org.jboss.portal.test.selenium.JBossSeleniumTestListener" suitename="SeleniumSingleTest" verbose="2">
+ <classfileset dir="${test.build.dir}" includes="${testname}" />
+ <sysproperty key="browser" value="${browser}" />
+ <sysproperty key="screenshot" value="${screenshot}" />
+ <sysproperty key="workspace" value="${workspace}" />
+ <sysproperty key="userCount" value="${userCount}" />
+ <sysproperty key="html-src" value="${html-src}" />
- <classfileset dir="${test.build.dir}" includes="${testname}" />
- <sysproperty key="browser" value="${browser}" />
- <sysproperty key="screenshot" value="${screenshot}" />
- <sysproperty key="workspace" value="${workspace}" />
- <sysproperty key="userCount" value="${userCount}" />
- <sysproperty key="html-src" value="${html-src}" />
+ <jvmarg value="-ea" />
+ </testng>
+ <antcall target="cleanup" />
- <jvmarg value="-ea" />
- </testng>
- <antcall target="cleanup" />
+ </target>
- </target>
+ <target name="selenium-test" depends="init, compile, run-src, copyApps">
+ <echo message="Runing TestNG" />
- <target name="selenium-test" depends="init, compile, run-src, copyApps">
- <echo message="Runing TestNG" />
+ <mkdir dir="test-output" />
+ <testng classpathref="test.cp" sourcedir="${test.src.dir}" outputdir="${testng.output.dir}" suitename="SeleniumSuite">
- <mkdir dir="test-output" />
- <testng classpathref="test.cp" sourcedir="${test.src.dir}" outputdir="${testng.output.dir}" suitename="SeleniumSuite">
+ <xmlfileset dir="." includes="${test.suite}" />
- <xmlfileset dir="." includes="testng.xml" />
+ <sysproperty key="browser" value="${browser}" />
+ <sysproperty key="screenshot" value="${screenshot}" />
+ <sysproperty key="workspace" value="${workspace}" />
+ <sysproperty key="userCount" value="${userCount}" />
+ <sysproperty key="html-src" value="${html-src}" />
- <sysproperty key="browser" value="${browser}" />
- <sysproperty key="screenshot" value="${screenshot}" />
- <sysproperty key="workspace" value="${workspace}" />
- <sysproperty key="userCount" value="${userCount}" />
- <sysproperty key="html-src" value="${html-src}" />
+ <jvmarg value="-ea" />
- <jvmarg value="-ea" />
+ </testng>
+ <antcall target="cleanup" />
+ </target>
- </testng>
- <antcall target="cleanup" />
- </target>
+ <target name="selenium-usecase" depends="init, compile, run-src, copyApps">
+ <echo message="Runing TestNG" />
+ <mkdir dir="test-output" />
+ <testng classpathref="test.cp" sourcedir="${test.src.dir}" outputdir="${testng.output.dir}" suitename="SeleniumSuite">
+
+ <xmlfileset dir="." includes="${usecase.suite}" />
+
+ <sysproperty key="browser" value="${browser}" />
+ <sysproperty key="screenshot" value="${screenshot}" />
+ <sysproperty key="workspace" value="${workspace}" />
+ <sysproperty key="userCount" value="${userCount}" />
+ <sysproperty key="html-src" value="${html-src}" />
+
+ <jvmarg value="-ea" />
+
+ </testng>
+ <antcall target="cleanup" />
+ </target>
+
+ <target name="archive" >
+ <!--<touch file="touchme.txt"/>-->
+ <echo file="touchme.txt" message="pipik2"/>
+ <genkey alias="apache-group" storepass="secret" dname="CN=Ant Group, OU=Jakarta Division, O=Apache.org, C=US"/>
+ <echo message=""/>
+ </target>
+
</project>
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java 2009-02-16 05:00:41 UTC (rev 12826)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java 2009-02-17 10:44:45 UTC (rev 12827)
@@ -1,10 +1,7 @@
package org.jboss.portal.test.selenium;
-import java.io.BufferedWriter;
-import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
-import java.io.PrintWriter;
import java.util.Properties;
import org.testng.Assert;
@@ -18,258 +15,228 @@
* @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
*/
public class JBossPortalSeleniumTestCase {
- public static final String LINK_LOGOUT = "link=Logout";
- public static final String SUBMIT_LOGIN = "login";
- public static final String ADDR_PORTAL = "/portal/";
- public static final String FRAME_LOGIN_CONTENT = "login-content";
- public static final String LINK_LOGIN = "link=Login";
- public static final String INPUT_PASSWORD = "j_password";
- public static final String INPUT_USERNAME = "j_username";
- protected Properties props;
- protected Selenium selenium;
- // Generic timeout in miliseconds
- protected static final String PAGE_LOAD = "2400000";
+ public static final String LINK_LOGOUT = "link=Logout";
+ public static final String SUBMIT_LOGIN = "login";
+ public static final String ADDR_PORTAL = "/portal/";
+ public static final String FRAME_LOGIN_CONTENT = "login-content";
+ public static final String LINK_LOGIN = "link=Login";
+ public static final String INPUT_PASSWORD = "j_password";
+ public static final String INPUT_USERNAME = "j_username";
+ protected Properties props;
+ protected Selenium selenium;
- // Element timeout in seconds
- protected static final int ELEM_TIMEOUT = 220;
+ // Generic timeout in miliseconds
+ protected static final String PAGE_LOAD = "2400000";
- public JBossPortalSeleniumTestCase() {
- try {
- this.props = getProperties();
- } catch (Exception e) {
- // TODO: handle exception
- }
- }
+ // Element timeout in seconds
+ protected static final int ELEM_TIMEOUT = 220;
- @BeforeClass
- public void setupChromeForLogin() throws Exception {
+ public JBossPortalSeleniumTestCase() {
+ try {
+ this.props = getProperties();
+ } catch (Exception e) {
+ // TODO: handle exception
+ }
+ }
- String browser = System.getProperty("browser");
+ @BeforeClass
+ public void setupChromeForLogin() throws Exception {
- selenium = new DefaultSelenium("127.0.0.1", 44444, browser, "http://localhost:8080/portal/");
+ String browser = System.getProperty("browser");
- JBossSeleniumTestListener.selenium = selenium;
- selenium.start();
- selenium.setTimeout(PAGE_LOAD);
- }
+ selenium = new DefaultSelenium("127.0.0.1", 44444, browser, "http://localhost:8080/portal/");
- @AfterClass
- public void tearDownInstaller() throws Exception {
- selenium.stop();
- }
+ JBossSeleniumTestListener.selenium = selenium;
+ selenium.start();
+ selenium.setTimeout(PAGE_LOAD);
+ }
- private Properties getProperties() throws IOException {
- ClassLoader cl = ClassLoader.getSystemClassLoader();
- InputStream is = cl.getResourceAsStream("org/jboss/portal/test/selenium/locator.properties");
- Properties props = new Properties();
- props.load(is);
- return props;
- }
+ @AfterClass
+ public void tearDownInstaller() throws Exception {
+ selenium.stop();
+ }
- protected String getProp(String prop, String subst) {
- if (subst == null || "".equals(subst)){
- subst = "Locator not set";
- }
-
- if (props == null)
- return subst;
- else
- return props.getProperty(prop) != null ? props.getProperty(prop) : subst;
- }
+ private Properties getProperties() throws IOException {
+ ClassLoader cl = ClassLoader.getSystemClassLoader();
+ InputStream is = cl.getResourceAsStream("org/jboss/portal/test/selenium/locator.properties");
+ Properties props = new Properties();
+ props.load(is);
+ return props;
+ }
- protected void clickIfVisible(String id) {
+ protected String getProp(String prop, String subst) {
+ if (subst == null || "".equals(subst)) {
+ subst = "Locator not set";
+ }
- if (selenium.isElementPresent(id)) {
- selenium.click(id);
+ if (props == null) {
+ return subst;
+ } else {
+ return props.getProperty(prop) != null ? props.getProperty(prop) : subst;
+ }
+ }
- selenium.waitForPageToLoad(PAGE_LOAD);
- }
- }
+ protected void clickIfVisible(String id) {
- protected void clickIfVisible(String id, String awaited) {
+ if (selenium.isElementPresent(id)) {
+ selenium.click(id);
- if (selenium.isElementPresent(id)) {
- selenium.click(id);
- selenium.waitForPageToLoad(PAGE_LOAD);
- }
- Assert.assertTrue(selenium.isTextPresent(awaited));
- }
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ }
+ }
- @Deprecated
- protected boolean findLink(String id) {
- for (String link : selenium.getAllLinks()) {
- if (link.equals(id)) {
- return true;
- }
- }
- for (String link : selenium.getAllFields()) {
- if (link.equals(id)) {
- return true;
- }
- }
+ protected int findTableRow(String tableLocation, String searchName, int searchCol) {
+ return Integer.valueOf(selenium.getEval("selenium.findTableRow(\"" + tableLocation + "\",'" + searchName + "'," + searchCol + ")"));
+ }
- return false;
- }
+ protected int countTableRows(String tableLocation) {
+ return Integer.valueOf(selenium.getEval("selenium.countTableRows(\"" + tableLocation + "\")"));
+ }
- protected int findTableRow(String tableLocation, String searchName, int searchCol) {
- return Integer.valueOf(selenium.getEval("selenium.findTableRow(\"" + tableLocation + "\",'" + searchName + "'," + searchCol + ")"));
- }
+ // TODO refactor
+ protected void safeSelect(String locator, String value) {
+ waitForElement(locator);
- protected int countTableRows(String tableLocation) {
- return Integer.valueOf(selenium.getEval("selenium.countTableRows(\"" + tableLocation + "\")"));
- }
+ for (int second = 0;; second++) {
+ if (second >= ELEM_TIMEOUT) {
+ Assert.fail("Element " + locator + " not found.");
+ }
+ try {
+ String[] opts = selenium.getSelectOptions(locator);
+ boolean isAvailable = false;
- // TODO refactor
- protected void safeSelect(String locator, String value) {
- waitForElement(locator);
+ for (String opt : opts) {
+ if (opt.equals(value)) {
+ isAvailable = true;
+ }
+ }
- for (int second = 0;; second++) {
- if (second >= ELEM_TIMEOUT) {
- Assert.fail("Element " + locator + " not found.");
- }
- try {
- String[] opts = selenium.getSelectOptions(locator);
- boolean isAvailable = false;
+ if (isAvailable) {
+ break;
+ }
+ } catch (Exception e) {
+ }
+ waitFor(1000);
+ }
- for (String opt : opts) {
- if (opt.equals(value)) {
- isAvailable = true;
- }
- }
+ selenium.select(locator, "label=" + value);
+ }
- if (isAvailable)
- break;
- } catch (Exception e) {
- }
- waitFor(1000);
- }
+ protected void clickAndWait(String locator) {
+ waitForElement(locator);
+ selenium.click(locator);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ }
- selenium.select(locator, "label=" + value);
- }
+ protected void openAndWait(String locator) {
+ selenium.open(locator);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ }
- protected void clickAndWait(String locator) {
- waitForElement(locator);
- selenium.click(locator);
- selenium.waitForPageToLoad(PAGE_LOAD);
- }
+ protected void selectIfNotSelected(String selector, String label) {
+ waitForElement(selector);
+ if (!selenium.getSelectedLabel(selector).equals(label)) {
+ selenium.select(selector, "label=" + label);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ }
+ }
- protected void openAndWait(String locator) {
- selenium.open(locator);
- selenium.waitForPageToLoad(PAGE_LOAD);
- }
+ protected boolean assertTextOrder(String text) {
+ return Boolean.valueOf(selenium.getEval("selenium.assertTextOrder(\"" + text + "\")"));
+ }
- protected void selectIfNotSelected(String selector, String label) {
- waitForElement(selector);
- if (!selenium.getSelectedLabel(selector).equals(label)) {
- selenium.select(selector, "label=" + label);
- selenium.waitForPageToLoad(PAGE_LOAD);
- }
- }
+ protected void waitFor(long time) {
+ try {
+ Thread.sleep(time);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
- protected boolean assertTextOrder(String text) {
- return Boolean.valueOf(selenium.getEval("selenium.assertTextOrder(\"" + text + "\")"));
- }
+ protected void waitForElement(String locator) {
+ for (int second = 0;; second++) {
+ if (second >= ELEM_TIMEOUT) {
+ Assert.fail("Element " + locator + " not found.");
+ }
+ try {
+ if (selenium.isElementPresent(locator)) {
+ break;
+ }
+ } catch (Exception e) {
+ }
+ waitFor(1000);
+ }
+ }
- protected void waitFor(long time) {
- try {
- Thread.sleep(time);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
+ protected void waitForElement(String locatorElem, String locatorLink, long timeToWait, long n) {
+ for (int i = 0;; i++) {
+ if (i >= n) {
+ Assert.fail("Element " + locatorElem + " not found.");
+ }
+ try {
+ if (selenium.isElementPresent(locatorElem)) {
+ break;
+ }
+ } catch (Exception e) {
+ }
+ waitFor(1000);
+ }
+ }
- protected void waitForElement(String locator) {
- for (int second = 0;; second++) {
- if (second >= ELEM_TIMEOUT) {
- Assert.fail("Element " + locator + " not found.");
- }
- try {
- if (selenium.isElementPresent(locator))
- break;
- } catch (Exception e) {
- }
- waitFor(1000);
- }
- }
+ public void waitForText(String text) {
+ for (int second = 0;; second++) {
+ if (second >= ELEM_TIMEOUT) {
+ Assert.fail("Text '" + text + "' not found.");
+ }
+ try {
+ if (selenium.isTextPresent(text)) {
+ break;
+ }
+ } catch (Exception e) {
+ }
+ waitFor(100);
+ }
+ }
- protected void waitForElement(String locatorElem, String locatorLink, long timeToWait, long n) {
- for (int i = 0;; i++) {
- if (i >= n) {
- Assert.fail("Element " + locatorElem + " not found.");
- }
- try {
- if (selenium.isElementPresent(locatorElem))
- break;
- } catch (Exception e) {
- }
- waitFor(1000);
- }
- }
+ protected void login(String username, String password) {
+ selenium.open(ADDR_PORTAL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- public void waitForText(String text) {
- for (int second = 0;; second++) {
- if (second >= ELEM_TIMEOUT) {
- Assert.fail("Text '" + text + "' not found.");
- }
- try {
- if (selenium.isTextPresent(text))
- break;
- } catch (Exception e) {
- }
- waitFor(100);
- }
- }
+ selenium.click(LINK_LOGIN);
+ selenium.selectFrame(FRAME_LOGIN_CONTENT);
- protected void login(String username, String password) {
- selenium.open(ADDR_PORTAL);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ waitForElement(INPUT_USERNAME);
+ waitForElement(INPUT_PASSWORD);
+ waitForElement(SUBMIT_LOGIN);
- selenium.click(LINK_LOGIN);
- selenium.selectFrame(FRAME_LOGIN_CONTENT);
+ selenium.type(INPUT_USERNAME, username);
+ selenium.type(INPUT_PASSWORD, password);
+ Assert.assertTrue(selenium.isElementPresent(SUBMIT_LOGIN));
+ selenium.click(SUBMIT_LOGIN);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent("Logged in as: " + username), "Not logged in, login message missing.");
+ }
- waitForElement(INPUT_USERNAME);
- waitForElement(INPUT_PASSWORD);
- waitForElement(SUBMIT_LOGIN);
+ protected void logout() {
+ selenium.open(ADDR_PORTAL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isElementPresent(LINK_LOGOUT));
+ selenium.click(LINK_LOGOUT);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertFalse(selenium.isTextPresent("Logged in as:"), "Not logged in, login message missing.");
+ Assert.assertTrue(selenium.isElementPresent("Link=Login"), "Login link not present.");
+ }
- selenium.type(INPUT_USERNAME, username);
- selenium.type(INPUT_PASSWORD, password);
- Assert.assertTrue(selenium.isElementPresent(SUBMIT_LOGIN));
- selenium.click(SUBMIT_LOGIN);
- selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("Logged in as: " + username), "Not logged in, login message missing.");
- }
-
- protected void logout() {
- selenium.open(ADDR_PORTAL);
- selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isElementPresent(LINK_LOGOUT));
- selenium.click(LINK_LOGOUT);
- selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertFalse(selenium.isTextPresent("Logged in as:"), "Not logged in, login message missing.");
- Assert.assertTrue(selenium.isElementPresent("Link=Login"), "Login link not present.");
- }
-
- protected void logoutIfPossible() {
- selenium.open(ADDR_PORTAL);
- selenium.waitForPageToLoad(PAGE_LOAD);
- if (selenium.isElementPresent(LINK_LOGOUT)) {
- selenium.click(LINK_LOGOUT);
- selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertFalse(selenium.isTextPresent("Logged in as:"), "Not logged in, login message missing.");
- Assert.assertTrue(selenium.isElementPresent("Link=Login"), "Login link not present.");
- }
- }
-
- protected void savePage(String filename) {
- try {
- PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(filename)));
- out.print(selenium.getHtmlSource());
- out.close();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
+ protected void logoutIfPossible() {
+ selenium.open(ADDR_PORTAL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ if (selenium.isElementPresent(LINK_LOGOUT)) {
+ selenium.click(LINK_LOGOUT);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertFalse(selenium.isTextPresent("Logged in as:"), "Not logged in, login message missing.");
+ Assert.assertTrue(selenium.isElementPresent("Link=Login"), "Login link not present.");
+ }
+ }
}
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserLoginTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserLoginTestCase.java 2009-02-16 05:00:41 UTC (rev 12826)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserLoginTestCase.java 2009-02-17 10:44:45 UTC (rev 12827)
@@ -4,7 +4,6 @@
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
-import com.thoughtworks.selenium.Selenium;
/**
* @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
@@ -16,14 +15,14 @@
public static final String casePfx = "";
private final String ADR_PORTAL = getProp(casePfx+"adr.portal","/portal");
- private final String FRM_MAIN = "relative=up";
- private final String SUB_CANCEL = "cancel";
- private final String LNK_LOGOUT = "link=Logout";
- private final String SUB_LOGIN = "login";
- private final String INP_PASSWORD = "xpath=id('j_password')";
- private final String INP_USERNAME = "xpath=id('j_username')";
- private final String FRM_LOGINFORM = "login-content";
- private final String LNK_LOGIN = "link=Login";
+ private final String FRM_MAIN = getProp(casePfx+"frm.main","relative=up");
+ private final String SUB_CANCEL = getProp(casePfx+"sub.portal","cancel");
+ private final String LNK_LOGOUT = getProp(casePfx+"adr.portal","link=Logout");
+ private final String SUB_LOGIN = getProp(casePfx+"adr.portal","login");
+ private final String INP_PASSWORD = getProp(casePfx+"adr.portal","xpath=id('j_password')");
+ private final String INP_USERNAME = getProp(casePfx+"adr.portal","xpath=id('j_username')");
+ private final String FRM_LOGINFORM = getProp(casePfx+"adr.portal","login-content");
+ private final String LNK_LOGIN = getProp(casePfx+"adr.portal","link=Login");
@AfterClass(enabled = true)
public void logoutIfNeeded()
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/WSRPTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/WSRPTestCase.java 2009-02-16 05:00:41 UTC (rev 12826)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/WSRPTestCase.java 2009-02-17 10:44:45 UTC (rev 12827)
@@ -68,7 +68,6 @@
selenium.click(SUBMIT_CREATECONS);
selenium.waitForPageToLoad(PAGE_LOAD);
- savePage("1.html");
selenium.type(INPUT_CACHEEXP, "600");
selenium.type(INPUT_CONSWSDL, "http://wsrp.bea.com:7001/producer/producer?WSDL");
@@ -221,8 +220,8 @@
selenium.click("link=WSRP");
selenium.waitForPageToLoad(PAGE_LOAD);
- clickIfVisible(ID_LINK_PRODCONF,"Producer configuration");
-
+ clickIfVisible(ID_LINK_PRODCONF);
+ Assert.assertTrue(selenium.isTextPresent("Producer configuration"));
clickAndWait(SUBMIT_ADDPROP_INIT);
selenium.type(INPUT_PROPNAME, "testProp");
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSDirectoryTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSDirectoryTestCase.java 2009-02-16 05:00:41 UTC (rev 12826)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSDirectoryTestCase.java 2009-02-17 10:44:45 UTC (rev 12827)
@@ -174,7 +174,6 @@
selenium.click("link=" + defaultDirName);
selenium.click("submit");
selenium.waitForPageToLoad(PAGE_LOAD);
- savePage("2.html");
Assert.assertEquals("copySrc", selenium.getText("//div[@id='center']/div/div/ul/li[5]"));
Assert.assertTrue(selenium.isElementPresent("link=" + defaultDirName));
selenium.click("link=Home");
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileTestCase.java 2009-02-16 05:00:41 UTC (rev 12826)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileTestCase.java 2009-02-17 10:44:45 UTC (rev 12827)
@@ -317,7 +317,6 @@
selenium.click("//div[@id='center']/div/div/div[3]/table/tbody/tr[3]/td[2]/form/select/option[4]");
selenium.click("//div[@id='center']/div/div/div[3]/table/tbody/tr[3]/td[2]/form/input");
selenium.waitForPageToLoad(PAGE_LOAD);
- savePage("3.html");
Assert.assertTrue(selenium.isTextPresent("Confirm Deletion of /newFile"));
Assert.assertTrue(selenium.isTextPresent("WARNING! You will not be able to undo these change!"));
Assert.assertTrue(selenium.isTextPresent("Are you sure you want to delete this resource?"));
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/AdminPortalTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/AdminPortalTestCase.java 2009-02-16 05:00:41 UTC (rev 12826)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/AdminPortalTestCase.java 2009-02-17 10:44:45 UTC (rev 12827)
@@ -11,361 +11,352 @@
/**
* @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
*/
-@Test(groups = { "admin_portal" }, enabled = true, description = "Partal administrating.")
+@Test(groups = {"admin_portal"}, enabled = true, description = "Partal administrating.")
public class AdminPortalTestCase extends JBossPortalSeleniumTestCase {
- private static final String SUB_LAYOUT_ADD_CENTER = "//input[contains(@id,'layoutForm:a_center')]";
- private static final String INP_WINDOW_NAME = "//input[contains(@id,'windowForm:windowName')]";
- private static final String SUBMIT_RENAME_PORTAL = "//input[contains(@id,'renameForm:rename')]";
- private static final String INPUT_RENAME_PORTAL = "//input[contains(@id,'renameForm:newName')]";
- private static final String SUBMIT_DELETE_PORTAL_CONF = "//input[contains(@id,'delete-view:confirm-form:delete')]";
- private static final String INPUT_SUBMIT_PAGECREATE = "//input[contains(@id,'create-page-form:create-page')]";
- private static final String INPUT_PAGENAME = "//input[contains(@id,'create-page-form:pageName')]";
- private static final String INPUT_PORTALNAME = "//input[contains(@id,'create-portal-form:name')]";
- private static final String INPUT_SUBMIT_CREATEPORTAL = "//input[contains(@id,'create-portal-form:create-portal')]";
+ private static final String SUB_LAYOUT_ADD_CENTER = "//input[contains(@id,'layoutForm:a_center')]";
+ private static final String INP_WINDOW_NAME = "//input[contains(@id,'windowForm:windowName')]";
+ private static final String SUBMIT_RENAME_PORTAL = "//input[contains(@id,'renameForm:rename')]";
+ private static final String INPUT_RENAME_PORTAL = "//input[contains(@id,'renameForm:newName')]";
+ private static final String SUBMIT_DELETE_PORTAL_CONF = "//input[contains(@id,'delete-view:confirm-form:delete')]";
+ private static final String INPUT_SUBMIT_PAGECREATE = "//input[contains(@id,'create-page-form:create-page')]";
+ private static final String INPUT_PAGENAME = "//input[contains(@id,'create-page-form:pageName')]";
+ private static final String INPUT_PORTALNAME = "//input[contains(@id,'create-portal-form:name')]";
+ private static final String INPUT_SUBMIT_CREATEPORTAL = "//input[contains(@id,'create-portal-form:create-portal')]";
+ private final String TAB_PORTALOBJ_ID = "Link=Admin";
+ private final String LINK_PORTALS_ID = "link=*Portal Objects*";
+ private final String LINK_PORTAL_HOME = "//a[contains(@id,'obj-temp-form:object-link-0')]";
+ private final String TABLE_PORTAL_ADMIN = "//table[contains(@id,'obj-nav-form:portal-datatable')]";
+ private final String POR_TL_MAIN = "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:object-iid-link'')]";
+ private final String POR_TL_SECURITY = "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:security-link'')]";
+ private final String POR_TL_PROPERTIES = "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:prop-link'')]";
+ private final String POR_TL_THEME = "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:theme-link'')]";
+ private final String POR_TL_RENAME = "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:rename'')]";
+ private final String POR_TL_DELETE = "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:delete'')]";
+ private final String POR_TL_MAKEDEF = "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:default-link'')]";
+ private final String TABLE_PORTALPAGE_ADMIN = "//table[contains(@id,'obj-nav-form:pages-datatable')]";
+ private final String PAG_TL_MAIN = "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:object-link'')]";
+ private final String PAG_TL_LAYOUT = "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:edit-page-layout'')]";
+ private final String PAG_TL_SECURITY = "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:security-link'')]";
+ private final String PAG_TL_PROPERTIES = "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:prop-link'')]";
+ private final String PAG_TL_THEME = "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:theme-link'')]";
+ private final String PAG_TL_RENAME = "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:rename-link'')]";
+ private final String PAG_TL_DISPLAY = "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:rename-display'')]";
+ private final String PAG_TL_DELETE = "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:delete-link'')]";
+ private final String PAG_TL_MAKEDEF = "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:default-link'')]";
- private final String TAB_PORTALOBJ_ID = "Link=Admin";
+ @BeforeMethod(groups = {"log"})
+ public void loginBeforeTest() {
+ logoutIfPossible();
+ login("admin", "admin");
+ }
- private final String LINK_PORTALS_ID = "link=*Portal Objects*";
- private final String LINK_PORTAL_HOME = "//a[contains(@id,'obj-temp-form:object-link-0')]";
-
- private final String TABLE_PORTAL_ADMIN = "//table[contains(@id,'obj-nav-form:portal-datatable')]";
- private final String POR_TL_MAIN = "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:object-iid-link'')]";
- private final String POR_TL_SECURITY = "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:security-link'')]";
- private final String POR_TL_PROPERTIES = "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:prop-link'')]";
- private final String POR_TL_THEME = "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:theme-link'')]";
- private final String POR_TL_RENAME = "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:rename'')]";
- private final String POR_TL_DELETE = "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:delete'')]";
- private final String POR_TL_MAKEDEF = "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:default-link'')]";
+ @AfterMethod(groups = {"log"})
+ public void logoutAfterTest() {
+ }
- private final String TABLE_PORTALPAGE_ADMIN = "//table[contains(@id,'obj-nav-form:pages-datatable')]";
- private final String PAG_TL_MAIN = "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:object-link'')]";
- private final String PAG_TL_LAYOUT = "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:edit-page-layout'')]";
- private final String PAG_TL_SECURITY = "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:security-link'')]";
- private final String PAG_TL_PROPERTIES = "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:prop-link'')]";
- private final String PAG_TL_THEME = "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:theme-link'')]";
- private final String PAG_TL_RENAME = "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:rename-link'')]";
- private final String PAG_TL_DISPLAY = "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:rename-display'')]";
- private final String PAG_TL_DELETE = "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:delete-link'')]";
- private final String PAG_TL_MAKEDEF = "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:default-link'')]";
+ @Test(enabled = true)
+ public void testPortalCreate() {
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
- @BeforeMethod(groups = { "log" })
- public void loginBeforeTest() {
- logoutIfPossible();
- login("admin", "admin");
- }
+ clickIfVisible(TAB_PORTALOBJ_ID);
+ clickIfVisible(LINK_PORTALS_ID);
- @AfterMethod(groups = { "log" })
- public void logoutAfterTest() {
-
- }
+ final String portalName = "TestPortal";
+ Assert.assertFalse(selenium.isTextPresent(portalName), "Not created page already exist.");
- @Test(enabled = true)
- public void testPortalCreate() {
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.type(INPUT_PORTALNAME, portalName);
+ selenium.click(INPUT_SUBMIT_CREATEPORTAL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- clickIfVisible(TAB_PORTALOBJ_ID);
- clickIfVisible(LINK_PORTALS_ID);
-
- final String portalName = "TestPortal";
- Assert.assertFalse(selenium.isTextPresent(portalName), "Not created page already exist.");
+ Assert.assertTrue(selenium.isTextPresent(portalName));
- selenium.type(INPUT_PORTALNAME, portalName);
- selenium.click(INPUT_SUBMIT_CREATEPORTAL);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ int r = findTableRow(TABLE_PORTAL_ADMIN, portalName, 0) - 1;
- Assert.assertTrue(selenium.isTextPresent(portalName));
+ Assert.assertTrue(selenium.isElementPresent(MessageFormat.format(POR_TL_MAIN, r)));
+ Assert.assertTrue(selenium.isElementPresent(MessageFormat.format(POR_TL_SECURITY, r)));
+ Assert.assertTrue(selenium.isElementPresent(MessageFormat.format(POR_TL_PROPERTIES, r)));
+ Assert.assertTrue(selenium.isElementPresent(MessageFormat.format(POR_TL_MAKEDEF, r)));
+ Assert.assertTrue(selenium.isElementPresent(MessageFormat.format(POR_TL_RENAME, r)));
+ Assert.assertTrue(selenium.isElementPresent(MessageFormat.format(POR_TL_THEME, r)));
+ }
- int r = findTableRow(TABLE_PORTAL_ADMIN, portalName, 0) - 1;
+ @Test(enabled = true, dependsOnMethods = {"testPortalCreate"})
+ public void testPortalRename() {
+ // first create a portal
- Assert.assertTrue(selenium.isElementPresent(MessageFormat.format(POR_TL_MAIN, r)));
- Assert.assertTrue(selenium.isElementPresent(MessageFormat.format(POR_TL_SECURITY, r)));
- Assert.assertTrue(selenium.isElementPresent(MessageFormat.format(POR_TL_PROPERTIES, r)));
- Assert.assertTrue(selenium.isElementPresent(MessageFormat.format(POR_TL_MAKEDEF, r)));
- Assert.assertTrue(selenium.isElementPresent(MessageFormat.format(POR_TL_RENAME, r)));
- Assert.assertTrue(selenium.isElementPresent(MessageFormat.format(POR_TL_THEME, r)));
- }
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
- @Test(enabled = true, dependsOnMethods = { "testPortalCreate" })
- public void testPortalRename() {
- // first create a portal
-
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ clickIfVisible(TAB_PORTALOBJ_ID);
+ clickIfVisible(LINK_PORTALS_ID);
- clickIfVisible(TAB_PORTALOBJ_ID);
- clickIfVisible(LINK_PORTALS_ID);
-
- final String portalName = "TestRenPortal";
- Assert.assertFalse(selenium.isTextPresent(portalName), "Not created page already exist.");
+ final String portalName = "TestRenPortal";
+ Assert.assertFalse(selenium.isTextPresent(portalName), "Not created page already exist.");
- selenium.type(INPUT_PORTALNAME, portalName);
- selenium.click(INPUT_SUBMIT_CREATEPORTAL);
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- // then rename it
-
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.type(INPUT_PORTALNAME, portalName);
+ selenium.click(INPUT_SUBMIT_CREATEPORTAL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- clickIfVisible(TAB_PORTALOBJ_ID);
- clickIfVisible(LINK_PORTALS_ID);
+ // then rename it
- final String portalToRename = "TestRenPortal";
- Assert.assertTrue(selenium.isTextPresent(portalToRename));
- final String portalRenamed = "AestPortal";
- Assert.assertFalse(selenium.isTextPresent(portalRenamed), "Not created page already exist.");
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
- int r = findTableRow(TABLE_PORTAL_ADMIN, portalToRename, 0) - 1;
+ clickIfVisible(TAB_PORTALOBJ_ID);
+ clickIfVisible(LINK_PORTALS_ID);
- selenium.click(MessageFormat.format(POR_TL_RENAME, r));
- selenium.waitForPageToLoad(PAGE_LOAD);
+ final String portalToRename = "TestRenPortal";
+ Assert.assertTrue(selenium.isTextPresent(portalToRename));
+ final String portalRenamed = "AestPortal";
+ Assert.assertFalse(selenium.isTextPresent(portalRenamed), "Not created page already exist.");
- selenium.type(INPUT_RENAME_PORTAL, portalRenamed);
- selenium.click(SUBMIT_RENAME_PORTAL);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ int r = findTableRow(TABLE_PORTAL_ADMIN, portalToRename, 0) - 1;
- Assert.assertFalse(selenium.isTextPresent(portalToRename));
- Assert.assertTrue(selenium.isTextPresent(portalRenamed));
- }
+ selenium.click(MessageFormat.format(POR_TL_RENAME, r));
+ selenium.waitForPageToLoad(PAGE_LOAD);
- @Test(enabled = true, dependsOnMethods = { "testPortalCreate" })
- public void testPortalDelete() {
- // first create a portal
-
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.type(INPUT_RENAME_PORTAL, portalRenamed);
+ selenium.click(SUBMIT_RENAME_PORTAL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- clickIfVisible(TAB_PORTALOBJ_ID);
- clickIfVisible(LINK_PORTALS_ID);
-
- final String portalName = "TestDelete";
- Assert.assertFalse(selenium.isTextPresent(portalName), "Not created page already exist.");
+ Assert.assertFalse(selenium.isTextPresent(portalToRename));
+ Assert.assertTrue(selenium.isTextPresent(portalRenamed));
+ }
- selenium.type(INPUT_PORTALNAME, portalName);
- selenium.click(INPUT_SUBMIT_CREATEPORTAL);
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- // then delete it
-
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ @Test(enabled = true, dependsOnMethods = {"testPortalCreate"})
+ public void testPortalDelete() {
+ // first create a portal
- clickIfVisible(TAB_PORTALOBJ_ID);
- clickIfVisible(LINK_PORTALS_ID);
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
- final String portalToDelete = "TestDelete";
- selenium.type(INPUT_PORTALNAME, portalToDelete);
- selenium.click(INPUT_SUBMIT_CREATEPORTAL);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ clickIfVisible(TAB_PORTALOBJ_ID);
+ clickIfVisible(LINK_PORTALS_ID);
- Assert.assertTrue(selenium.isTextPresent(portalToDelete));
+ final String portalName = "TestDelete";
+ Assert.assertFalse(selenium.isTextPresent(portalName), "Not created page already exist.");
- int r = findTableRow(TABLE_PORTAL_ADMIN, portalToDelete, 0) - 1;
+ selenium.type(INPUT_PORTALNAME, portalName);
+ selenium.click(INPUT_SUBMIT_CREATEPORTAL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(MessageFormat.format(POR_TL_DELETE, r));
- selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("WARNING! You are about to delete the "+portalToDelete+" portal from the context!"));
- Assert.assertTrue(selenium.isTextPresent("Delete portal"));
- Assert.assertTrue(selenium.isTextPresent("Are you sure you want to delete this portal?"));
- selenium.click(SUBMIT_DELETE_PORTAL_CONF);
- selenium.waitForPageToLoad(PAGE_LOAD);
- //Assert.assertTrue(selenium.isTextPresent("TestDelete has successfully been destroyed"));
+ // then delete it
- clickIfVisible("link=Admin");
- clickIfVisible(TAB_PORTALOBJ_ID);
- Assert.assertFalse(selenium.isTextPresent(portalToDelete));
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
- }
+ clickIfVisible(TAB_PORTALOBJ_ID);
+ clickIfVisible(LINK_PORTALS_ID);
- @Test(enabled = true, dependsOnMethods = { "testPortalCreate" })
- public void testAddPage() {
+ final String portalToDelete = "TestDelete";
+ selenium.type(INPUT_PORTALNAME, portalToDelete);
+ selenium.click(INPUT_SUBMIT_CREATEPORTAL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- final String portalName = "TestAddPagePortal";
- final String portalPage = "tToAddPage";
-
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent(portalToDelete));
- clickIfVisible(TAB_PORTALOBJ_ID);
- clickIfVisible(LINK_PORTALS_ID);
+ int r = findTableRow(TABLE_PORTAL_ADMIN, portalToDelete, 0) - 1;
-
- selenium.type(INPUT_PORTALNAME, portalName);
- selenium.click(INPUT_SUBMIT_CREATEPORTAL);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(MessageFormat.format(POR_TL_DELETE, r));
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent("WARNING! You are about to delete the " + portalToDelete + " portal from the context!"));
+ Assert.assertTrue(selenium.isTextPresent("Delete portal"));
+ Assert.assertTrue(selenium.isTextPresent("Are you sure you want to delete this portal?"));
+ selenium.click(SUBMIT_DELETE_PORTAL_CONF);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ //Assert.assertTrue(selenium.isTextPresent("TestDelete has successfully been destroyed"));
- int r = findTableRow(TABLE_PORTAL_ADMIN, portalName, 0) - 1;
+ clickIfVisible("link=Admin");
+ clickIfVisible(TAB_PORTALOBJ_ID);
+ Assert.assertFalse(selenium.isTextPresent(portalToDelete));
- selenium.click(MessageFormat.format(POR_TL_MAIN, r));
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- Assert.assertFalse(selenium.isTextPresent(portalPage), "Portal page already present");
- Assert.assertTrue(selenium.isTextPresent("Create a page named:"));
+ }
- selenium.type(INPUT_PAGENAME, portalPage);
- selenium.click(INPUT_SUBMIT_PAGECREATE);
- selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent(portalPage));
- }
+ @Test(enabled = true, dependsOnMethods = {"testPortalCreate"})
+ public void testAddPage() {
- @Test(enabled = true, dependsOnMethods = { "testPortalCreate","testAddPage" })
- public void testRemovePage() {
-
- final String portalName = "TestRemovePagePortal";
- final String portalPage = "tRemPage";
+ final String portalName = "TestAddPagePortal";
+ final String portalPage = "tToAddPage";
- createPortal(portalName);
- createPage(portalName, portalPage);
-
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
- clickIfVisible(TAB_PORTALOBJ_ID);
- clickIfVisible(LINK_PORTALS_ID);
- clickIfVisible(LINK_PORTAL_HOME);
+ clickIfVisible(TAB_PORTALOBJ_ID);
+ clickIfVisible(LINK_PORTALS_ID);
- int r = findTableRow(TABLE_PORTAL_ADMIN, portalName, 0) - 1;
- selenium.click(MessageFormat.format(POR_TL_MAIN, r));
- selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.type(INPUT_PORTALNAME, portalName);
+ selenium.click(INPUT_SUBMIT_CREATEPORTAL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- r = findTableRow(TABLE_PORTALPAGE_ADMIN, portalPage, 0) - 1;
+ int r = findTableRow(TABLE_PORTAL_ADMIN, portalName, 0) - 1;
- selenium.click(MessageFormat.format(PAG_TL_DELETE, r));
- selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(MessageFormat.format(POR_TL_MAIN, r));
+ selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("Delete page"));
- Assert.assertTrue(selenium.isTextPresent("WARNING! You are about to delete the " + portalPage + " page from the " + portalName + " portal! "));
- Assert.assertTrue(selenium.isTextPresent("Are you sure you want to delete this page?"));
+ Assert.assertFalse(selenium.isTextPresent(portalPage), "Portal page already present");
+ Assert.assertTrue(selenium.isTextPresent("Create a page named:"));
- }
+ selenium.type(INPUT_PAGENAME, portalPage);
+ selenium.click(INPUT_SUBMIT_PAGECREATE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent(portalPage));
+ }
- @Test(enabled = true, dependsOnMethods = { "testPortalCreate", "testAddPage" })
- public void testCreateWindow() {
+ @Test(enabled = true, dependsOnMethods = {"testPortalCreate", "testAddPage"})
+ public void testRemovePage() {
- final String portalName = "toAddWindowPortal";
- final String pageName = "windowContainer";
- final String windowName = "myFancyWindow";
+ final String portalName = "TestRemovePagePortal";
+ final String portalPage = "tRemPage";
- createPortal(portalName);
- createPage(portalName, pageName);
+ createPortal(portalName);
+ createPage(portalName, portalPage);
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ clickIfVisible(TAB_PORTALOBJ_ID);
+ clickIfVisible(LINK_PORTALS_ID);
+ clickIfVisible(LINK_PORTAL_HOME);
- clickIfVisible(TAB_PORTALOBJ_ID);
- clickIfVisible(LINK_PORTALS_ID);
- clickIfVisible(LINK_PORTAL_HOME);
+ int r = findTableRow(TABLE_PORTAL_ADMIN, portalName, 0) - 1;
- int r = findTableRow(TABLE_PORTAL_ADMIN, portalName, 0) - 1;
- selenium.click(MessageFormat.format(POR_TL_MAIN, r));
- selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(MessageFormat.format(POR_TL_MAIN, r));
+ selenium.waitForPageToLoad(PAGE_LOAD);
- r = findTableRow(TABLE_PORTALPAGE_ADMIN, pageName, 0) - 1;
+ r = findTableRow(TABLE_PORTALPAGE_ADMIN, portalPage, 0) - 1;
- // click on the page layout
- selenium.click(MessageFormat.format(PAG_TL_LAYOUT, r));
-
- try {
- Thread.sleep(5000);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ selenium.click(MessageFormat.format(PAG_TL_DELETE, r));
+ selenium.waitForPageToLoad(PAGE_LOAD);
-
- selenium.click("link=Who's online portlet");
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- selenium.type(INP_WINDOW_NAME, windowName);
-
- selenium.click(SUB_LAYOUT_ADD_CENTER);
- selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent(windowName));
+ Assert.assertTrue(selenium.isTextPresent("Delete page"));
+ Assert.assertTrue(selenium.isTextPresent("WARNING! You are about to delete the " + portalPage + " page from the " + portalName + " portal! "));
+ Assert.assertTrue(selenium.isTextPresent("Are you sure you want to delete this page?"));
- selenium.open("/portal/auth/portal/mimikry");
- Assert.assertTrue(selenium.isTextPresent("Current users"));
+ }
- }
-
- @Test(enabled = true, dependsOnMethods={"testPortalCreate", "testAddPage"})
- public void testPageRename(){
- String portalName = "TestPortal";
- String pageName = "PageToRename";
-
- createPage("TestPortal", "PageToRename");
-
- openAndWait("/portal");
- clickAndWait("link=Admin");
+ @Test(enabled = true, dependsOnMethods = {"testPortalCreate", "testAddPage"})
+ public void testCreateWindow() {
- clickIfVisible(TAB_PORTALOBJ_ID);
- clickIfVisible(LINK_PORTALS_ID);
- //selenium.setSpeed("8000");
- clickIfVisible(LINK_PORTAL_HOME ,"Create a portal named:");
+ final String portalName = "toAddWindowPortal";
+ final String pageName = "windowContainer";
+ final String windowName = "myFancyWindow";
- int r = findTableRow(TABLE_PORTAL_ADMIN, portalName, 0) - 1;
+ createPortal(portalName);
+ createPage(portalName, pageName);
- clickAndWait(MessageFormat.format(POR_TL_MAIN, r));
+ selenium.open("/portal/");
+ selenium.waitForPageToLoad(PAGE_LOAD);
- r = findTableRow(TABLE_PORTALPAGE_ADMIN, pageName, 0) - 1;
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
- clickAndWait(MessageFormat.format(PAG_TL_RENAME, r));
+ clickIfVisible(TAB_PORTALOBJ_ID);
+ clickIfVisible(LINK_PORTALS_ID);
+ clickIfVisible(LINK_PORTAL_HOME);
- }
+ int r = findTableRow(TABLE_PORTAL_ADMIN, portalName, 0) - 1;
+ selenium.click(MessageFormat.format(POR_TL_MAIN, r));
+ selenium.waitForPageToLoad(PAGE_LOAD);
- @Test(enabled = false)
- public void testPageSecurity(){
-
- }
-
- @Test(enabled = false)
- public void testPageTheme(){
-
- }
-
- @Test(enabled = false)
- public void testPageLayout(){
-
- }
-
- private void createPortal(String name) {
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ r = findTableRow(TABLE_PORTALPAGE_ADMIN, pageName, 0) - 1;
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ // click on the page layout
+ selenium.click(MessageFormat.format(PAG_TL_LAYOUT, r));
- clickIfVisible(TAB_PORTALOBJ_ID);
- clickIfVisible(LINK_PORTALS_ID);
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
- selenium.type(INPUT_PORTALNAME, name);
- selenium.click(INPUT_SUBMIT_CREATEPORTAL);
- selenium.waitForPageToLoad(PAGE_LOAD);
- }
- private void createPage(String portalName, String pageName) {
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=Who's online portlet");
+ selenium.waitForPageToLoad(PAGE_LOAD);
- clickIfVisible(TAB_PORTALOBJ_ID);
- clickIfVisible(LINK_PORTALS_ID);
+ selenium.type(INP_WINDOW_NAME, windowName);
- int r = findTableRow(TABLE_PORTAL_ADMIN, portalName, 0) - 1;
+ selenium.click(SUB_LAYOUT_ADD_CENTER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent(windowName));
- selenium.click(MessageFormat.format(POR_TL_MAIN, r));
- selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.open("/portal/auth/portal/mimikry");
+ Assert.assertTrue(selenium.isTextPresent("Current users"));
- selenium.type(INPUT_PAGENAME, pageName);
- selenium.click(INPUT_SUBMIT_PAGECREATE);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ }
- }
+ @Test(enabled = true, dependsOnMethods = {"testPortalCreate", "testAddPage"})
+ public void testPageRename() {
+ String portalName = "TestPortal";
+ String pageName = "PageToRename";
+ createPage("TestPortal", "PageToRename");
+
+ openAndWait("/portal");
+ clickAndWait("link=Admin");
+
+ clickIfVisible(TAB_PORTALOBJ_ID);
+ clickIfVisible(LINK_PORTALS_ID);
+ //selenium.setSpeed("8000");
+ clickIfVisible(LINK_PORTAL_HOME);
+ Assert.assertTrue(selenium.isTextPresent("Create a portal named:"));
+ int r = findTableRow(TABLE_PORTAL_ADMIN, portalName, 0) - 1;
+
+ clickAndWait(MessageFormat.format(POR_TL_MAIN, r));
+
+ r = findTableRow(TABLE_PORTALPAGE_ADMIN, pageName, 0) - 1;
+
+ clickAndWait(MessageFormat.format(PAG_TL_RENAME, r));
+
+ }
+
+ @Test(enabled = false)
+ public void testPageSecurity() {
+ }
+
+ @Test(enabled = false)
+ public void testPageTheme() {
+ }
+
+ @Test(enabled = false)
+ public void testPageLayout() {
+ }
+
+ private void createPortal(String name) {
+ selenium.open("/portal/");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ clickIfVisible(TAB_PORTALOBJ_ID);
+ clickIfVisible(LINK_PORTALS_ID);
+
+ selenium.type(INPUT_PORTALNAME, name);
+ selenium.click(INPUT_SUBMIT_CREATEPORTAL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ }
+
+ private void createPage(String portalName, String pageName) {
+ selenium.open("/portal/");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ clickIfVisible(TAB_PORTALOBJ_ID);
+ clickIfVisible(LINK_PORTALS_ID);
+
+ int r = findTableRow(TABLE_PORTAL_ADMIN, portalName, 0) - 1;
+
+ selenium.click(MessageFormat.format(POR_TL_MAIN, r));
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.type(INPUT_PAGENAME, pageName);
+ selenium.click(INPUT_SUBMIT_PAGECREATE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ }
}
Added: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/EndtoEndPortalAdminTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/EndtoEndPortalAdminTestCase.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/EndtoEndPortalAdminTestCase.java 2009-02-17 10:44:45 UTC (rev 12827)
@@ -0,0 +1,214 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.jboss.portal.test.selenium.portal;
+
+import java.text.MessageFormat;
+import org.jboss.portal.test.selenium.JBossPortalSeleniumTestCase;
+import org.testng.Assert;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
+ */
+@Test(groups = {"usecase"}, enabled = true, description = "Creating of new portal with content.")
+public class EndtoEndPortalAdminTestCase extends JBossPortalSeleniumTestCase {
+
+ public static final String SEL_PORTLET_TYPE = "_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:_viewRoot:windowForm:instanceId";
+ private static final String SUB_LAYOUT_ADD_CENTER = "//input[contains(@id,'layoutForm:a_center')]";
+ private static final String INP_WINDOW_NAME = "//input[contains(@id,'windowForm:windowName')]";
+ private static final String SUB_RENAME_PORTAL = "//input[contains(@id,'renameForm:rename')]";
+ private static final String INP_RENAME_PORTAL = "//input[contains(@id,'renameForm:newName')]";
+ private static final String SUB_DELETE_PORTAL_CONF = "//input[contains(@id,'delete-view:confirm-form:delete')]";
+ private static final String INP_SUBMIT_PAGECREATE = "//input[contains(@id,'create-page-form:create-page')]";
+ private static final String INP_PAGENAME = "//input[contains(@id,'create-page-form:pageName')]";
+ private static final String INP_PORTALNAME = "//input[contains(@id,'create-portal-form:name')]";
+ private static final String INP_SUBMIT_CREATEPORTAL = "//input[contains(@id,'create-portal-form:create-portal')]";
+ private final String TAB_PORTALOBJ_ID = "Link=Admin";
+ private final String LNK_PORTALS_ID = "link=*Portal Objects*";
+ private final String LNK_PORTAL_HOME = "//a[contains(@id,'obj-temp-form:object-link-0')]";
+ private final String TBL_PORTAL_ADMIN = "//table[contains(@id,'obj-nav-form:portal-datatable')]";
+ private final String POR_TL_MAIN = "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:object-iid-link'')]";
+ private final String POR_TL_SECURITY = "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:security-link'')]";
+ private final String POR_TL_PROPERTIES = "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:prop-link'')]";
+ private final String POR_TL_THEME = "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:theme-link'')]";
+ private final String POR_TL_RENAME = "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:rename'')]";
+ private final String POR_TL_DELETE = "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:delete'')]";
+ private final String POR_TL_MAKEDEF = "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:default-link'')]";
+ private final String TBL_PORTALPAGE_ADMIN = "//table[contains(@id,'obj-nav-form:pages-datatable')]";
+ private final String PAG_TL_MAIN = "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:object-link'')]";
+ private final String PAG_TL_LAYOUT = "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:edit-page-layout'')]";
+ private final String PAG_TL_SECURITY = "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:security-link'')]";
+ private final String PAG_TL_PROPERTIES = "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:prop-link'')]";
+ private final String PAG_TL_THEME = "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:theme-link'')]";
+ private final String PAG_TL_RENAME = "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:rename-link'')]";
+ private final String PAG_TL_DISPLAY = "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:rename-display'')]";
+ private final String PAG_TL_DELETE = "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:delete-link'')]";
+ private final String PAG_TL_MAKEDEF = "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:default-link'')]";
+ /*
+ - create a new portal
+ - add couple of page to the portal
+ - add few portlets of different kinds (csm, widget, regular portlets) in each page
+ - verify that new portal, pages and portlets get added correctly.
+ - Make the new portal default and verify that it becomes default portal
+ */
+
+ @BeforeMethod(groups = {"log"})
+ public void loginBeforeTest() {
+ logoutIfPossible();
+ login("admin", "admin");
+ }
+
+ @AfterMethod(groups = {"log"})
+ public void logoutAfterTest() {
+ }
+ final String portalName = "UseCasePortal";
+ final String page1Name = "firstPage";
+ final String page2Name = "anotherPage";
+ final String page3Name = "lastPage with whitespace";
+ final String page4Name = "_.s t R*a^n g e NAME _.][\\page";
+ final String PORTLET1 = "link=*ExceptionPortletInstance*";
+ final String PORTLET2 = "link=*CMSPortletInstance*";
+ final String PORTLET3 = "link=*ExceptionPortletInstance*";
+ final String PORTLET4 = "link=*ExceptionPortletInstance*";
+
+ @Test(enabled = true, description = "Usecase for creating small portal with content.")
+ public void testCreatePortalUsecase() {
+ createPortal(portalName);
+
+ addPage(page1Name);
+ //selenium.setSpeed("4000");
+ addPage(page2Name);
+ addPage(page3Name);
+ addPage(page4Name);
+
+ addPortlet(portalName, page1Name, PORTLET1, "portlet");
+ addPortlet(portalName, page1Name, PORTLET2, "portlet");
+ addPortlet(portalName, page1Name, PORTLET3, "portlet");
+ addPortlet(portalName, page1Name, PORTLET4, "portlet");
+
+ makeDefaultPortal(portalName);
+ }
+
+ private void createPortal(String portalName) {
+ selenium.open("/portal/");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ clickIfVisible(TAB_PORTALOBJ_ID);
+ clickIfVisible(LNK_PORTALS_ID);
+ clickIfVisible(LNK_PORTAL_HOME);
+
+ Assert.assertFalse(selenium.isTextPresent(portalName), "Not created page already exist.");
+
+ selenium.type(INP_PORTALNAME, portalName);
+ selenium.click(INP_SUBMIT_CREATEPORTAL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isTextPresent(portalName));
+ }
+
+ private void addPage(String pageName) {
+ selenium.open("/portal/");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ clickIfVisible(TAB_PORTALOBJ_ID);
+ clickIfVisible(LNK_PORTALS_ID);
+ clickIfVisible(LNK_PORTAL_HOME);
+
+ selenium.type(INP_PORTALNAME, portalName);
+ selenium.click(INP_SUBMIT_CREATEPORTAL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ int r = findTableRow(TBL_PORTAL_ADMIN, portalName, 0) - 1;
+
+ selenium.click(MessageFormat.format(POR_TL_MAIN, r));
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertFalse(selenium.isTextPresent(pageName), "Portal page already present");
+ Assert.assertTrue(selenium.isTextPresent("Create a page named:"));
+
+ selenium.type(INP_PAGENAME, pageName);
+ selenium.click(INP_SUBMIT_PAGECREATE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent(pageName));
+ }
+
+ private void addPortlet(String portalName, String pageName, String portletName, String type) {
+ selenium.open("/portal/");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ clickIfVisible(TAB_PORTALOBJ_ID);
+ clickIfVisible(LNK_PORTALS_ID);
+ clickIfVisible(LNK_PORTAL_HOME);
+
+ int r = findTableRow(TBL_PORTAL_ADMIN, portalName, 0) - 1;
+ selenium.click(MessageFormat.format(POR_TL_MAIN, r));
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ r = findTableRow(TBL_PORTALPAGE_ADMIN, pageName, 0) - 1;
+
+ // click on the page layout
+ selenium.click(MessageFormat.format(PAG_TL_LAYOUT, r));
+
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+
+ //hack
+ selenium.select(SEL_PORTLET_TYPE, "label=" + "cms");
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+
+ selenium.select(SEL_PORTLET_TYPE, "label=" + type);
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ selenium.click(portletName);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.click(SUB_LAYOUT_ADD_CENTER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ }
+
+ private void makeDefaultPortal(String portalName) {
+ selenium.open("/portal/");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ clickIfVisible(TAB_PORTALOBJ_ID);
+ clickIfVisible(LNK_PORTALS_ID);
+ clickIfVisible(LNK_PORTAL_HOME);
+
+ int r = findTableRow(TBL_PORTAL_ADMIN, portalName, 0) - 1;
+
+ selenium.click(MessageFormat.format(POR_TL_MAKEDEF, r));
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ }
+}
Added: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/usecaseng.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/usecaseng.xml (rev 0)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/usecaseng.xml 2009-02-17 10:44:45 UTC (rev 12827)
@@ -0,0 +1,14 @@
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
+<suite name="SeleniumTest">
+
+ <test verbose="2" name="org.jboss.portal.test.selenium.usecase.NewPortalUsecaseTestCase" annotations="JDK">
+ <classes>
+ <class name="org.jboss.portal.test.selenium.usecase.NewPortalUsecaseTestCase"/>
+ </classes>
+ </test>
+
+<listeners>
+<!-- <listener class-name="org.testng.reporters.JUnitXMLReporter"></listener> -->
+ <listener class-name="org.jboss.portal.test.selenium.JBossSeleniumTestListener"/>
+</listeners>
+</suite>
17 years, 2 months
JBoss Portal SVN: r12826 - in modules/authorization: tags and 1 other directory.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2009-02-16 00:00:41 -0500 (Mon, 16 Feb 2009)
New Revision: 12826
Added:
modules/authorization/tags/
modules/authorization/tags/authorization_1_0_PR/
Log:
Preview Release
Copied: modules/authorization/tags/authorization_1_0_PR (from rev 12825, modules/authorization/trunk)
17 years, 2 months
JBoss Portal SVN: r12825 - in modules/authorization/trunk/documentation/reference-guide/en: images and 2 other directories.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2009-02-15 23:43:05 -0500 (Sun, 15 Feb 2009)
New Revision: 12825
Added:
modules/authorization/trunk/documentation/reference-guide/en/images/architecture/
modules/authorization/trunk/documentation/reference-guide/en/images/architecture/architecture.png
Modified:
modules/authorization/trunk/documentation/reference-guide/en/master.xml
modules/authorization/trunk/documentation/reference-guide/en/modules/architecture.xml
Log:
adding architecture diagram to the doc
Added: modules/authorization/trunk/documentation/reference-guide/en/images/architecture/architecture.png
===================================================================
(Binary files differ)
Property changes on: modules/authorization/trunk/documentation/reference-guide/en/images/architecture/architecture.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: modules/authorization/trunk/documentation/reference-guide/en/master.xml
===================================================================
--- modules/authorization/trunk/documentation/reference-guide/en/master.xml 2009-02-16 02:29:38 UTC (rev 12824)
+++ modules/authorization/trunk/documentation/reference-guide/en/master.xml 2009-02-16 04:43:05 UTC (rev 12825)
@@ -20,5 +20,4 @@
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="modules/profiles.xml" />
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="modules/spi.xml" />
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="modules/examples.xml" />
- <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="modules/sample.xml" />
</book>
\ No newline at end of file
Modified: modules/authorization/trunk/documentation/reference-guide/en/modules/architecture.xml
===================================================================
--- modules/authorization/trunk/documentation/reference-guide/en/modules/architecture.xml 2009-02-16 02:29:38 UTC (rev 12824)
+++ modules/authorization/trunk/documentation/reference-guide/en/modules/architecture.xml 2009-02-16 04:43:05 UTC (rev 12825)
@@ -17,13 +17,16 @@
<listitem>Authorization Server</listitem>
</itemizedlist>
</para>
+ <imageobject>
+ <imagedata fileref="images/architecture/architecture.png" format="png"/>
+ </imageobject>
<sect2>
<title>Application Framework</title>
<para>
Application Framework consists of a Developer API that is used to integrate an Authorization layer for your application. This allows your Application
components to be free from any embedded Security Logic. The Framework consists of entities that can be used to create custom Authorization layers within the
context of your application, and with Profiles for infrastructure tiers that allows you to integrate Authorization layers as a simple drop in, without
- requiring any coding.
+ requiring any coding (Declarative Security Policy).
</para>
<sect3>
<title>Profiles</title>
@@ -90,7 +93,8 @@
<para>
Profile Implementations are expected to be complete with the following features:
<itemizedlist>
- <listitem><emphasis>A Drop In Authorization Layer</emphasis></listitem>
+ <listitem><emphasis>A Drop In Authorization Layer, not requiring any code changes to business components</emphasis></listitem>
+ <listitem><emphasis>XML Configuration to specify Security Declaratively</emphasis></listitem>
<listitem><emphasis>Developer Components built on top of the Developer API to develop Policy Provisioning functions (typically used for building Custom GUI)</emphasis></listitem>
<listitem><emphasis>An Optional tier-specific Generic GUI for Policy Provisioning</emphasis></listitem>
</itemizedlist>
17 years, 2 months