gatein SVN: r4994 - in components/wsrp/trunk: consumer/src/main/java/org/gatein/wsrp/consumer and 1 other directory.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2010-11-09 18:14:45 -0500 (Tue, 09 Nov 2010)
New Revision: 4994
Modified:
components/wsrp/trunk/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ConsumerManagerBean.java
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/ProducerInfo.java
Log:
- GTNWSRP-155: added cache by default.
Modified: components/wsrp/trunk/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ConsumerManagerBean.java
===================================================================
--- components/wsrp/trunk/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ConsumerManagerBean.java 2010-11-09 23:02:33 UTC (rev 4993)
+++ components/wsrp/trunk/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ConsumerManagerBean.java 2010-11-09 23:14:45 UTC (rev 4994)
@@ -26,6 +26,7 @@
import org.gatein.common.util.ParameterValidation;
import org.gatein.pc.api.PortletInvokerException;
import org.gatein.wsrp.WSRPConsumer;
+import org.gatein.wsrp.consumer.ProducerInfo;
import org.gatein.wsrp.consumer.RefreshResult;
import org.gatein.wsrp.consumer.RegistrationInfo;
import org.gatein.wsrp.consumer.registry.ConsumerRegistry;
@@ -182,7 +183,7 @@
{
try
{
- getRegistry().createConsumer(selectedId, null, null);
+ getRegistry().createConsumer(selectedId, ProducerInfo.DEFAULT_CACHE_VALUE, null);
setConsumerIdInSession(false);
return CONFIGURE_CONSUMER;
}
Modified: components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/ProducerInfo.java
===================================================================
--- components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/ProducerInfo.java 2010-11-09 23:02:33 UTC (rev 4993)
+++ components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/ProducerInfo.java 2010-11-09 23:14:45 UTC (rev 4994)
@@ -83,6 +83,7 @@
{
private final static Logger log = LoggerFactory.getLogger(ProducerInfo.class);
private final static boolean debug = log.isDebugEnabled();
+ public static final Integer DEFAULT_CACHE_VALUE = 30;
// Persistent information
@@ -99,7 +100,7 @@
private String persistentId;
/** The cache expiration duration (in seconds) for cached values */
- private Integer persistentExpirationCacheSeconds;
+ private Integer persistentExpirationCacheSeconds = DEFAULT_CACHE_VALUE;
/** The activated status of the associated Consumer */
private boolean persistentActive;
14 years, 2 months
gatein SVN: r4993 - in portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state: consumer and 4 other directories.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2010-11-09 18:02:33 -0500 (Tue, 09 Nov 2010)
New Revision: 4993
Modified:
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/JCRPersister.java
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/JCRConsumerRegistry.java
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/migration/JCRMigrationService.java
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/configuration/JCRProducerConfigurationService.java
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/registrations/JCRRegistrationPersistenceManager.java
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/state/JCRPortletStatePersistenceManager.java
Log:
- GTNWSRP-84: Made JCRPersister thread-safe.
Modified: portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/JCRPersister.java
===================================================================
--- portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/JCRPersister.java 2010-11-09 21:41:18 UTC (rev 4992)
+++ portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/JCRPersister.java 2010-11-09 23:02:33 UTC (rev 4993)
@@ -1,28 +1,28 @@
/*
-* JBoss, a division of Red Hat
-* Copyright 2008, 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.
-*/
+ * JBoss, a division of Red Hat
+ * Copyright 2010, 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.gatein.portal.wsrp.state;
-import EDU.oswego.cs.dl.util.concurrent.FJTask;
import org.chromattic.api.Chromattic;
import org.chromattic.api.ChromatticBuilder;
import org.chromattic.api.ChromatticSession;
@@ -59,6 +59,8 @@
private String workspaceName;
private Map<Class, Class<? extends BaseMapping>> modelToMapping;
+ private ThreadLocal<ChromatticSession> sessionHolder = new ThreadLocal<ChromatticSession>();
+
public JCRPersister(ExoContainer container, String workspaceName)
{
this.workspaceName = workspaceName;
@@ -87,7 +89,7 @@
if (BaseMapping.class.isAssignableFrom(mappingClass))
{
Type[] interfaces = mappingClass.getGenericInterfaces();
- if(ParameterValidation.existsAndIsNotEmpty(interfaces))
+ if (ParameterValidation.existsAndIsNotEmpty(interfaces))
{
Class type = (Class)((ParameterizedType)interfaces[0]).getActualTypeArguments()[0];
modelToMapping.put(type, mappingClass);
@@ -101,28 +103,41 @@
public ChromatticSession getSession()
{
- return chrome.openSession();
+ if (sessionHolder.get() == null)
+ {
+ ChromatticSession session = chrome.openSession();
+ sessionHolder.set(session);
+ return session;
+ }
+ else
+ {
+ return sessionHolder.get();
+ }
}
- public void closeSession(ChromatticSession session, boolean save)
+ public void closeSession(boolean save)
{
+ ChromatticSession session = getSession();
if (save)
{
- session.save();
+ synchronized (this)
+ {
+ session.save();
+ }
}
session.close();
}
- public void save(ChromatticSession session)
+ public synchronized void save()
{
- session.save();
+ getSession().save();
}
public <T> boolean delete(T toDelete, StoresByPathManager<T> manager)
{
Class<? extends Object> modelClass = toDelete.getClass();
Class<? extends BaseMapping> baseMappingClass = modelToMapping.get(modelClass);
- if(baseMappingClass == null)
+ if (baseMappingClass == null)
{
throw new IllegalArgumentException("Cannot find a mapping class for " + modelClass.getName());
}
@@ -134,12 +149,12 @@
if (old != null)
{
session.remove(old);
- closeSession(session, true);
+ closeSession(true);
return true;
}
else
{
- closeSession(session, false);
+ closeSession(false);
return false;
}
Modified: portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/JCRConsumerRegistry.java
===================================================================
--- portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/JCRConsumerRegistry.java 2010-11-09 21:41:18 UTC (rev 4992)
+++ portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/JCRConsumerRegistry.java 2010-11-09 23:02:33 UTC (rev 4993)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2009, Red Hat Middleware, LLC, and individual
+ * Copyright 2010, 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.
@@ -49,7 +49,7 @@
*/
public class JCRConsumerRegistry extends AbstractConsumerRegistry implements StoresByPathManager<ProducerInfo>
{
-// private NewJCRPersister persister;
+ // private NewJCRPersister persister;
private JCRPersister persister;
private static final String PRODUCER_INFOS_PATH = ProducerInfosMapping.NODE_NAME;
@@ -78,12 +78,12 @@
info.setKey(key);
pim.initFrom(info);
- persister.closeSession(session, true);
+ persister.closeSession(true);
}
catch (Exception e)
{
e.printStackTrace(); // todo: fix me
- persister.closeSession(session, false);
+ persister.closeSession(false);
}
}
@@ -113,7 +113,7 @@
String newId = producerInfo.getId();
pim.initFrom(producerInfo);
- persister.closeSession(session, true);
+ persister.closeSession(true);
// if the consumer's id has changed, return the old one so that state can be updated
return (oldId.equals(newId)) ? null : oldId;
@@ -127,7 +127,7 @@
List<ProducerInfoMapping> mappings = producerInfosMapping.getProducerInfos();
- persister.closeSession(session, true);
+ persister.closeSession(true);
return new MappingToProducerInfoIterator(mappings.iterator());
}
Modified: portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/migration/JCRMigrationService.java
===================================================================
--- portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/migration/JCRMigrationService.java 2010-11-09 21:41:18 UTC (rev 4992)
+++ portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/migration/JCRMigrationService.java 2010-11-09 23:02:33 UTC (rev 4993)
@@ -85,7 +85,7 @@
exportInfos.add(eim.toModel(null));
}
- persister.closeSession(session, false);
+ persister.closeSession(false);
exportInfosCount = exportInfos.size();
@@ -95,7 +95,7 @@
private ExportInfosMapping getExportInfosMapping(ChromatticSession session)
{
ExportInfosMapping exportInfosMapping = session.findByPath(ExportInfosMapping.class, ExportInfosMapping.NODE_NAME);
- if(exportInfosMapping == null)
+ if (exportInfosMapping == null)
{
exportInfosMapping = session.insert(ExportInfosMapping.class, ExportInfosMapping.NODE_NAME);
exportInfosCount = 0;
@@ -110,7 +110,7 @@
ExportInfoMapping eim = session.findByPath(ExportInfoMapping.class, getPathFor(exportTime));
- if(eim != null)
+ if (eim != null)
{
return eim.toModel(null);
}
@@ -126,7 +126,7 @@
ExportInfoMapping eim = session.findByPath(ExportInfoMapping.class, getChildPath(info));
long exportTime = info.getExportTime();
- if(eim != null)
+ if (eim != null)
{
throw new IllegalArgumentException("An ExportInfo with export time "
+ exportTime + " already exists!");
@@ -139,7 +139,7 @@
session.persist(exportInfosMapping, exportInfo, exportTimeAsString);
exportInfo.initFrom(info);
- persister.closeSession(session, true);
+ persister.closeSession(true);
exportInfosCount++;
}
}
@@ -159,7 +159,7 @@
public boolean isAvailableExportInfosEmpty()
{
- if(exportInfosCount == -1)
+ if (exportInfosCount == -1)
{
ChromatticSession session = persister.getSession();
ExportInfosMapping mappings = getExportInfosMapping(session);
Modified: portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/configuration/JCRProducerConfigurationService.java
===================================================================
--- portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/configuration/JCRProducerConfigurationService.java 2010-11-09 21:41:18 UTC (rev 4992)
+++ portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/configuration/JCRProducerConfigurationService.java 2010-11-09 23:02:33 UTC (rev 4993)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2009, Red Hat Middleware, LLC, and individual
+ * Copyright 2010, 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.
@@ -47,7 +47,7 @@
private static String PRODUCER_CONFIGURATION_PATH = ProducerConfigurationMapping.NODE_NAME;
private InputStream defaultConfigurationIS;
-// private NewJCRPersister persister;
+ // private NewJCRPersister persister;
private JCRPersister persister;
public JCRProducerConfigurationService(ExoContainer container) throws Exception
@@ -96,7 +96,7 @@
}
- persister.closeSession(session, true);
+ persister.closeSession(true);
}
public void saveConfiguration() throws Exception
@@ -110,6 +110,6 @@
}
pcm.initFrom(configuration);
- persister.closeSession(session, true);
+ persister.closeSession(true);
}
}
Modified: portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/registrations/JCRRegistrationPersistenceManager.java
===================================================================
--- portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/registrations/JCRRegistrationPersistenceManager.java 2010-11-09 21:41:18 UTC (rev 4992)
+++ portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/registrations/JCRRegistrationPersistenceManager.java 2010-11-09 23:02:33 UTC (rev 4993)
@@ -1,24 +1,25 @@
/*
-* JBoss, a division of Red Hat
-* Copyright 2008, 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.
-*/
+ * JBoss, a division of Red Hat
+ * Copyright 2010, 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.gatein.portal.wsrp.state.producer.registrations;
@@ -51,7 +52,7 @@
*/
public class JCRRegistrationPersistenceManager extends RegistrationPersistenceManagerImpl
{
-// private NewJCRPersister persister;
+ // private NewJCRPersister persister;
private JCRPersister persister;
private ConsumersAndGroupsMapping mappings;
@@ -73,7 +74,7 @@
{
mappings = session.insert(ConsumersAndGroupsMapping.class, ConsumersAndGroupsMapping.NODE_NAME);
}
- persister.save(session); // needed right now as the session must still be open to iterate over nodes
+ persister.save(); // needed right now as the session must still be open to iterate over nodes
for (ConsumerGroupMapping cgm : mappings.getConsumerGroups())
{
@@ -92,7 +93,7 @@
}
}
- persister.closeSession(session, false);
+ persister.closeSession(false);
}
@Override
@@ -115,12 +116,12 @@
RegistrationMapping rm = cm.createAndAddRegistrationMappingFrom(null);
registration = newRegistrationSPI(consumer, registrationProperties, rm.getPersistentKey());
rm.initFrom(registration);
- persister.closeSession(session, true);
+ persister.closeSession(true);
}
catch (Exception e)
{
e.printStackTrace(); // todo fix me
- persister.closeSession(session, false);
+ persister.closeSession(false);
}
return registration;
@@ -138,7 +139,7 @@
{
ChromatticSession session = persister.getSession();
session.remove(session.findById(clazz, id));
- persister.closeSession(session, true);
+ persister.closeSession(true);
}
@Override
@@ -154,12 +155,12 @@
mappings.getConsumers().add(cm);
cm.initFrom(consumer);
consumer.setPersistentKey(cm.getPersistentKey());
- persister.closeSession(session, true);
+ persister.closeSession(true);
}
catch (Exception e)
{
e.printStackTrace(); // todo: fix me
- persister.closeSession(session, false);
+ persister.closeSession(false);
}
return consumer;
@@ -175,34 +176,34 @@
{
ConsumerMapping cm = session.findById(ConsumerMapping.class, consumer.getPersistentKey());
cm.initFrom(consumer);
- persister.closeSession(session, true);
+ persister.closeSession(true);
}
catch (Exception e)
{
e.printStackTrace(); // todo: fix me
- persister.closeSession(session, false);
+ persister.closeSession(false);
}
return consumerSPI;
}
-
+
protected RegistrationSPI internalSaveChangesTo(Registration registration)
{
RegistrationSPI registrationSPI = super.internalSaveChangesTo(registration);
-
+
ChromatticSession session = persister.getSession();
try
{
RegistrationMapping cm = session.findById(RegistrationMapping.class, registration.getPersistentKey());
cm.initFrom(registration);
- persister.closeSession(session, true);
+ persister.closeSession(true);
}
catch (Exception e)
{
e.printStackTrace(); //todo: fix me
- persister.closeSession(session, false);
+ persister.closeSession(false);
}
-
+
return registrationSPI;
}
@@ -234,12 +235,12 @@
mappings.getConsumerGroups().add(cgm);
group.setPersistentKey(cgm.getPersistentKey());
cgm.initFrom(group);
- persister.closeSession(session, true);
+ persister.closeSession(true);
}
catch (Exception e)
{
e.printStackTrace(); // todo: fix me
- persister.closeSession(session, false);
+ persister.closeSession(false);
}
return group;
Modified: portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/state/JCRPortletStatePersistenceManager.java
===================================================================
--- portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/state/JCRPortletStatePersistenceManager.java 2010-11-09 21:41:18 UTC (rev 4992)
+++ portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/state/JCRPortletStatePersistenceManager.java 2010-11-09 23:02:33 UTC (rev 4993)
@@ -83,7 +83,7 @@
PortletStateMapping psm = pscm.getState();
psm.setProperties(propertyMap);
- persister.closeSession(session, true);
+ persister.closeSession(true);
}
@@ -103,7 +103,7 @@
context = pscm.toPortletStateContext();
}
- persister.closeSession(session, false);
+ persister.closeSession(false);
return context;
}
@@ -127,7 +127,7 @@
psm.setPortletID(pscm.getPortletId());
psm.setProperties(propertyMap);
- persister.closeSession(session, true);
+ persister.closeSession(true);
return pscm.getPersistentKey();
}
@@ -150,7 +150,7 @@
result = pscm.toPortletStateContext();
}
- persister.closeSession(session, true);
+ persister.closeSession(true);
return result;
}
14 years, 2 months
gatein SVN: r4992 - portal/branches/navcontroller/web/portal/src/main/webapp/WEB-INF/conf.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2010-11-09 16:41:18 -0500 (Tue, 09 Nov 2010)
New Revision: 4992
Modified:
portal/branches/navcontroller/web/portal/src/main/webapp/WEB-INF/conf/default-router.xml
Log:
cleanup router table
Modified: portal/branches/navcontroller/web/portal/src/main/webapp/WEB-INF/conf/default-router.xml
===================================================================
--- portal/branches/navcontroller/web/portal/src/main/webapp/WEB-INF/conf/default-router.xml 2010-11-09 21:40:23 UTC (rev 4991)
+++ portal/branches/navcontroller/web/portal/src/main/webapp/WEB-INF/conf/default-router.xml 2010-11-09 21:41:18 UTC (rev 4992)
@@ -13,15 +13,6 @@
<request-param name="gtn:action" matchName="portal:action" required="false"/>
<request-param name="gtn:objectid" matchName="objectId" required="false"/>
- <!-- Map the sitemap navigation on the /foo path -->
-<!--
- <route path="/foo">
- <param name="gtn:access" value="public"/>
- <param name="gtn:sitename" value="classic"/>
- <param name="gtn:path" value="/sitemap"/>
- </route>
--->
-
<!-- The public access -->
<route path="/public/{gtn:sitename}{gtn:path}">
<route-param name="gtn:access" value="public"/>
@@ -39,13 +30,6 @@
<!-- The group access -->
<route path="/groups">
<route-param name="gtn:access" value="private"/>
-<!--
- <route path="/">
- <route-param name="gtn:sitetype" value="portal"/>
- <route-param name="gtn:sitename" value="classic"/>
- <route-param name="gtn:path" value="/groupnavigation"/>
- </route>
--->
<route path="/{gtn:sitename}{gtn:path}">
<route-param name="gtn:sitetype" value="group"/>
<path-param name="gtn:path" pattern=".*" encoding="preserve-path"/>
14 years, 2 months
gatein SVN: r4991 - in portal/branches/navcontroller/component/web/controller/src: main/java/org/exoplatform/web/controller/metadata and 2 other directories.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2010-11-09 16:40:23 -0500 (Tue, 09 Nov 2010)
New Revision: 4991
Added:
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortal.java
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/gatein_router_1_0.xsd
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/DescriptorBuilder.java
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/PathParamDescriptor.java
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteDescriptor.java
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PatternBuilder.java
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PatternParam.java
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestBuildRoute.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestDescriptorBuilder.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestLegacyPortal.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestMatch.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortalConfiguration.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRender.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/router.xml
Log:
- remove the required for path param embryo
- add unit test for testing language in path
Modified: portal/branches/navcontroller/component/web/controller/src/main/java/gatein_router_1_0.xsd
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/gatein_router_1_0.xsd 2010-11-09 21:09:11 UTC (rev 4990)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/gatein_router_1_0.xsd 2010-11-09 21:40:23 UTC (rev 4991)
@@ -64,7 +64,6 @@
</xs:restriction>
</xs:simpleType>
</xs:attribute>
- <xs:attribute name="required" type="xs:boolean" use="optional"/>
</xs:complexType>
<xs:complexType name="requestParamType">
Modified: portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/DescriptorBuilder.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/DescriptorBuilder.java 2010-11-09 21:09:11 UTC (rev 4990)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/DescriptorBuilder.java 2010-11-09 21:40:23 UTC (rev 4991)
@@ -110,9 +110,8 @@
String name = reader.getAttributeValue(null, "name");
String pattern = reader.getAttributeValue(null, "pattern");
String encoded = reader.getAttributeValue(null, "encoding");
- String required = reader.getAttributeValue(null, "required");
EncodingMode encodingMode = "preserve-path".equals(encoded) ? EncodingMode.PRESERVE_PATH : EncodingMode.DEFAULT_FORM;
- routeDesc.addPathParam(QualifiedName.parse(name), pattern, encodingMode, !"false".equals(required));
+ routeDesc.addPathParam(QualifiedName.parse(name), pattern, encodingMode);
}
else if (routeQN.equals(reader.getName()))
{
Modified: portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/PathParamDescriptor.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/PathParamDescriptor.java 2010-11-09 21:09:11 UTC (rev 4990)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/PathParamDescriptor.java 2010-11-09 21:40:23 UTC (rev 4991)
@@ -38,10 +38,7 @@
/** . */
private final EncodingMode encodingMode;
- /** . */
- private final boolean required;
-
- public PathParamDescriptor(QualifiedName name, String pattern, EncodingMode encodingMode, boolean required)
+ public PathParamDescriptor(QualifiedName name, String pattern, EncodingMode encodingMode)
{
if (name == null)
{
@@ -52,7 +49,6 @@
this.name = name;
this.pattern = pattern;
this.encodingMode = encodingMode;
- this.required = required;
}
public QualifiedName getName()
@@ -69,9 +65,4 @@
{
return encodingMode;
}
-
- public boolean isRequired()
- {
- return required;
- }
}
Modified: portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteDescriptor.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteDescriptor.java 2010-11-09 21:09:11 UTC (rev 4990)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteDescriptor.java 2010-11-09 21:40:23 UTC (rev 4991)
@@ -92,9 +92,9 @@
return this;
}
- public RouteDescriptor addPathParam(QualifiedName name, String pattern, EncodingMode encodingMode, boolean required)
+ public RouteDescriptor addPathParam(QualifiedName name, String pattern, EncodingMode encodingMode)
{
- return addRequestParam(new PathParamDescriptor(name, pattern, encodingMode, required));
+ return addRequestParam(new PathParamDescriptor(name, pattern, encodingMode));
}
public RouteDescriptor addRequestParam(PathParamDescriptor requestParam)
Modified: portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PatternBuilder.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PatternBuilder.java 2010-11-09 21:09:11 UTC (rev 4990)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PatternBuilder.java 2010-11-09 21:40:23 UTC (rev 4991)
@@ -36,6 +36,10 @@
public PatternBuilder expr(String s)
{
+ if (s == null)
+ {
+ throw new NullPointerException("No null expression allowed");
+ }
buffer.append(s);
return this;
}
Modified: portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PatternParam.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PatternParam.java 2010-11-09 21:09:11 UTC (rev 4990)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PatternParam.java 2010-11-09 21:40:23 UTC (rev 4991)
@@ -39,14 +39,10 @@
/** . */
final Pattern pattern;
- /** . */
- final boolean required;
-
- PatternParam(QualifiedName name, EncodingMode encodingMode, Pattern pattern, boolean required)
+ PatternParam(QualifiedName name, EncodingMode encodingMode, Pattern pattern)
{
this.name = name;
this.encodingMode = encodingMode;
this.pattern = pattern;
- this.required = required;
}
}
Modified: portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java 2010-11-09 21:09:11 UTC (rev 4990)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java 2010-11-09 21:40:23 UTC (rev 4991)
@@ -183,19 +183,26 @@
for (RequestParam requestParamDef : requestParamDefs.values())
{
String a = blah.get(requestParamDef.name);
+ boolean matched = false;
if (a != null)
{
if (requestParamDef.matchValue(a))
{
- abc.remove(requestParamDef.name);
- continue;
+ matched = true;
}
}
+ if (matched)
+ {
+ abc.remove(requestParamDef.name);
+ }
else if (!requestParamDef.isRequired())
{
- continue;
+ // Do nothing
}
- return null;
+ else
+ {
+ return null;
+ }
}
}
@@ -590,11 +597,12 @@
{
if (start.size() == end.size())
{
- List<QualifiedName> parameterNames = new ArrayList<QualifiedName>();
PatternBuilder builder = new PatternBuilder();
builder.expr("^").expr('/');
List<String> chunks = new ArrayList<String>();
List<PatternParam> parameterPatterns = new ArrayList<PatternParam>();
+
+ //
int previous = 0;
for (int i = 0;i < start.size();i++)
{
@@ -607,27 +615,33 @@
// Now get path param metadata
PathParamDescriptor parameterDescriptor = pathParamDescriptors.get(parameterQName);
- String regex = "[^/]+";
+ String regex = null;
EncodingMode encodingMode = EncodingMode.DEFAULT_FORM;
- boolean required = true;
if (parameterDescriptor != null)
{
regex = parameterDescriptor.getPattern();
encodingMode = parameterDescriptor.getEncodingMode();
- required = parameterDescriptor.isRequired();
}
//
- builder.expr("(");
- builder.expr(regex);
- builder.expr(")");
+ if (regex == null)
+ {
+ regex = "[^/]+";
+ }
+
+ //
+ builder.expr("(").expr(regex).expr(")");
+
+ //
parameterPatterns.add(new PatternParam(
parameterQName,
encodingMode,
- Pattern.compile("^" + regex + "$"),
- required));
+ Pattern.compile("^" + regex + "$")
+ ));
previous = end.get(i) + 1;
}
+
+ //
builder.litteral(path, previous, pos);
chunks.add(path.substring(previous, pos));
// Julien : should the pattern end with a $ ?????? I don't see that for now
Modified: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestBuildRoute.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestBuildRoute.java 2010-11-09 21:09:11 UTC (rev 4990)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestBuildRoute.java 2010-11-09 21:40:23 UTC (rev 4991)
@@ -112,7 +112,7 @@
for (String path : paths)
{
RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor(path).addPathParam(QualifiedName.parse("a"), ".*", EncodingMode.DEFAULT_FORM, true));
+ routerMD.addRoute(new RouteDescriptor(path).addPathParam(QualifiedName.parse("a"), ".*", EncodingMode.DEFAULT_FORM));
Router router = new Router(routerMD);
//
Modified: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestDescriptorBuilder.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestDescriptorBuilder.java 2010-11-09 21:09:11 UTC (rev 4990)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestDescriptorBuilder.java 2010-11-09 21:40:23 UTC (rev 4991)
@@ -59,7 +59,6 @@
assertEquals(QualifiedName.parse("gtn:path"), route1.getPathParams().get(QualifiedName.parse("gtn:path")).getName());
assertEquals(".*", route1.getPathParams().get(QualifiedName.parse("gtn:path")).getPattern());
assertEquals(EncodingMode.DEFAULT_FORM, route1.getPathParams().get(QualifiedName.parse("gtn:path")).getEncodingMode());
- assertEquals(true, route1.getPathParams().get(QualifiedName.parse("gtn:path")).isRequired());
//
assertTrue(i.hasNext());
@@ -70,7 +69,6 @@
assertEquals(QualifiedName.parse("gtn:path"), route2.getPathParams().get(QualifiedName.parse("gtn:path")).getName());
assertEquals(".*", route2.getPathParams().get(QualifiedName.parse("gtn:path")).getPattern());
assertEquals(EncodingMode.PRESERVE_PATH, route2.getPathParams().get(QualifiedName.parse("gtn:path")).getEncodingMode());
- assertEquals(true, route2.getPathParams().get(QualifiedName.parse("gtn:path")).isRequired());
//
assertTrue(i.hasNext());
@@ -113,16 +111,6 @@
assertEquals(true, route6.getRequestParams().get("juu").isRequired());
//
- assertTrue(i.hasNext());
- RouteDescriptor route7 = i.next();
- assertEquals("/{gtn:lang}", route7.getPath());
- assertEquals(Collections.singleton(QualifiedName.parse("gtn:lang")), route7.getPathParams().keySet());
- assertEquals(QualifiedName.parse("gtn:lang"), route7.getPathParams().get(QualifiedName.parse("gtn:lang")).getName());
- assertEquals(null, route7.getPathParams().get(QualifiedName.parse("gtn:lang")).getPattern());
- assertEquals(EncodingMode.DEFAULT_FORM, route7.getPathParams().get(QualifiedName.parse("gtn:lang")).getEncodingMode());
- assertEquals(false, route7.getPathParams().get(QualifiedName.parse("gtn:lang")).isRequired());
-
- //
assertFalse(i.hasNext());
}
}
Modified: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestLegacyPortal.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestLegacyPortal.java 2010-11-09 21:09:11 UTC (rev 4990)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestLegacyPortal.java 2010-11-09 21:40:23 UTC (rev 4991)
@@ -49,8 +49,8 @@
addRequestParam(QualifiedName.parse("gtn:action"), "portal:action", null, false).
addRequestParam(QualifiedName.parse("gtn:objectid"), "portal:objectId", null, false).
addRoute(new RouteDescriptor("/public/{gtn:sitename}{gtn:path}").
- addParam(QualifiedName.parse("gtn:access"), "public")).addPathParam(QualifiedName.parse("gtn:path"), ".*", EncodingMode.PRESERVE_PATH, true).
- addRoute(new RouteDescriptor("/private/{gtn:sitename}{gtn:path}").addPathParam(QualifiedName.parse("gtn:path"), ".*", EncodingMode.PRESERVE_PATH, true).
+ addParam(QualifiedName.parse("gtn:access"), "public")).addPathParam(QualifiedName.parse("gtn:path"), ".*", EncodingMode.PRESERVE_PATH).
+ addRoute(new RouteDescriptor("/private/{gtn:sitename}{gtn:path}").addPathParam(QualifiedName.parse("gtn:path"), ".*", EncodingMode.PRESERVE_PATH).
addParam(QualifiedName.parse("gtn:access"), "private"));
//
Modified: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestMatch.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestMatch.java 2010-11-09 21:09:11 UTC (rev 4990)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestMatch.java 2010-11-09 21:40:23 UTC (rev 4991)
@@ -107,7 +107,7 @@
public void testWildcardPattern() throws Exception
{
RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), ".*", EncodingMode.PRESERVE_PATH, true));
+ routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), ".*", EncodingMode.PRESERVE_PATH));
Router router = new Router(routerMD);
//
@@ -120,7 +120,7 @@
public void testDefaultForm() throws Exception
{
RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), "[^/]+", EncodingMode.DEFAULT_FORM, true));
+ routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), "[^/]+", EncodingMode.DEFAULT_FORM));
Router router = new Router(routerMD);
//
@@ -130,7 +130,7 @@
public void testPreservePath() throws Exception
{
RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), "[^/]+", EncodingMode.PRESERVE_PATH, true));
+ routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), "[^/]+", EncodingMode.PRESERVE_PATH));
Router router = new Router(routerMD);
//
@@ -141,7 +141,7 @@
public void testSimplePattern() throws Exception
{
RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), "a", EncodingMode.DEFAULT_FORM, true));
+ routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), "a", EncodingMode.DEFAULT_FORM));
Router router = new Router(routerMD);
//
@@ -155,7 +155,7 @@
{
RouterDescriptor routerMD = new RouterDescriptor();
routerMD.addRoute(new RouteDescriptor("/a"));
- routerMD.addRoute(new RouteDescriptor("/{p}/b").addPathParam(QualifiedName.parse("p"), "a", EncodingMode.DEFAULT_FORM, true));
+ routerMD.addRoute(new RouteDescriptor("/{p}/b").addPathParam(QualifiedName.parse("p"), "a", EncodingMode.DEFAULT_FORM));
Router router = new Router(routerMD);
//
Added: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortal.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortal.java (rev 0)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortal.java 2010-11-09 21:40:23 UTC (rev 4991)
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * 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.exoplatform.web.controller.router;
+
+import org.exoplatform.web.controller.QualifiedName;
+import org.exoplatform.web.controller.metadata.RouteDescriptor;
+import org.exoplatform.web.controller.metadata.RouterDescriptor;
+
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TestPortal extends AbstractTestController
+{
+
+ public void testLanguage1() throws Exception
+ {
+ RouterDescriptor routerMD = new RouterDescriptor().addRoute(
+ new RouteDescriptor("/public{gtn:lang}").addPathParam(
+ QualifiedName.parse("gtn:lang"), "(/[A-Za-z][A-Za-z])?", EncodingMode.PRESERVE_PATH)
+ );
+ Router router = new Router(routerMD);
+ assertEquals(Collections.singletonMap(QualifiedName.parse("gtn:lang"), ""), router.route("/public"));
+ assertEquals(Collections.singletonMap(QualifiedName.parse("gtn:lang"), "/fr"), router.route("/public/fr"));
+ }
+
+ public void testLanguage2() throws Exception
+ {
+ RouterDescriptor routerMD = new RouterDescriptor().addRoute(
+ new RouteDescriptor("/{gtn:lang}public").addPathParam(
+ QualifiedName.parse("gtn:lang"), "([A-Za-z][A-Za-z]/)?", EncodingMode.PRESERVE_PATH)
+ );
+ Router router = new Router(routerMD);
+ assertEquals(Collections.singletonMap(QualifiedName.parse("gtn:lang"), ""), router.route("/public"));
+ assertEquals(Collections.singletonMap(QualifiedName.parse("gtn:lang"), "fr/"), router.route("/fr/public"));
+ }
+
+ public void testLanguage3() throws Exception
+ {
+ RouterDescriptor routerMD = new RouterDescriptor().
+ addRoute(new RouteDescriptor("/public")).
+ addRoute(new RouteDescriptor("/{gtn:lang}/public").
+ addPathParam(QualifiedName.parse("gtn:lang"), "([A-Za-z][A-Za-z])", EncodingMode.DEFAULT_FORM
+ )
+ );
+ Router router = new Router(routerMD);
+ assertEquals(Collections.<QualifiedName, String>emptyMap(), router.route("/public"));
+ assertEquals(Collections.singletonMap(QualifiedName.parse("gtn:lang"), "fr"), router.route("/fr/public"));
+ }
+
+}
Modified: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortalConfiguration.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortalConfiguration.java 2010-11-09 21:09:11 UTC (rev 4990)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortalConfiguration.java 2010-11-09 21:40:23 UTC (rev 4991)
@@ -46,25 +46,25 @@
RouteDescriptor portalRouteMD = new RouteDescriptor("/private/{gtn:sitetype}/{gtn:sitename}{gtn:path}");
portalRouteMD.addParam(QualifiedName.create("gtn", "controller"), "site");
portalRouteMD.addRequestParam(QualifiedName.create("gtn", "componentid"), "portal:componentId", null, false);
- portalRouteMD.addPathParam(QualifiedName.create("gtn", "path"), ".*", EncodingMode.PRESERVE_PATH, true);
+ portalRouteMD.addPathParam(QualifiedName.create("gtn", "path"), ".*", EncodingMode.PRESERVE_PATH);
routerMD.addRoute(portalRouteMD);
//
RouteDescriptor portalRouteMD2 = new RouteDescriptor("/private/{gtn:sitetype}/{gtn:sitename}{gtn:path}");
portalRouteMD2.addParam(QualifiedName.create("gtn", "controller"), "site");
- portalRouteMD2.addPathParam(QualifiedName.create("gtn", "path"), ".*", EncodingMode.PRESERVE_PATH, true);
+ portalRouteMD2.addPathParam(QualifiedName.create("gtn", "path"), ".*", EncodingMode.PRESERVE_PATH);
routerMD.addRoute(portalRouteMD2);
//
RouteDescriptor groupRouteMD = new RouteDescriptor("/groups/{gtn:sitetype}/{gtn:sitename}{gtn:path}");
groupRouteMD.addParam(QualifiedName.create("gtn", "controller"), "site");
- groupRouteMD.addPathParam(QualifiedName.create("gtn", "path"), ".*", EncodingMode.PRESERVE_PATH, true);
+ groupRouteMD.addPathParam(QualifiedName.create("gtn", "path"), ".*", EncodingMode.PRESERVE_PATH);
routerMD.addRoute(groupRouteMD);
//
RouteDescriptor userRouteMD = new RouteDescriptor("/users/{gtn:sitetype}/{gtn:sitename}{gtn:path}");
userRouteMD.addParam(QualifiedName.create("gtn", "controller"), "site");
- userRouteMD.addPathParam(QualifiedName.create("gtn", "path"), ".*", EncodingMode.PRESERVE_PATH, true);
+ userRouteMD.addPathParam(QualifiedName.create("gtn", "path"), ".*", EncodingMode.PRESERVE_PATH);
routerMD.addRoute(userRouteMD);
//
Modified: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRender.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRender.java 2010-11-09 21:09:11 UTC (rev 4990)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRender.java 2010-11-09 21:40:23 UTC (rev 4991)
@@ -76,7 +76,7 @@
public void testSimplePatternPathParam() throws Exception
{
RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), "a", EncodingMode.DEFAULT_FORM, true));
+ routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), "a", EncodingMode.DEFAULT_FORM));
Router router = new Router(routerMD);
//
@@ -87,7 +87,7 @@
public void testWildcardPathParam() throws Exception
{
RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), ".*", EncodingMode.PRESERVE_PATH, true));
+ routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), ".*", EncodingMode.PRESERVE_PATH));
Router router = new Router(routerMD);
//
@@ -99,7 +99,7 @@
public void testFoo() throws Exception
{
RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), "[^/]*", EncodingMode.PRESERVE_PATH, true));
+ routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), "[^/]*", EncodingMode.PRESERVE_PATH));
Router router = new Router(routerMD);
//
@@ -109,7 +109,7 @@
public void testBar() throws Exception
{
RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), "[^/]*", EncodingMode.DEFAULT_FORM, true));
+ routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), "[^/]*", EncodingMode.DEFAULT_FORM));
Router router = new Router(routerMD);
//
@@ -119,7 +119,7 @@
public void testWildcardParamPathPreservePathEncoding() throws Exception
{
RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), ".*", EncodingMode.PRESERVE_PATH, true));
+ routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), ".*", EncodingMode.PRESERVE_PATH));
Router router = new Router(routerMD);
//
@@ -129,7 +129,7 @@
public void testWildcardParamPathDefaultFormEncoded() throws Exception
{
RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), ".*", EncodingMode.DEFAULT_FORM, true));
+ routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), ".*", EncodingMode.DEFAULT_FORM));
Router router = new Router(routerMD);
//
@@ -140,7 +140,7 @@
{
RouterDescriptor routerMD = new RouterDescriptor();
routerMD.addRoute(new RouteDescriptor("/a"));
- routerMD.addRoute(new RouteDescriptor("/{p}/b").addPathParam(QualifiedName.parse("p"), "a", EncodingMode.DEFAULT_FORM, true));
+ routerMD.addRoute(new RouteDescriptor("/{p}/b").addPathParam(QualifiedName.parse("p"), "a", EncodingMode.DEFAULT_FORM));
Router router = new Router(routerMD);
//
Modified: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/router.xml
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/router.xml 2010-11-09 21:09:11 UTC (rev 4990)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/router.xml 2010-11-09 21:40:23 UTC (rev 4991)
@@ -34,8 +34,4 @@
<request-param name="juu" matchName="juu" matchValue="juu" required="true"/>
</route>
- <route path="/{gtn:lang}">
- <path-param name="gtn:lang" required="false"/>
- </route>
-
</router>
\ No newline at end of file
14 years, 2 months
gatein SVN: r4990 - in portal/branches/navcontroller/component/web/controller/src: test/java/org/exoplatform/web/controller/router and 1 other directory.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2010-11-09 16:09:11 -0500 (Tue, 09 Nov 2010)
New Revision: 4990
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestBuildRoute.java
Log:
minor improvement
Modified: portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java 2010-11-09 16:28:48 UTC (rev 4989)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java 2010-11-09 21:09:11 UTC (rev 4990)
@@ -360,13 +360,13 @@
{
for (PatternRoute route : patterns)
{
- Matcher matcher = route.pattern.matcher(path.substring(1));
+ Matcher matcher = route.pattern.matcher(path);
// We match
if (matcher.find())
{
// Build next controller context
- int nextPos = matcher.end() + 1;
+ int nextPos = matcher.end();
String nextPath;
if (path.length() == nextPos)
{
@@ -592,7 +592,7 @@
{
List<QualifiedName> parameterNames = new ArrayList<QualifiedName>();
PatternBuilder builder = new PatternBuilder();
- builder.expr("^");
+ builder.expr("^").expr('/');
List<String> chunks = new ArrayList<String>();
List<PatternParam> parameterPatterns = new ArrayList<PatternParam>();
int previous = 0;
Modified: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestBuildRoute.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestBuildRoute.java 2010-11-09 16:28:48 UTC (rev 4989)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestBuildRoute.java 2010-11-09 21:09:11 UTC (rev 4990)
@@ -71,7 +71,7 @@
assertEquals(0, router.root.getSegmentNames().size());
assertEquals(1, router.root.getPatternSize());
PatternRoute patternRoute = router.root.getPattern(0);
- assertEquals("^([^/]+)", patternRoute.pattern.toString());
+ assertEquals("^/([^/]+)", patternRoute.pattern.toString());
assertEquals(1, patternRoute.params.size());
assertEquals(QualifiedName.create("a"), patternRoute.params.get(0).name);
assertEquals("^[^/]+$", patternRoute.params.get(0).pattern.toString());
@@ -95,7 +95,7 @@
assertEquals(0, router.root.getSegmentNames().size());
assertEquals(1, router.root.getPatternSize());
PatternRoute patternRoute = router.root.getPattern(0);
- assertEquals("^([^/]+)", patternRoute.pattern.toString());
+ assertEquals("^/([^/]+)", patternRoute.pattern.toString());
assertEquals(1, patternRoute.params.size());
assertEquals(QualifiedName.create("q", "a"), patternRoute.params.get(0).name);
assertEquals("^[^/]+$", patternRoute.params.get(0).pattern.toString());
@@ -119,7 +119,7 @@
assertEquals(0, router.root.getSegmentNames().size());
assertEquals(1, router.root.getPatternSize());
PatternRoute patternRoute = router.root.getPattern(0);
- assertEquals("^(.*)", patternRoute.pattern.toString());
+ assertEquals("^/(.*)", patternRoute.pattern.toString());
assertEquals(1, patternRoute.params.size());
assertEquals(QualifiedName.create("a"), patternRoute.params.get(0).name);
assertEquals("^.*$", patternRoute.params.get(0).pattern.toString());
14 years, 2 months
gatein SVN: r4989 - in portal/branches/navcontroller/component/web/controller/src: main/java/org/exoplatform/web/controller/metadata and 2 other directories.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2010-11-09 11:28:48 -0500 (Tue, 09 Nov 2010)
New Revision: 4989
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/gatein_router_1_0.xsd
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/DescriptorBuilder.java
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/PathParamDescriptor.java
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteDescriptor.java
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PatternParam.java
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestBuildRoute.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestDescriptorBuilder.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestLegacyPortal.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestMatch.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortalConfiguration.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRender.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/router.xml
Log:
add required=true|false on a path param, need to impl it though
Modified: portal/branches/navcontroller/component/web/controller/src/main/java/gatein_router_1_0.xsd
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/gatein_router_1_0.xsd 2010-11-09 13:45:48 UTC (rev 4988)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/gatein_router_1_0.xsd 2010-11-09 16:28:48 UTC (rev 4989)
@@ -64,6 +64,7 @@
</xs:restriction>
</xs:simpleType>
</xs:attribute>
+ <xs:attribute name="required" type="xs:boolean" use="optional"/>
</xs:complexType>
<xs:complexType name="requestParamType">
Modified: portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/DescriptorBuilder.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/DescriptorBuilder.java 2010-11-09 13:45:48 UTC (rev 4988)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/DescriptorBuilder.java 2010-11-09 16:28:48 UTC (rev 4989)
@@ -110,8 +110,9 @@
String name = reader.getAttributeValue(null, "name");
String pattern = reader.getAttributeValue(null, "pattern");
String encoded = reader.getAttributeValue(null, "encoding");
+ String required = reader.getAttributeValue(null, "required");
EncodingMode encodingMode = "preserve-path".equals(encoded) ? EncodingMode.PRESERVE_PATH : EncodingMode.DEFAULT_FORM;
- routeDesc.addPathParam(QualifiedName.parse(name), pattern, encodingMode);
+ routeDesc.addPathParam(QualifiedName.parse(name), pattern, encodingMode, !"false".equals(required));
}
else if (routeQN.equals(reader.getName()))
{
Modified: portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/PathParamDescriptor.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/PathParamDescriptor.java 2010-11-09 13:45:48 UTC (rev 4988)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/PathParamDescriptor.java 2010-11-09 16:28:48 UTC (rev 4989)
@@ -38,21 +38,21 @@
/** . */
private final EncodingMode encodingMode;
- public PathParamDescriptor(QualifiedName name, String pattern, EncodingMode encodingMode)
+ /** . */
+ private final boolean required;
+
+ public PathParamDescriptor(QualifiedName name, String pattern, EncodingMode encodingMode, boolean required)
{
if (name == null)
{
throw new NullPointerException("No null name accepted");
}
- if (pattern == null)
- {
- throw new NullPointerException("No null pattern accepted");
- }
//
this.name = name;
this.pattern = pattern;
this.encodingMode = encodingMode;
+ this.required = required;
}
public QualifiedName getName()
@@ -69,4 +69,9 @@
{
return encodingMode;
}
+
+ public boolean isRequired()
+ {
+ return required;
+ }
}
Modified: portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteDescriptor.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteDescriptor.java 2010-11-09 13:45:48 UTC (rev 4988)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteDescriptor.java 2010-11-09 16:28:48 UTC (rev 4989)
@@ -92,9 +92,9 @@
return this;
}
- public RouteDescriptor addPathParam(QualifiedName name, String pattern, EncodingMode encodingMode)
+ public RouteDescriptor addPathParam(QualifiedName name, String pattern, EncodingMode encodingMode, boolean required)
{
- return addRequestParam(new PathParamDescriptor(name, pattern, encodingMode));
+ return addRequestParam(new PathParamDescriptor(name, pattern, encodingMode, required));
}
public RouteDescriptor addRequestParam(PathParamDescriptor requestParam)
Modified: portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PatternParam.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PatternParam.java 2010-11-09 13:45:48 UTC (rev 4988)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PatternParam.java 2010-11-09 16:28:48 UTC (rev 4989)
@@ -39,10 +39,14 @@
/** . */
final Pattern pattern;
- PatternParam(QualifiedName name, EncodingMode encodingMode, Pattern pattern)
+ /** . */
+ final boolean required;
+
+ PatternParam(QualifiedName name, EncodingMode encodingMode, Pattern pattern, boolean required)
{
this.name = name;
this.encodingMode = encodingMode;
this.pattern = pattern;
+ this.required = required;
}
}
Modified: portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java 2010-11-09 13:45:48 UTC (rev 4988)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java 2010-11-09 16:28:48 UTC (rev 4989)
@@ -609,17 +609,23 @@
PathParamDescriptor parameterDescriptor = pathParamDescriptors.get(parameterQName);
String regex = "[^/]+";
EncodingMode encodingMode = EncodingMode.DEFAULT_FORM;
+ boolean required = true;
if (parameterDescriptor != null)
{
regex = parameterDescriptor.getPattern();
encodingMode = parameterDescriptor.getEncodingMode();
+ required = parameterDescriptor.isRequired();
}
//
builder.expr("(");
builder.expr(regex);
builder.expr(")");
- parameterPatterns.add(new PatternParam(parameterQName, encodingMode, Pattern.compile("^" + regex + "$")));
+ parameterPatterns.add(new PatternParam(
+ parameterQName,
+ encodingMode,
+ Pattern.compile("^" + regex + "$"),
+ required));
previous = end.get(i) + 1;
}
builder.litteral(path, previous, pos);
Modified: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestBuildRoute.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestBuildRoute.java 2010-11-09 13:45:48 UTC (rev 4988)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestBuildRoute.java 2010-11-09 16:28:48 UTC (rev 4989)
@@ -112,7 +112,7 @@
for (String path : paths)
{
RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor(path).addPathParam(QualifiedName.parse("a"), ".*", EncodingMode.DEFAULT_FORM));
+ routerMD.addRoute(new RouteDescriptor(path).addPathParam(QualifiedName.parse("a"), ".*", EncodingMode.DEFAULT_FORM, true));
Router router = new Router(routerMD);
//
Modified: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestDescriptorBuilder.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestDescriptorBuilder.java 2010-11-09 13:45:48 UTC (rev 4988)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestDescriptorBuilder.java 2010-11-09 16:28:48 UTC (rev 4989)
@@ -59,6 +59,7 @@
assertEquals(QualifiedName.parse("gtn:path"), route1.getPathParams().get(QualifiedName.parse("gtn:path")).getName());
assertEquals(".*", route1.getPathParams().get(QualifiedName.parse("gtn:path")).getPattern());
assertEquals(EncodingMode.DEFAULT_FORM, route1.getPathParams().get(QualifiedName.parse("gtn:path")).getEncodingMode());
+ assertEquals(true, route1.getPathParams().get(QualifiedName.parse("gtn:path")).isRequired());
//
assertTrue(i.hasNext());
@@ -69,6 +70,7 @@
assertEquals(QualifiedName.parse("gtn:path"), route2.getPathParams().get(QualifiedName.parse("gtn:path")).getName());
assertEquals(".*", route2.getPathParams().get(QualifiedName.parse("gtn:path")).getPattern());
assertEquals(EncodingMode.PRESERVE_PATH, route2.getPathParams().get(QualifiedName.parse("gtn:path")).getEncodingMode());
+ assertEquals(true, route2.getPathParams().get(QualifiedName.parse("gtn:path")).isRequired());
//
assertTrue(i.hasNext());
@@ -109,5 +111,18 @@
assertEquals("juu", route6.getRequestParams().get("juu").getMatchName());
assertEquals("juu", route6.getRequestParams().get("juu").getMatchValue());
assertEquals(true, route6.getRequestParams().get("juu").isRequired());
+
+ //
+ assertTrue(i.hasNext());
+ RouteDescriptor route7 = i.next();
+ assertEquals("/{gtn:lang}", route7.getPath());
+ assertEquals(Collections.singleton(QualifiedName.parse("gtn:lang")), route7.getPathParams().keySet());
+ assertEquals(QualifiedName.parse("gtn:lang"), route7.getPathParams().get(QualifiedName.parse("gtn:lang")).getName());
+ assertEquals(null, route7.getPathParams().get(QualifiedName.parse("gtn:lang")).getPattern());
+ assertEquals(EncodingMode.DEFAULT_FORM, route7.getPathParams().get(QualifiedName.parse("gtn:lang")).getEncodingMode());
+ assertEquals(false, route7.getPathParams().get(QualifiedName.parse("gtn:lang")).isRequired());
+
+ //
+ assertFalse(i.hasNext());
}
}
Modified: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestLegacyPortal.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestLegacyPortal.java 2010-11-09 13:45:48 UTC (rev 4988)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestLegacyPortal.java 2010-11-09 16:28:48 UTC (rev 4989)
@@ -49,8 +49,8 @@
addRequestParam(QualifiedName.parse("gtn:action"), "portal:action", null, false).
addRequestParam(QualifiedName.parse("gtn:objectid"), "portal:objectId", null, false).
addRoute(new RouteDescriptor("/public/{gtn:sitename}{gtn:path}").
- addParam(QualifiedName.parse("gtn:access"), "public")).addPathParam(QualifiedName.parse("gtn:path"), ".*", EncodingMode.PRESERVE_PATH).
- addRoute(new RouteDescriptor("/private/{gtn:sitename}{gtn:path}").addPathParam(QualifiedName.parse("gtn:path"), ".*", EncodingMode.PRESERVE_PATH).
+ addParam(QualifiedName.parse("gtn:access"), "public")).addPathParam(QualifiedName.parse("gtn:path"), ".*", EncodingMode.PRESERVE_PATH, true).
+ addRoute(new RouteDescriptor("/private/{gtn:sitename}{gtn:path}").addPathParam(QualifiedName.parse("gtn:path"), ".*", EncodingMode.PRESERVE_PATH, true).
addParam(QualifiedName.parse("gtn:access"), "private"));
//
Modified: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestMatch.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestMatch.java 2010-11-09 13:45:48 UTC (rev 4988)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestMatch.java 2010-11-09 16:28:48 UTC (rev 4989)
@@ -107,7 +107,7 @@
public void testWildcardPattern() throws Exception
{
RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), ".*", EncodingMode.PRESERVE_PATH));
+ routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), ".*", EncodingMode.PRESERVE_PATH, true));
Router router = new Router(routerMD);
//
@@ -120,7 +120,7 @@
public void testDefaultForm() throws Exception
{
RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), "[^/]+", EncodingMode.DEFAULT_FORM));
+ routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), "[^/]+", EncodingMode.DEFAULT_FORM, true));
Router router = new Router(routerMD);
//
@@ -130,7 +130,7 @@
public void testPreservePath() throws Exception
{
RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), "[^/]+", EncodingMode.PRESERVE_PATH));
+ routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), "[^/]+", EncodingMode.PRESERVE_PATH, true));
Router router = new Router(routerMD);
//
@@ -141,7 +141,7 @@
public void testSimplePattern() throws Exception
{
RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), "a", EncodingMode.DEFAULT_FORM));
+ routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), "a", EncodingMode.DEFAULT_FORM, true));
Router router = new Router(routerMD);
//
@@ -155,7 +155,7 @@
{
RouterDescriptor routerMD = new RouterDescriptor();
routerMD.addRoute(new RouteDescriptor("/a"));
- routerMD.addRoute(new RouteDescriptor("/{p}/b").addPathParam(QualifiedName.parse("p"), "a", EncodingMode.DEFAULT_FORM));
+ routerMD.addRoute(new RouteDescriptor("/{p}/b").addPathParam(QualifiedName.parse("p"), "a", EncodingMode.DEFAULT_FORM, true));
Router router = new Router(routerMD);
//
Modified: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortalConfiguration.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortalConfiguration.java 2010-11-09 13:45:48 UTC (rev 4988)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortalConfiguration.java 2010-11-09 16:28:48 UTC (rev 4989)
@@ -46,25 +46,25 @@
RouteDescriptor portalRouteMD = new RouteDescriptor("/private/{gtn:sitetype}/{gtn:sitename}{gtn:path}");
portalRouteMD.addParam(QualifiedName.create("gtn", "controller"), "site");
portalRouteMD.addRequestParam(QualifiedName.create("gtn", "componentid"), "portal:componentId", null, false);
- portalRouteMD.addPathParam(QualifiedName.create("gtn", "path"), ".*", EncodingMode.PRESERVE_PATH);
+ portalRouteMD.addPathParam(QualifiedName.create("gtn", "path"), ".*", EncodingMode.PRESERVE_PATH, true);
routerMD.addRoute(portalRouteMD);
//
RouteDescriptor portalRouteMD2 = new RouteDescriptor("/private/{gtn:sitetype}/{gtn:sitename}{gtn:path}");
portalRouteMD2.addParam(QualifiedName.create("gtn", "controller"), "site");
- portalRouteMD2.addPathParam(QualifiedName.create("gtn", "path"), ".*", EncodingMode.PRESERVE_PATH);
+ portalRouteMD2.addPathParam(QualifiedName.create("gtn", "path"), ".*", EncodingMode.PRESERVE_PATH, true);
routerMD.addRoute(portalRouteMD2);
//
RouteDescriptor groupRouteMD = new RouteDescriptor("/groups/{gtn:sitetype}/{gtn:sitename}{gtn:path}");
groupRouteMD.addParam(QualifiedName.create("gtn", "controller"), "site");
- groupRouteMD.addPathParam(QualifiedName.create("gtn", "path"), ".*", EncodingMode.PRESERVE_PATH);
+ groupRouteMD.addPathParam(QualifiedName.create("gtn", "path"), ".*", EncodingMode.PRESERVE_PATH, true);
routerMD.addRoute(groupRouteMD);
//
RouteDescriptor userRouteMD = new RouteDescriptor("/users/{gtn:sitetype}/{gtn:sitename}{gtn:path}");
userRouteMD.addParam(QualifiedName.create("gtn", "controller"), "site");
- userRouteMD.addPathParam(QualifiedName.create("gtn", "path"), ".*", EncodingMode.PRESERVE_PATH);
+ userRouteMD.addPathParam(QualifiedName.create("gtn", "path"), ".*", EncodingMode.PRESERVE_PATH, true);
routerMD.addRoute(userRouteMD);
//
Modified: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRender.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRender.java 2010-11-09 13:45:48 UTC (rev 4988)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRender.java 2010-11-09 16:28:48 UTC (rev 4989)
@@ -76,7 +76,7 @@
public void testSimplePatternPathParam() throws Exception
{
RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), "a", EncodingMode.DEFAULT_FORM));
+ routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), "a", EncodingMode.DEFAULT_FORM, true));
Router router = new Router(routerMD);
//
@@ -87,7 +87,7 @@
public void testWildcardPathParam() throws Exception
{
RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), ".*", EncodingMode.PRESERVE_PATH));
+ routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), ".*", EncodingMode.PRESERVE_PATH, true));
Router router = new Router(routerMD);
//
@@ -99,7 +99,7 @@
public void testFoo() throws Exception
{
RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), "[^/]*", EncodingMode.PRESERVE_PATH));
+ routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), "[^/]*", EncodingMode.PRESERVE_PATH, true));
Router router = new Router(routerMD);
//
@@ -109,7 +109,7 @@
public void testBar() throws Exception
{
RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), "[^/]*", EncodingMode.DEFAULT_FORM));
+ routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), "[^/]*", EncodingMode.DEFAULT_FORM, true));
Router router = new Router(routerMD);
//
@@ -119,7 +119,7 @@
public void testWildcardParamPathPreservePathEncoding() throws Exception
{
RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), ".*", EncodingMode.PRESERVE_PATH));
+ routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), ".*", EncodingMode.PRESERVE_PATH, true));
Router router = new Router(routerMD);
//
@@ -129,7 +129,7 @@
public void testWildcardParamPathDefaultFormEncoded() throws Exception
{
RouterDescriptor routerMD = new RouterDescriptor();
- routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), ".*", EncodingMode.DEFAULT_FORM));
+ routerMD.addRoute(new RouteDescriptor("/{p}").addPathParam(QualifiedName.parse("p"), ".*", EncodingMode.DEFAULT_FORM, true));
Router router = new Router(routerMD);
//
@@ -140,7 +140,7 @@
{
RouterDescriptor routerMD = new RouterDescriptor();
routerMD.addRoute(new RouteDescriptor("/a"));
- routerMD.addRoute(new RouteDescriptor("/{p}/b").addPathParam(QualifiedName.parse("p"), "a", EncodingMode.DEFAULT_FORM));
+ routerMD.addRoute(new RouteDescriptor("/{p}/b").addPathParam(QualifiedName.parse("p"), "a", EncodingMode.DEFAULT_FORM, true));
Router router = new Router(routerMD);
//
Modified: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/router.xml
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/router.xml 2010-11-09 13:45:48 UTC (rev 4988)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/router.xml 2010-11-09 16:28:48 UTC (rev 4989)
@@ -34,4 +34,8 @@
<request-param name="juu" matchName="juu" matchValue="juu" required="true"/>
</route>
+ <route path="/{gtn:lang}">
+ <path-param name="gtn:lang" required="false"/>
+ </route>
+
</router>
\ No newline at end of file
14 years, 2 months
gatein SVN: r4988 - in portal/trunk/testsuite: selenium-tests-other and 20 other directories.
by do-not-reply@jboss.org
Author: mstruk
Date: 2010-11-09 08:45:48 -0500 (Tue, 09 Nov 2010)
New Revision: 4988
Added:
portal/trunk/testsuite/selenium-tests-other/
portal/trunk/testsuite/selenium-tests-other/Readme.txt
portal/trunk/testsuite/selenium-tests-other/pom.xml
portal/trunk/testsuite/selenium-tests-other/src/
portal/trunk/testsuite/selenium-tests-other/src/main/
portal/trunk/testsuite/selenium-tests-other/src/main/java/
portal/trunk/testsuite/selenium-tests-other/src/main/resources/
portal/trunk/testsuite/selenium-tests-other/src/suite/
portal/trunk/testsuite/selenium-tests-other/src/suite/user-extensions.js
portal/trunk/testsuite/selenium-tests-other/src/test/
portal/trunk/testsuite/selenium-tests-other/src/test/java/
portal/trunk/testsuite/selenium-tests-other/src/test/java/org/
portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/
portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/
portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/
portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/AbstractContextual.java
portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/AbstractSingleTest.java
portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/AbstractSingleTestWithAnt.java
portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/AbstractTestCase.java
portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/SeleniumContext.java
portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/TestCaseFailListener.java
portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/TestMethodSelector.java
portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/build/
portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/build/BuildHelper.java
portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/common/
portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/common/CommonHelper.java
portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/jira/
portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/jira/Test_GTNPORTAL_1257_SeamSessionOutlivesTheGateInSession.java
portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/messages.properties
portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/navigation/
portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/navigation/NavigationHelper.java
portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/page/
portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/page/PageHelper.java
portal/trunk/testsuite/selenium-tests-other/src/test/resources/
portal/trunk/testsuite/selenium-tests-other/src/test/resources/org/
portal/trunk/testsuite/selenium-tests-other/src/test/resources/org/jboss/
portal/trunk/testsuite/selenium-tests-other/src/test/resources/org/jboss/gatein/
portal/trunk/testsuite/selenium-tests-other/src/test/resources/org/jboss/gatein/selenium/
portal/trunk/testsuite/selenium-tests-other/src/test/resources/org/jboss/gatein/selenium/jira/
portal/trunk/testsuite/selenium-tests-other/src/test/resources/org/jboss/gatein/selenium/jira/Test_GTNPORTAL_1257_SeamSessionOutlivesTheGateInSession-build.xml
portal/trunk/testsuite/selenium-tests-other/src/test/resources/testng.xml
Log:
TestNG + Java based Selenium testsuite
Added: portal/trunk/testsuite/selenium-tests-other/Readme.txt
===================================================================
--- portal/trunk/testsuite/selenium-tests-other/Readme.txt (rev 0)
+++ portal/trunk/testsuite/selenium-tests-other/Readme.txt 2010-11-09 13:45:48 UTC (rev 4988)
@@ -0,0 +1,47 @@
+
+An alternative selenium testsuite.
+
+
+
+== Features ==
+
+- API for simple programmatic test composition
+- includes ready made per-test ant build - allowing individual tests to prepare and deploy any server-side dependency they might need but are unavailable
+- no support for 'macro' .html files
+- more control at every step of execution allowing for a more robust while still efficient tests
+
+
+
+== Usage ==
+
+To run against an already running GateIn instance use:
+
+ mvn integration-test -Pselenium
+
+
+
+To start an already built GateIn JBoss (avaialbe in packaging/pkg/target/jboss) before starting tests use:
+
+ mvn integration-test -Pselenium -DcontainerId=jboss5x
+
+
+
+== Using per-test ant builds ==
+
+This functionality is very useful for integration testing where individual tests need to pull in custom dependencies for deployment to an already running GateIn instance for example.
+
+When a test class extends AbstractSingleTestWithAnt it inherits functionality that allows for test-specific build.xml file discovery and execution. Discovery is based on a naming convention - it looks for a file called TEST_CLASS_NAME-build.xml (where TEST_CLASS_NAME is the name of the test class), and it expects to find it in test class' package.
+
+A test making use of this functionality can easily trigger a complete discovery and execution cycle by calling one single method.
+
+(For an example see Test_GTNPORTAL_1257_SeamSessionOutlivesTheGateInSession.java which deploys JBoss Portlet Bridge's Seam booking example)
+
+
+
+== Known issues ==
+
+Using maven-ant-tasks-2.1.1 from ant builds doesn't work with Maven 3.
+
+
+
+
Added: portal/trunk/testsuite/selenium-tests-other/pom.xml
===================================================================
--- portal/trunk/testsuite/selenium-tests-other/pom.xml (rev 0)
+++ portal/trunk/testsuite/selenium-tests-other/pom.xml 2010-11-09 13:45:48 UTC (rev 4988)
@@ -0,0 +1,480 @@
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file 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.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.testsuite</artifactId>
+ <version>3.2.0-Beta01-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.jboss.gatein</groupId>
+ <artifactId>gatein.ui.tests.selenium</artifactId>
+ <version>3.2.0-Beta01-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>Selenium UI Tests for GateIn</name>
+ <description>Selenium UI Tests for GateIn</description>
+
+ <properties>
+ <org.selenium.server.version>1.0.1</org.selenium.server.version>
+ <org.selenium.server.client.version>1.0.1</org.selenium.server.client.version>
+ <selenium.port>6666</selenium.port>
+ <selenium.browser>firefox</selenium.browser>
+ <selenium.timeout>20000</selenium.timeout>
+ <selenium.speed>300</selenium.speed>
+ <selenium.host>localhost</selenium.host>
+ <selenium.host.port>8080</selenium.host.port>
+ <selenium.host2>localhost</selenium.host2>
+ <selenium.host2.port>8080</selenium.host2.port>
+ <wsrp.version>v1</wsrp.version>
+ <org.selenium.maven-plugin.version>1.0.1</org.selenium.maven-plugin.version>
+ <cargo.timeout>240000</cargo.timeout>
+ <cargo.jvmargs.additional/>
+ <portal.path>/portal/public/classic</portal.path>
+ <testng.suite.file>testng.xml</testng.suite.file>
+ <method>*</method>
+ <screenshot>false</screenshot>
+ <html_src>false</html_src>
+ <selenium.test.skip>false</selenium.test.skip>
+ <selenium.server.skip>false</selenium.server.skip>
+
+ <!-- These are used by test specific ant projects to know where to deploy dependency artifacts -->
+ <container.home>../../packaging/pkg/target/jboss</container.home>
+ <container.config.home>${container.home}/server/default</container.config.home>
+ <container.config.deploy>${container.config.home}/deploy</container.config.deploy>
+
+ <!-- Change this to INFO or WARN to reduce ant build logging -->
+ <ant.logging.level>DEBUG</ant.logging.level>
+ </properties>
+
+
+ <repositories>
+ <repository>
+ <id>repository.jboss.org</id>
+ <url>http://repository.jboss.org/maven2</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>snapshots.jboss.org</id>
+ <url>http://snapshots.jboss.org/maven2</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>jboss-releases</id>
+ <url>https://repository.jboss.org/nexus/content/repositories/releases/</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>jboss-public</id>
+ <url>https://repository.jboss.org/nexus/content/groups/public/</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <!-- no tests by default -->
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>sniff-tests</id>
+ <properties>
+ <testng.suite.file>testng-sniff.xml</testng.suite.file>
+ </properties>
+ </profile>
+ <profile>
+ <id>selenium</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>deploy</id>
+ <phase>package</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <copy file="${basedir}/src/test/java/org/jboss/gatein/selenium/messages.properties"
+ todir="${project.build.directory}/test-classes/org/jboss/gatein/selenium"/>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>selenium-maven-plugin</artifactId>
+ <version>${org.selenium.maven-plugin.version}</version>
+ <executions>
+ <execution>
+ <id>start-selenium-server</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>start-server</goal>
+ </goals>
+ <configuration>
+ <background>true</background>
+ <logFile>${project.build.directory}/server.log</logFile>
+ <logOutput>true</logOutput>
+ <userExtensions>${pom.basedir}/src/suite/user-extensions.js</userExtensions>
+ <port>${selenium.port}</port>
+ <skip>${selenium.server.skip}</skip>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop-selenium-server</id>
+ <phase>post-integration-test</phase>
+ <goals>
+ <goal>stop-server</goal>
+ </goals>
+ <configuration>
+ <background>true</background>
+ <port>${selenium.port}</port>
+ <skip>${selenium.server.skip}</skip>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>properties-maven-plugin</artifactId>
+ <version>1.0-alpha-2</version>
+ <executions>
+ <execution>
+ <id>project-properties</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>write-project-properties</goal>
+ </goals>
+ <configuration>
+ <outputFile>
+ ${project.build.directory}/project.properties
+ </outputFile>
+ </configuration>
+ </execution>
+ <execution>
+ <id>active-profile-properties</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>write-active-profile-properties</goal>
+ </goals>
+ <configuration>
+ <outputFile>
+ ${project.build.directory}/active-profile.properties
+ </outputFile>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <skip>${selenium.test.skip}</skip>
+ <suiteXmlFiles>
+ <suiteXmlFile>src/test/resources/${testng.suite.file}</suiteXmlFile>
+ </suiteXmlFiles>
+ <systemProperties>
+ <property>
+ <name>selenium.port</name>
+ <value>${selenium.port}</value>
+ </property>
+ <property>
+ <name>selenium.browser</name>
+ <value>${selenium.browser}</value>
+ </property>
+ <property>
+ <name>selenium.speed</name>
+ <value>${selenium.speed}</value>
+ </property>
+ <property>
+ <name>selenium.timeout</name>
+ <value>${selenium.timeout}</value>
+ </property>
+ <property>
+ <name>selenium.host</name>
+ <value>${selenium.host}</value>
+ </property>
+ <property>
+ <name>selenium.host.port</name>
+ <value>${selenium.host.port}</value>
+ </property>
+ <property>
+ <name>selenium.host2</name>
+ <value>${selenium.host2}</value>
+ </property>
+ <property>
+ <name>selenium.host2.port</name>
+ <value>${selenium.host2.port}</value>
+ </property>
+ <property>
+ <name>portal.path</name>
+ <value>${portal.path}</value>
+ </property>
+ <property>
+ <name>wsrp.version</name>
+ <value>${wsrp.version}</value>
+ </property>
+ <property>
+ <name>method</name>
+ <value>${method}</value>
+ </property>
+ <property>
+ <name>screenshot</name>
+ <value>${screenshot}</value>
+ </property>
+ <property>
+ <name>html-src</name>
+ <value>${html_src}</value>
+ </property>
+ <property>
+ <name>output-dir</name>
+ <value>${project.build.directory}/screenshots</value>
+ </property>
+ </systemProperties>
+ <properties>
+ <property>
+ <name>listener</name>
+ <value>
+ org.jboss.test.selenium.listener.ConsoleStatusTestListener,org.jboss.gatein.selenium.TestMethodSelector,org.jboss.gatein.selenium.TestCaseFailListener
+ </value>
+ </property>
+ </properties>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <!-- Container Profile -->
+ <profile>
+ <id>container</id>
+ <activation>
+ <property>
+ <name>containerId</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.cargo</groupId>
+ <artifactId>cargo-maven2-plugin</artifactId>
+ <version>1.0.2</version>
+ <executions>
+ <execution>
+ <id>start-container</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>start</goal>
+ </goals>
+ </execution>
+ <!--
+ Stop is done by jboss-maven-plugin <execution>
+ <id>stop-container</id> <phase>post-integration-test</phase>
+ <goals> <goal>stop</goal> </goals> </execution>
+ -->
+ </executions>
+ <configuration>
+ <wait>false</wait>
+ <container>
+ <containerId>${containerId}</containerId>
+ <append>false</append>
+ <home>${container.home}</home>
+ <timeout>${cargo.timeout}</timeout>
+ </container>
+ <configuration>
+ <properties>
+ <cargo.hostname>${selenium.host}</cargo.hostname>
+ <cargo.jvmargs>-Xms768m -Xmx1024m -XX:MaxPermSize=256m
+ -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000
+ -Dsun.rmi.dgc.server.gcInterval=3600000 -Dsun.lang.ClassLoader.allowArraySyntax=true
+ -Dexo.conf.dir.name=gatein ${cargo.jvmargs.additional}
+ </cargo.jvmargs>
+ </properties>
+ </configuration>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <!-- Container: JBoss AS 5.X -->
+ <profile>
+ <id>container-jboss5x</id>
+ <activation>
+ <property>
+ <name>containerId</name>
+ <value>jboss5x</value>
+ </property>
+ </activation>
+ <properties>
+ <container.home>../../packaging/pkg/target/jboss</container.home>
+ <container.config.home>${container.home}/server/default</container.config.home>
+ <container.config.deploy>${container.config.home}/deploy</container.config.deploy>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.cargo</groupId>
+ <artifactId>cargo-maven2-plugin</artifactId>
+ <version>1.0.2</version>
+ <configuration>
+ <configuration>
+ <type>existing</type>
+ <home>${container.config.home}</home>
+ <properties>
+ <cargo.jboss.configuration>default</cargo.jboss.configuration>
+ <cargo.rmi.port>1099</cargo.rmi.port>
+ </properties>
+ </configuration>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jboss-maven-plugin</artifactId>
+ <version>1.4</version>
+ <executions>
+ <execution>
+ <id>stop-container</id>
+ <phase>post-integration-test</phase>
+ <goals>
+ <goal>stop</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <jbossHome>${container.home}</jbossHome>
+ <serverName>default</serverName>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+ <dependencies>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>5.12.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.seleniumhq.selenium.client-drivers</groupId>
+ <artifactId>selenium-java-client-driver</artifactId>
+ <version>${org.selenium.server.client.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.seleniumhq.selenium.server</groupId>
+ <artifactId>selenium-server</artifactId>
+ <version>${org.selenium.server.version}</version>
+ <classifier>standalone</classifier>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.4</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.test</groupId>
+ <artifactId>richfaces-selenium</artifactId>
+ <version>1.5.0.Alpha1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-ant-tasks</artifactId>
+ <version>2.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>1.7.1</version>
+ </dependency>
+ </dependencies>
+</project>
Added: portal/trunk/testsuite/selenium-tests-other/src/suite/user-extensions.js
===================================================================
--- portal/trunk/testsuite/selenium-tests-other/src/suite/user-extensions.js (rev 0)
+++ portal/trunk/testsuite/selenium-tests-other/src/suite/user-extensions.js 2010-11-09 13:45:48 UTC (rev 4988)
@@ -0,0 +1,59 @@
+/***************************************************************************************************************/
+/** Exo User Extensions ***/
+/***************************************************************************************************************/
+
+Selenium.prototype.doGetExoExtensionVersion = function(){
+ return "1.0";
+};
+
+/**
+ * This function allows to use a specific Contextual menu
+ * Usage:
+ * - Locator : Element to rightclick on
+ *
+ * For more information see the following URL:
+ * - Manually Fire event : http://www.howtocreate.co.uk/tutorials/javascript/domevents#domevld1
+ * - initMouseEvent properties : http://www.quirksmode.org/js/events_properties.html
+ *
+ * store in exo-int/qa/selenium
+ **/
+Selenium.prototype.doComponentExoContextMenu = function(locator){
+
+ var element = this.page().findElement(locator);
+ if (element.fireEvent && element.ownerDocument && element.ownerDocument.createEventObject) { // IE
+ var evt = createEventObject(element, false, false, false, false);
+ evt.button = 2;
+ element.fireEvent('onmousedown', evt);
+ } else {
+ var evObj = document.createEvent('MouseEvents');
+ evObj.initMouseEvent( 'mousedown', true, true, window, 1, 12, 345, 7, 220, false, false, false, false, 2, null );
+ element.dispatchEvent(evObj);
+ }
+
+};
+
+/**
+ * This function allows to use a specific Contextual menu
+ * Usage:
+ * - Locator : Element to doubleclick on
+
+ * For more information see the following URL:
+ * - Manually Fire event : http://www.howtocreate.co.uk/tutorials/javascript/domevents#domevld1
+ * - initMouseEvent properties : http://www.quirksmode.org/js/events_properties.html
+ *
+ * store in exo-int/qa/selenium
+ **/
+Selenium.prototype.doComponentExoDoubleClick = function(locator){
+
+ var element = this.page().findElement(locator);
+ if (element.fireEvent && element.ownerDocument && element.ownerDocument.createEventObject) { // IE
+ var evt = createEventObject(element, false, false, false, false);
+ evt.button = 0;
+ element.fireEvent('ondblclick', evt);
+ } else {
+ var evObj = document.createEvent('MouseEvents');
+ evObj.initMouseEvent( 'dblclick', true, true, window, 1, 12, 345, 7, 220, false, false, false, false, 0, null );
+ element.dispatchEvent(evObj);
+ }
+
+};
\ No newline at end of file
Added: portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/AbstractContextual.java
===================================================================
--- portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/AbstractContextual.java (rev 0)
+++ portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/AbstractContextual.java 2010-11-09 13:45:48 UTC (rev 4988)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.gatein.selenium;
+
+import com.thoughtworks.selenium.Selenium;
+
+public class AbstractContextual
+{
+
+ protected static Selenium selenium;
+ protected static String timeout;
+ protected static int timeoutSecInt;
+ protected static String portalPath;
+ protected static String browser;
+ protected static boolean ieFlag;
+
+ private static boolean inited;
+ private static int savedTimeoutSecInt;
+
+ private static SeleniumContext getSeleniumContext()
+ {
+ return AbstractTestCase.getCurrentSeleniumContext();
+ }
+
+ protected static void setUp()
+ {
+ if (inited)
+ {
+ return;
+ }
+
+ final SeleniumContext seleniumContext = getSeleniumContext();
+ selenium = seleniumContext.getSelenium();
+ timeout = seleniumContext.getTimeout();
+ timeoutSecInt = seleniumContext.getTimeoutSecInt();
+ portalPath = seleniumContext.getPortalPath();
+ browser = seleniumContext.getBrowser();
+ ieFlag = browser.contains("explore");
+ inited = true;
+ }
+
+ public static void setTemporaryTimeoutSecInt(int secs)
+ {
+ setUp();
+
+ savedTimeoutSecInt = timeoutSecInt;
+ if (secs > timeoutSecInt)
+ {
+ timeoutSecInt = secs;
+ }
+ }
+
+ public static void restoreTimeoutSecInt()
+ {
+ timeoutSecInt = savedTimeoutSecInt;
+ }
+}
Added: portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/AbstractSingleTest.java
===================================================================
--- portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/AbstractSingleTest.java (rev 0)
+++ portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/AbstractSingleTest.java 2010-11-09 13:45:48 UTC (rev 4988)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.gatein.selenium;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public abstract class AbstractSingleTest extends AbstractTestCase
+{
+
+ protected void performTest() throws Throwable
+ {
+ try
+ {
+ mainTest();
+ }
+ catch (Throwable ex)
+ {
+ exception(ex);
+ throw ex;
+ }
+ finally
+ {
+ cleanup();
+ }
+ }
+
+ protected void mainTest() throws Throwable
+ {}
+
+ protected void cleanup()
+ {}
+
+ protected void exception(Throwable ex)
+ {}
+}
Added: portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/AbstractSingleTestWithAnt.java
===================================================================
--- portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/AbstractSingleTestWithAnt.java (rev 0)
+++ portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/AbstractSingleTestWithAnt.java 2010-11-09 13:45:48 UTC (rev 4988)
@@ -0,0 +1,201 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.gatein.selenium;
+
+import org.apache.tools.ant.DefaultLogger;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.ProjectHelper;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+import java.util.Properties;
+
+import static org.jboss.gatein.selenium.build.BuildHelper.getMavenHome;
+import static org.jboss.gatein.selenium.common.CommonHelper.copyAndClose;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class AbstractSingleTestWithAnt extends AbstractSingleTest
+{
+ private String workDirRoot = "target/";
+ private String mavenProps = "project.properties";
+ private String mavenActiveProps = "active-profile.properties";
+
+ private boolean fileInited;
+ private File antBuildFile;
+ private Project project;
+
+ protected String getTestName()
+ {
+ String className = getClass().getName();
+ return className.substring(className.lastIndexOf('.') + 1);
+ }
+
+ protected Properties getActiveMavenProperties() throws IOException
+ {
+ Properties props = new Properties();
+ File propsFile = new File(workDirRoot, mavenProps);
+ if (!propsFile.isFile())
+ {
+ log.warn("File " + propsFile + " not found. Make sure you're using properties-maven-plugin in your pom.xml. Build may not work properly: " + getAntBuildFileName());
+ }
+ else
+ {
+ props.load(new FileInputStream(propsFile));
+ }
+
+ propsFile = new File(workDirRoot, mavenActiveProps);
+ if (!propsFile.isFile())
+ {
+ log.warn("File " + propsFile + " not found. Make sure you're using properties-maven-plugin in your pom.xml. Build may not work properly: " + getAntBuildFileName());
+ }
+ else
+ {
+ props.load(new FileInputStream(propsFile));
+ }
+
+ return props;
+ }
+
+ protected File getTestWorkDir()
+ {
+ return new File(workDirRoot, getTestName());
+ }
+
+ protected String getAntBuildFileName()
+ {
+ return getTestName() + "-build.xml";
+ }
+
+ protected File findAntBuildFileForTest() throws IOException
+ {
+ if (fileInited)
+ return antBuildFile;
+
+ fileInited = true;
+ String fileName = getAntBuildFileName();
+ InputStream is = getClass().getResourceAsStream(fileName);
+
+ if (is == null)
+ return null;
+
+ File outDir = getTestWorkDir();
+ File outFile = new File(outDir, fileName);
+ outDir.mkdirs();
+ copyAndClose(is, new FileOutputStream(outFile));
+
+ antBuildFile = outFile;
+ return outFile;
+ }
+
+ protected boolean expectAntBuildFile() throws IOException
+ {
+ File buildFile = findAntBuildFileForTest();
+
+ if (buildFile == null)
+ {
+ log.warn("Test specific ant build file not found: " + getAntBuildFileName() + ".");
+ return false;
+ }
+ return true;
+ }
+
+ protected Project prepareAntBuild() throws IOException
+ {
+ /*
+ * Example of how to embed ant:
+ * http://svn.apache.org/viewvc/maven/plugins/tags/maven-antrun-plugin-1.6/s...
+ *
+ */
+ File mavenHome = getMavenHome();
+ if (mavenHome != null)
+ System.setProperty("maven.home", mavenHome.getAbsolutePath());
+
+ Project project = new Project();
+ File buildFile = findAntBuildFileForTest();
+ project.setUserProperty("ant.file", buildFile.getAbsolutePath());
+
+ Properties props = getActiveMavenProperties();
+ for (Map.Entry ent: props.entrySet())
+ {
+ String key = (String) ent.getKey();
+ // build.xml properties override pom.xml properties
+ if (project.getProperty(key) == null)
+ {
+ project.setInheritedProperty(key, (String) ent.getValue());
+ }
+ }
+
+ project.init();
+ ProjectHelper.configureProject(project, buildFile);
+
+ DefaultLogger antLogger = new DefaultLogger();
+ antLogger.setOutputPrintStream( System.out );
+ antLogger.setErrorPrintStream( System.err );
+
+ String loggingLevel = project.getProperty("ant.logging.level");
+ antLogger.setMessageOutputLevel(getAntDebugLevel(loggingLevel));
+ project.addBuildListener( antLogger );
+
+ this.project = project;
+ return project;
+ }
+
+ protected int getAntDebugLevel(String loggingLevel)
+ {
+ loggingLevel = loggingLevel.toUpperCase();
+ if ("VERBOSE".equalsIgnoreCase(loggingLevel))
+ return Project.MSG_VERBOSE;
+ else if ("DEBUG".equals(loggingLevel))
+ return Project.MSG_DEBUG;
+ else if ("WARN".equals(loggingLevel))
+ return Project.MSG_WARN;
+ else if ("ERROR".equals(loggingLevel))
+ return Project.MSG_ERR;
+ else
+ return Project.MSG_INFO;
+ }
+
+ protected void executeAntBuild()
+ {
+ if (project == null)
+ throw new RuntimeException("Project not initialized. Call prepareAntBuild() first.");
+
+ String target = project.getDefaultTarget();
+ if (target == null)
+ throw new RuntimeException("No default target specified in ant build file: " + antBuildFile);
+
+ project.executeTarget(target);
+ }
+
+ protected void prepareAndExecuteAntBuild() throws IOException
+ {
+ prepareAntBuild();
+ executeAntBuild();
+ }
+}
Added: portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/AbstractTestCase.java
===================================================================
--- portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/AbstractTestCase.java (rev 0)
+++ portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/AbstractTestCase.java 2010-11-09 13:45:48 UTC (rev 4988)
@@ -0,0 +1,165 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.gatein.selenium;
+
+import com.thoughtworks.selenium.DefaultSelenium;
+import com.thoughtworks.selenium.Selenium;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.log4testng.Logger;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+public abstract class AbstractTestCase
+{
+
+ public Selenium selenium;
+
+ public String speed = "100";
+ public String timeout = "30000";
+ public int timeoutSecInt = 30;
+ public String browser = "firefox";
+ public String host = "localhost";
+ public String hostPort = "8080";
+ public String host2 = "localhost";
+ public String host2Port = "8080";
+ public String seleniumPort = "6666";
+ public String portalPath = "/portal/public/classic";
+ public boolean ieFlag = false;
+ public String wsrpVersion = "v1";
+
+ protected Logger log = Logger.getLogger(getClass());
+
+ protected static Properties propsMes;
+
+ static
+ {
+ try
+ {
+ propsMes = getProperties("org/jboss/gatein/selenium/messages.properties");
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ protected static SeleniumContext currentSeleniumContext;
+
+ public static SeleniumContext getCurrentSeleniumContext()
+ {
+ return currentSeleniumContext;
+ }
+
+ public void setInitialTestParameters()
+ {
+ setTimeout();
+ setSpeed();
+ }
+
+ public void setTimeout()
+ {
+ selenium.setTimeout(timeout);
+ }
+
+ public void setSpeed()
+ {
+ selenium.setSpeed(speed);
+ }
+
+ @BeforeClass(alwaysRun = true)
+ public void setUp() throws Exception
+ {
+ initSystemProperties();
+ selenium = new DefaultSelenium("127.0.0.1", Integer.parseInt(seleniumPort), "*" + browser, "http://" + host + ":" + hostPort);
+ TestCaseFailListener.selenium = selenium;
+ selenium.start();
+ currentSeleniumContext = new SeleniumContext(selenium, timeout, portalPath, browser);
+ setInitialTestParameters(); // initialization of speed and timeout
+ selenium.windowMaximize(); // running tests in maximize window
+ }
+
+ @AfterClass(alwaysRun = true)
+ public void tearDown() throws Exception
+ {
+ selenium.stop();
+ currentSeleniumContext = null;
+ }
+
+ public void initSystemProperties()
+ {
+ browser = System.getProperty("selenium.browser", browser);
+ timeout = System.getProperty("selenium.timeout", timeout);
+ timeoutSecInt = Integer.parseInt(timeout) / 1000;
+ speed = System.getProperty("selenium.speed", speed);
+ host = System.getProperty("selenium.host", host);
+ hostPort = System.getProperty("selenium.host.port", hostPort);
+ host2 = System.getProperty("selenium.host2", host2);
+ host2Port = System.getProperty("selenium.host2.port", host2Port);
+ seleniumPort = System.getProperty("selenium.port", seleniumPort);
+ portalPath = System.getProperty("portal.path", portalPath);
+ wsrpVersion = System.getProperty("wsrp.version", wsrpVersion);
+ ieFlag = browser.contains("iexplore");
+ }
+
+ public static String getMessage(String property)
+ {
+ return getProperty(propsMes, property, null);
+ }
+
+ public static String getMessage(String property, String subst)
+ {
+ return getProperty(propsMes, property, subst);
+ }
+
+ private static String getProperty(Properties properties, String property,
+ String subst)
+ {
+
+ if (subst == null || "".equals(subst))
+ {
+ subst = "Substitude not set";
+ }
+
+ if (properties == null)
+ {
+ return subst;
+ }
+ else
+ {
+ String message = properties.getProperty(property);
+ return message != null ? message : subst;
+ }
+ }
+
+ private static Properties getProperties(String resource) throws IOException
+ {
+ ClassLoader cl = ClassLoader.getSystemClassLoader();
+ InputStream is = cl.getResourceAsStream(resource);
+ Properties props = new Properties();
+ props.load(is);
+ return props;
+ }
+}
Added: portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/SeleniumContext.java
===================================================================
--- portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/SeleniumContext.java (rev 0)
+++ portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/SeleniumContext.java 2010-11-09 13:45:48 UTC (rev 4988)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.gatein.selenium;
+
+import com.thoughtworks.selenium.Selenium;
+
+public class SeleniumContext
+{
+
+ public Selenium getSelenium()
+ {
+ return selenium;
+ }
+
+ public String getTimeout()
+ {
+ return timeout;
+ }
+
+ public int getTimeoutSecInt()
+ {
+ return timeoutSecInt;
+ }
+
+ public String getPortalPath()
+ {
+ return portalPath;
+ }
+
+ public String getBrowser()
+ {
+ return browser;
+ }
+
+ private Selenium selenium;
+ private String timeout;
+ private int timeoutSecInt;
+ private String portalPath;
+ private String browser;
+
+ public SeleniumContext(Selenium selenium, String timeout, String portalPath, String browser)
+ {
+ this.selenium = selenium;
+ this.timeout = timeout;
+ this.timeoutSecInt = Integer.parseInt(timeout) / 1000;
+ this.portalPath = portalPath;
+ this.browser = browser;
+ }
+}
Added: portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/TestCaseFailListener.java
===================================================================
--- portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/TestCaseFailListener.java (rev 0)
+++ portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/TestCaseFailListener.java 2010-11-09 13:45:48 UTC (rev 4988)
@@ -0,0 +1,168 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.gatein.selenium;
+
+import com.thoughtworks.selenium.Selenium;
+import com.thoughtworks.selenium.SeleniumException;
+import org.testng.ITestResult;
+import org.testng.TestListenerAdapter;
+
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+/**
+ * The listener interface for receiving AbstractTestCase events.
+ * The class that is interested in processing a AbstractTestCase
+ * event implements this interface, and the object created
+ * with that class is registered with a component using the
+ * component's <code>addTestCaseFailListener<code> method. When
+ * the AbstractTestCase event occurs, that object's appropriate
+ * method is invoked. <br/>
+ * TestCaseFailListener is responsible for decoding most of the parameters which are passed to selenium tests.
+ * <table>
+ * <thead>
+ * <tr>
+ * <th>parameter name</th>
+ * <th>valid values</th>
+ * <th>default value</th>
+ * <th>description</th>
+ * </tr>
+ * </thead>
+ * <tr>
+ * <td>screenshot</td>
+ * <td>true/false</td>
+ * <td>false</td>
+ * <td>If true, screenshots are taken after the test failure. They are saved into directory specified by the "output-dir" parameter.</td>
+ * </tr><tr>
+ * <td>html-src</td><td>true/false</td><td>false</td><td>If true, html sources are taken after the test failure. They are saved into directory specified by the "output" parameter.</td>
+ * </tr><tr>
+ * <td>output-dir</td><td><path-to-dir></td><td>""</td><td>Path to the directory where html sources and screenshots are saved.</td>
+ * </tr>
+ * </table>
+ */
+public class TestCaseFailListener extends TestListenerAdapter
+{
+
+ public static Selenium selenium;
+ protected static int count;
+ protected static boolean screenshot = false;
+ protected static boolean htmlSource = false;
+ protected static String outputDir = "";
+
+ static
+ {
+ String ss = System.getProperty("screenshot");
+ if ("true".equals(ss))
+ {
+ screenshot = true;
+ }
+
+ String sh = System.getProperty("html-src");
+ if ("true".equals(sh))
+ {
+ htmlSource = true;
+ }
+
+ String so = System.getProperty("output-dir");
+ if (so != null)
+ {
+ outputDir = so;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.testng.TestListenerAdapter#onTestFailure(org.testng.ITestResult)
+ */
+
+ @Override
+ public void onTestFailure(ITestResult tr)
+ {
+
+ String name = outputDir + "/" + "F_" + tr.getName() + "-" + count;
+
+ if (screenshot)
+ {
+ try
+ {
+ selenium.windowMaximize();
+ waitFor(5000);
+ selenium.captureScreenshot(name + ".jpg");
+ }
+ catch (SeleniumException e2)
+ {
+ e2.printStackTrace();
+ }
+ }
+
+ if (htmlSource)
+ {
+ try
+ {
+ PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(name + ".html")));
+ out.println(selenium.getHtmlSource());
+ out.close();
+ }
+ catch (IOException e1)
+ {
+ e1.printStackTrace();
+ }
+ }
+ count++;
+ }
+
+ /**
+ * Waits for specified time in ms. Used mostly in AJAX based tests.
+ *
+ * @param time the time (in ms) to be waited for.
+ */
+ public void waitFor(long time)
+ {
+ try
+ {
+ Thread.sleep(time);
+ }
+ catch (InterruptedException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public static void captureScreenshot(String testName)
+ {
+ String name = outputDir + "/" + "F_" + testName;
+ if (screenshot)
+ {
+ try
+ {
+ selenium.captureScreenshot(name + ".jpg");
+ }
+ catch (SeleniumException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+}
Added: portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/TestMethodSelector.java
===================================================================
--- portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/TestMethodSelector.java (rev 0)
+++ portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/TestMethodSelector.java 2010-11-09 13:45:48 UTC (rev 4988)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.gatein.selenium;
+
+
+import org.apache.commons.lang.StringUtils;
+import org.testng.IAnnotationTransformer;
+import org.testng.annotations.ITestAnnotation;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+
+public class TestMethodSelector implements IAnnotationTransformer
+{
+
+ /**
+ * Disables the test methods which doesn't match the given method name.
+ */
+ @SuppressWarnings("unchecked")
+ public void transform(ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod)
+ {
+ String[] selectedMethods = System.getProperty("method", "*").split(",");
+
+ String methodName = testMethod.getDeclaringClass().getCanonicalName() + "." + testMethod.getName();
+ boolean match = false;
+
+ for (String selectedMethod : selectedMethods)
+ {
+
+ selectedMethod = StringUtils.replace(selectedMethod, "*", ".*");
+
+ if (methodName.matches(selectedMethod))
+ {
+ match = true;
+ break;
+ }
+ }
+
+ annotation.setEnabled(match);
+
+ }
+}
Added: portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/build/BuildHelper.java
===================================================================
--- portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/build/BuildHelper.java (rev 0)
+++ portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/build/BuildHelper.java 2010-11-09 13:45:48 UTC (rev 4988)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.gatein.selenium.build;
+
+import org.apache.tools.ant.taskdefs.Execute;
+
+import java.io.File;
+import java.util.List;
+
+public class BuildHelper
+{
+
+ public static File getMavenHome()
+ {
+
+ String mavenHome = null;
+
+ List<String> env = Execute.getProcEnvironment();
+ for (String var : env)
+ {
+ if (var.startsWith("M2_HOME="))
+ {
+ mavenHome = var.substring("M2_HOME=".length());
+ break;
+ }
+ }
+
+ if (mavenHome != null)
+ {
+ File mFile = new File(mavenHome);
+ if (!mFile.isDirectory())
+ {
+ mavenHome = System.getProperty("maven.home");
+ if (mavenHome != null)
+ {
+ mFile = new File(mavenHome);
+ }
+ }
+ if (mFile.isDirectory())
+ {
+ return mFile;
+ }
+ }
+ return null;
+ }
+}
\ No newline at end of file
Added: portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/common/CommonHelper.java
===================================================================
--- portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/common/CommonHelper.java (rev 0)
+++ portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/common/CommonHelper.java 2010-11-09 13:45:48 UTC (rev 4988)
@@ -0,0 +1,643 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.gatein.selenium.common;
+
+import com.thoughtworks.selenium.SeleniumException;
+import org.jboss.gatein.selenium.AbstractContextual;
+import org.testng.Assert;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public class CommonHelper extends AbstractContextual
+{
+
+ public static void waitForElementPresent(String element) throws Exception
+ {
+ setUp();
+
+ for (int second = 0; ; second++)
+ {
+ if (second >= timeoutSecInt)
+ {
+ Assert.fail("Timeout at waitForElementPresent: " + element);
+ }
+ try
+ {
+ if (selenium.isElementPresent(element))
+ {
+ break;
+ }
+ }
+ catch (Exception e)
+ {
+ }
+ Thread.sleep(1000);
+ }
+ }
+
+ public static void waitForTextPresent(String text) throws Exception
+ {
+ setUp();
+
+ for (int second = 0; ; second++)
+ {
+ if (second >= timeoutSecInt)
+ {
+ Assert.fail("Timeout at waitForTextPresent: " + text);
+ }
+ try
+ {
+ if (ieFlag)
+ {
+ if (selenium.isElementPresent("//*[contains(text(), '" + text + "')]") && selenium.isVisible("//*[contains(text(), '" + text + "')]"))
+ {
+ break;
+ }
+ }
+ else
+ {
+ if (selenium.isTextPresent(text))
+ {
+ break;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ }
+ Thread.sleep(1000);
+ }
+ }
+
+ public static void waitForTextNotPresent(String text) throws Exception
+ {
+ setUp();
+
+ for (int second = 0; ; second++)
+ {
+ if (second >= timeoutSecInt)
+ {
+ Assert.fail("Timeout at waitForTextNotPresent: " + text);
+ }
+ try
+ {
+ if (ieFlag)
+ {
+ if (!selenium.isElementPresent("//*[contains(text(), '" + text + "')]") || !selenium.isVisible("//*[contains(text(), '" + text + "')]"))
+ {
+ break;
+ }
+ }
+ else
+ {
+ if (!selenium.isTextPresent(text))
+ {
+ break;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ }
+ Thread.sleep(1000);
+ }
+ }
+
+ public static void waitForElementNotPresent(String element) throws Exception
+ {
+ setUp();
+
+ for (int second = 0; ; second++)
+ {
+ if (second >= timeoutSecInt)
+ {
+ Assert.fail("Timeout at waitForElementNotPresent: " + element);
+ }
+ try
+ {
+ if (!selenium.isElementPresent(element))
+ {
+ break;
+ }
+ }
+ catch (Exception e)
+ {
+ }
+ Thread.sleep(1000);
+ }
+ }
+
+ public static void waitForConfirmation(String confirmationText) throws Exception
+ {
+ setUp();
+
+ for (int second = 0; ; second++)
+ {
+ if (second >= timeoutSecInt)
+ {
+ Assert.fail("Timeout at waitForConfirmation: " + confirmationText);
+ }
+ try
+ {
+ if (selenium.getConfirmation().equals(confirmationText))
+ {
+ break;
+ }
+ }
+ catch (Exception e)
+ {
+ }
+ Thread.sleep(1000);
+ }
+ }
+
+ public static String getText(String element) throws Exception
+ {
+ setUp();
+
+ return selenium.getText(element);
+ }
+
+ public static boolean isTextPresent(String text) throws Exception
+ {
+ setUp();
+
+ if (ieFlag)
+ {
+ return selenium.isElementPresent("//*[contains(text(), '" + text + "')]") && selenium.isVisible("//*[contains(text(), '" + text + "')]");
+ }
+ else
+ {
+ return selenium.isTextPresent(text);
+ }
+ }
+
+ public static boolean isTextNotPresent(String text) throws Exception
+ {
+ setUp();
+
+ if (ieFlag)
+ {
+ return !selenium.isElementPresent("//*[contains(text(), '" + text + "')]") || !selenium.isVisible("//*[contains(text(), '" + text + "')]");
+ }
+ else
+ {
+ return !selenium.isTextPresent(text);
+ }
+ }
+
+ public static boolean isElementPresent(String element) throws Exception
+ {
+ setUp();
+
+ return selenium.isElementPresent(element);
+ }
+
+ public static boolean isElementNotPresent(String element) throws Exception
+ {
+ setUp();
+
+ return !selenium.isElementPresent(element);
+ }
+
+ public static boolean isOrdered(String element1, String element2)
+ {
+ setUp();
+
+ return selenium.isOrdered(element1, element2);
+ }
+
+ public static void waitForPageToLoad(String timeout)
+ {
+ setUp();
+
+ selenium.waitForPageToLoad(timeout);
+ }
+
+ public static void dragAndDropToObject(String source, String target)
+ {
+ setUp();
+
+ System.out.println("--Drag and drop to object--");
+ selenium.dragAndDropToObject(source, target);
+ }
+
+ public static void dragAndDrop(String source, String movementString)
+ {
+ setUp();
+
+ System.out.println("--Drag and drop--");
+ selenium.dragAndDrop(source, movementString);
+ }
+
+ public static void contextMenuOnElement(String element)
+ {
+ selenium.getEval("selenium.doComponentExoContextMenu(\"" + element + "\")");
+ }
+
+ public static void doubleClickOnElement(String element)
+ {
+ selenium.getEval("selenium.doComponentExoDoubleClick(\"" + element + "\")");
+ }
+
+ public static void keyPressOnElement(String element, String key)
+ {
+ selenium.keyPress(element, key);
+ }
+
+ public static void open(String location)
+ {
+ setUp();
+
+ System.out.println("--Opening location " + location + "--");
+ long start = System.currentTimeMillis();
+ RuntimeException re = null;
+ do
+ {
+ try
+ {
+ selenium.open(location);
+ return;
+ }
+ catch (SeleniumException ex)
+ {
+ if (!ex.getMessage().startsWith("Timed out"))
+ {
+ throw ex;
+ }
+ re = ex;
+ }
+ }
+ while (System.currentTimeMillis() - start < timeoutSecInt * 1000);
+
+ if (re != null)
+ {
+ throw re;
+ }
+ }
+
+ public static void click(String element)
+ {
+ setUp();
+
+ selenium.click(element);
+ }
+
+ public static void type(String element, String value)
+ {
+ setUp();
+
+ selenium.type(element, value);
+ }
+
+ public static void select(String element, String option)
+ {
+ setUp();
+
+ selenium.select(element, option);
+ }
+
+ public static void check(String element)
+ {
+ setUp();
+
+ selenium.check(element);
+ }
+
+ public static boolean isCheck(String element)
+ {
+ setUp();
+
+ return selenium.isChecked(element);
+ }
+
+ public static void uncheck(String element)
+ {
+ setUp();
+
+ selenium.uncheck(element);
+ }
+
+ public static void fireEvent(String element, String event)
+ {
+ setUp();
+
+ selenium.fireEvent(element, event);
+ }
+
+ public static void mouseOver(String element)
+ {
+ setUp();
+
+ selenium.mouseOver(element);
+ }
+
+ public static void pause(long timeInMillis)
+ {
+ try
+ {
+ Thread.sleep(timeInMillis);
+ }
+ catch (InterruptedException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public static String getValue(String element)
+ {
+ setUp();
+
+ return selenium.getValue(element);
+ }
+
+ public static String getXpathCount(String element)
+ {
+ setUp();
+
+ return selenium.getXpathCount(element).toString();
+ }
+
+ public static boolean isTextAtElementEqual(String element, String text) throws Exception
+ {
+ setUp();
+
+ return getText(element).equals(text);
+ }
+
+
+ public static void openPortal(boolean publicMode)
+ {
+ setUp();
+
+ open(publicMode ? portalPath : portalPath.replace("public", "private"));
+ }
+
+ public static void signInAsRoot() throws Exception
+ {
+ signIn("root", "gtn");
+ }
+
+ public static void signInAsJohn() throws Exception
+ {
+ signIn("john", "gtn");
+ }
+
+ public static void signInAsMary() throws Exception
+ {
+ signIn("mary", "gtn");
+ }
+
+ public static void signInAsDemo() throws Exception
+ {
+ signIn("demo", "gtn");
+ }
+
+ public static void signIn(String username, String password) throws Exception
+ {
+ setUp();
+
+ System.out.println("--Signing in as " + username + "--");
+ waitForElementPresent("link=Sign in");
+ click("link=Sign in");
+ waitForElementPresent("username");
+ type("username", username);
+ type("password", password);
+ click("//div[@id='UIPortalLoginFormAction']/div/div/div/a");
+ waitForPageToLoad(timeout);
+ }
+
+ public static void signInWithRememberChecked(String username, String password) throws Exception
+ {
+ setUp();
+
+ System.out.println("--Signing in as " + username + " with checked remember me--");
+ waitForElementPresent("link=Sign in");
+ click("link=Sign in");
+ waitForElementPresent("username");
+ type("username", username);
+ type("password", password);
+ System.out.println("--Check \"remember my login\"");
+ click("rememberme");
+ click("//div[@id='UIPortalLoginFormAction']/div/div/div/a");
+ waitForPageToLoad(timeout);
+ }
+
+ public static void signOut() throws Exception
+ {
+ setUp();
+
+ signOutWithLanguage("Sign out");
+ }
+
+ public static void signOutWithLanguage(String signOutLabel) throws Exception
+ {
+ setUp();
+
+ System.out.println("--Signing out--");
+ waitForElementPresent("link=" + signOutLabel);
+ click("link=" + signOutLabel);
+ waitForPageToLoad(timeout);
+ }
+
+ public static void goToApplicationRegistry() throws Exception
+ {
+ setUp();
+
+ System.out.println("--Go to App.registry--");
+ waitForElementPresent("link=Application Registry");
+ click("link=Application Registry");
+ waitForPageToLoad(timeout);
+ }
+
+ public static void goToPageManagement() throws Exception
+ {
+ setUp();
+
+ System.out.println("--Go to Page Management--");
+ waitForElementPresent("link=Page Management");
+ click("link=Page Management");
+ waitForPageToLoad(timeout);
+ }
+
+ public static void goToUsersManagement() throws Exception
+ {
+ setUp();
+
+ System.out.println("--Go to Users and groups management--");
+ waitForElementPresent("link=Users and groups management");
+ click("link=Users and groups management");
+ waitForPageToLoad(timeout);
+ }
+
+ public static void goToNewStaff() throws Exception
+ {
+ setUp();
+
+ System.out.println("--Go to New Staff--");
+ waitForElementPresent("link=New Staff");
+ click("link=New Staff");
+ waitForPageToLoad(timeout);
+ }
+
+ public static void goToSiteManagement() throws Exception
+ {
+ setUp();
+
+ System.out.println("--Go to Site Management--");
+ waitForElementPresent("link=Site");
+ click("link=Site");
+ waitForPageToLoad(timeout);
+ }
+
+ public static void goToGroupManagement() throws Exception
+ {
+ setUp();
+
+ System.out.println("--Go to Group Management--");
+ waitForElementPresent("link=Group");
+ click("link=Group");
+ waitForPageToLoad(timeout);
+ }
+
+ public static void goToDashboard() throws Exception
+ {
+ setUp();
+
+ System.out.println("--Go to Dashboard--");
+ waitForElementPresent("link=Dashboard");
+ click("link=Dashboard");
+ waitForPageToLoad(timeout);
+ }
+
+ public static void goToClassicPortal() throws Exception
+ {
+ setUp();
+
+ System.out.println("--Go to portal classic--");
+ waitForElementPresent("link=classic");
+ click("link=classic");
+ waitForPageToLoad(timeout);
+ }
+
+ public static void goToPage(String pageLabel) throws Exception
+ {
+ setUp();
+
+ System.out.println("--Go to page: " + pageLabel + "--");
+ waitForElementPresent("link=" + pageLabel);
+ click("link=" + pageLabel);
+ waitForPageToLoad(timeout);
+ }
+
+ public static void closeMessageDialog() throws Exception
+ {
+ System.out.println("--Closing message dialog--");
+ waitForElementPresent("//div[@id='UIPortalApplication']/div[@class='UIPopupWindow UIDragObject']//div[@class='MiddleLeftSideDecorator']//div[@class='UIPopupMessages']/div[@class='MessageActionBar']//a");
+ click("//div[@id='UIPortalApplication']/div[@class='UIPopupWindow UIDragObject']//div[@class='MiddleLeftSideDecorator']//div[@class='UIPopupMessages']/div[@class='MessageActionBar']//a");
+ }
+
+ public static void waitForMessage(String message) throws Exception
+ {
+ System.out.println("--Verify message: " + message);
+ waitForElementPresent("//div[@class='PopupMessage']");
+ waitForTextPresent(message);
+ }
+
+ public static void waitForPopupElementWithMessage(String message) throws Exception
+ {
+ System.out.println("--Verify message: " + message);
+ waitForElementPresent("//div[@class='PopupMessage']");
+ String value = getText("//div[@class='PopupMessage']");
+ if (!value.contains(message))
+ {
+ throw new Exception("Message to verify is not valid, current message value is: " + value);
+ }
+ }
+
+ public static void assertConfirmation(String msg) throws Exception
+ {
+ Assert.assertTrue(selenium.getConfirmation().matches("^" + msg + "$"));
+ }
+
+ public static void verifyTextPresent(String text) throws Exception
+ {
+ Assert.assertTrue(selenium.isTextPresent(text));
+ }
+
+ public static void importApplications() throws Exception
+ {
+ System.out.println("--Import applications--");
+ waitForElementPresent("//div[@id='UIApplicationRegistryPortlet']/div[2]/div[2]/div/div/div[2]");
+ click("//div[@id='UIApplicationRegistryPortlet']/div[2]/div[2]/div/div/div[2]");
+ assertConfirmation("This action will automatically create categories and import all the gadgets and portlets on it.");
+ }
+
+ public static void verifyPortletInstalled(String appName, String portletName) throws Exception
+ {
+ System.out.println("--Verify portlet is installed: " + appName + "/" + portletName + "--");
+ waitForElementPresent("link=" + appName);
+ click("link=" + appName);
+ waitForTextPresent(portletName);
+ verifyTextPresent(portletName);
+ }
+
+ public static void echo(String msg)
+ {
+ System.out.println(msg);
+ }
+
+ /**
+ * Copy input to output.
+ *
+ * @param in the input
+ * @param out the output
+ * @throws IOException for any I/O error
+ */
+ public static void copyAndClose(InputStream in, OutputStream out) throws IOException
+ {
+ try
+ {
+ byte[] buf = new byte[20000];
+ int rc;
+ while ((rc = in.read(buf)) != -1)
+ {
+ out.write(buf, 0, rc);
+ }
+ out.flush();
+ out.close();
+ }
+ finally
+ {
+ try
+ {
+ in.close();
+ }
+ catch (Exception ignored)
+ {
+ }
+ }
+ }
+}
Added: portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/jira/Test_GTNPORTAL_1257_SeamSessionOutlivesTheGateInSession.java
===================================================================
--- portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/jira/Test_GTNPORTAL_1257_SeamSessionOutlivesTheGateInSession.java (rev 0)
+++ portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/jira/Test_GTNPORTAL_1257_SeamSessionOutlivesTheGateInSession.java 2010-11-09 13:45:48 UTC (rev 4988)
@@ -0,0 +1,208 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.gatein.selenium.jira;
+
+import static org.jboss.gatein.selenium.common.CommonHelper.*;
+import static org.jboss.gatein.selenium.navigation.NavigationHelper.*;
+import static org.jboss.gatein.selenium.page.PageHelper.*;
+
+import org.jboss.gatein.selenium.AbstractContextual;
+import org.jboss.gatein.selenium.AbstractSingleTestWithAnt;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class Test_GTNPORTAL_1257_SeamSessionOutlivesTheGateInSession extends AbstractSingleTestWithAnt
+{
+
+ @BeforeTest(alwaysRun = true)
+ public void deploySeamBooking() throws Exception
+ {
+
+ if (!expectAntBuildFile())
+ {
+ log.warn("JBoss Portlet Bridge Seam Booking example may not be available");
+ return;
+ }
+
+ prepareAndExecuteAntBuild();
+ }
+
+ @Test(groups = {"GateIn", "jira"})
+ public void testGTNPORTAL_1257_SeamSessionOutlivesTheGateInSession() throws Throwable
+ {
+ performTest();
+ }
+
+ @Override
+ protected void mainTest() throws Throwable
+ {
+ try
+ {
+ AbstractContextual.setTemporaryTimeoutSecInt(60); // give it at least one minute
+ openPortal(true);
+ }
+ finally
+ {
+ AbstractContextual.restoreTimeoutSecInt();
+ }
+
+ signInAsRoot();
+
+ goToApplicationRegistry();
+
+ installPortlet();
+
+ goToPage("Home");
+
+ try
+ {
+ AbstractContextual.setTemporaryTimeoutSecInt(60); // give it at least one minute
+ addNewPageWithEditor(null, "TestPage", "TestPage", "portalBookingDemo", "seamBookingPortlet",
+ "//div[@id='portalBookingDemo/seamBookingPortlet']");
+ }
+ catch (Throwable th)
+ {
+ try
+ {
+ leavePageEdit();
+ }
+ catch (Exception ex)
+ {
+ log.warn("IGNORED: ", ex);
+ }
+ throw th;
+ }
+ finally
+ {
+ AbstractContextual.restoreTimeoutSecInt();
+ }
+
+ waitForTextPresent("Search Hotels");
+
+ verifyTextPresent("Welcome, root");
+
+ signOut();
+
+ signInAsMary();
+
+ goToPage("TestPage");
+
+ waitForTextPresent("Search Hotels");
+ verifyTextPresent("Welcome, mary");
+
+ }
+
+ private void leavePageEdit()
+ {
+ // we could have an error window popped up
+ String closeButton = "//div[@class='ExoMessageDecorator' and //div[@class='TabsContainer']//div[@class='SelectedTab']]//div[@class='CloseButton']";
+ click(closeButton);
+
+ // also we may have to abort
+ String abortButton = "//table[@class='ActionContainer']//div[contains(@onclick, 'action=Abort')]//a[text()='Abort']";
+ click(abortButton);
+ }
+
+ private void installPortlet() throws Throwable
+ {
+ // try several times - to give dependency deployment some time
+ Throwable ex = null;
+ for (int i = 0; i < 3; i++)
+ {
+ importApplications();
+ try
+ {
+ verifyPortletInstalled("portalBookingDemo", "seamBookingPortlet");
+ return;
+ }
+ catch (Throwable th)
+ {
+ ex = th;
+ }
+ }
+ throw ex;
+ }
+
+ @Override
+ protected void exception(Throwable ex)
+ {
+ log.error("Exception during test: ", ex);
+ }
+
+ @Override
+ protected void cleanup()
+ {
+ System.out.println("\n== Cleanup ==");
+
+ try
+ {
+ signOut();
+ }
+ catch (Throwable e)
+ {
+ log.warn("IGNORED: Failed to sign out: ", e);
+ }
+
+ try
+ {
+ signInAsRoot();
+ }
+ catch (Throwable e)
+ {
+ log.warn("IGNORED: Failed to sign in as root: ", e);
+ }
+
+ try
+ {
+ goToPageManagement();
+ searchAndDeletePage("TestPage");
+ }
+ catch (Throwable e)
+ {
+ log.warn("IGNORED: Failed to delete testPage: ", e);
+ }
+
+ try
+ {
+ goToSiteManagement();
+ editNavigation("classic");
+ deleteNode("TestPage");
+ }
+ catch (Throwable e)
+ {
+ log.warn("IGNORED: Failed to remove TestPage from navigation: ", e);
+ }
+
+ try
+ {
+ signOut();
+ }
+ catch (Throwable e)
+ {
+ log.warn("IGNORED: Failed to sign out: ", e);
+ }
+ }
+}
\ No newline at end of file
Added: portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/messages.properties
===================================================================
--- portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/messages.properties (rev 0)
+++ portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/messages.properties 2010-11-09 13:45:48 UTC (rev 4988)
@@ -0,0 +1,49 @@
+#
+# JBoss, Home of Professional Open Source.
+# Copyright 2010, Red Hat Middleware LLC, and individual contributors
+# as indicated by the @author tags. See the copyright.txt file 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.
+#
+
+language.signout.label.vietnamese=\u0110\u0103ng xu\u1EA5t
+language.home.label.vietnamese=Trang ch\u1EE7
+language.label.english.vietnamese=Ti\u1EBFng Anh
+language.changelanguage.label.vietnamese=Thay \u0111\u1ED5i ng\u00F4n ng\u1EEF
+language.apply.button.label.vietnamese=\u00C1p d\u1EE5ng
+language.home.label.french=Accueil
+language.signout.label.french=D\u00E9connexion
+language.label.english.french=Anglais
+language.changelanguage.label.french=Changer la langue
+language.apply.button.label.french=Appliquer
+language.signout.label.german=Abmelden
+language.home.label.german=Startseite
+language.label.english.german=Englisch
+language.changelanguage.label.german=Sprache wechseln
+language.apply.button.label.german=Anwenden
+language.signout.label.italian=Uscita
+language.sitemap.label.italian=Mappa del Sito
+language.label.english.italian=Inglese
+language.changelanguage.label.italian=Cambia Lingua
+language.apply.button.label.italian=Applica
+language.home.label.russian=\u0413\u043B\u0430\u0432\u043D\u0430\u044F
+language.signout.label.russian=\u0412\u044B\u0439\u0442\u0438
+language.signout.label.dutch=Uitloggen
+language.signout.label.spanish=Desconectar
+language.home.label.spanish=Inicio
+passwordconfirm.copiedvalue=\u25CF\u25CF\u25CF\u25CF\u25CF\u25CF\u25CF\u25CF\u25CF\u25CF\u25CF\u25CF\u25CF\u25CF\u25CF
+
Added: portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/navigation/NavigationHelper.java
===================================================================
--- portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/navigation/NavigationHelper.java (rev 0)
+++ portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/navigation/NavigationHelper.java 2010-11-09 13:45:48 UTC (rev 4988)
@@ -0,0 +1,204 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.gatein.selenium.navigation;
+
+import org.jboss.gatein.selenium.AbstractContextual;
+import org.testng.Assert;
+
+import static org.jboss.gatein.selenium.common.CommonHelper.*;
+
+public class NavigationHelper extends AbstractContextual
+{
+
+ public static enum CopyType
+ {
+ COPY, CUT, CLONE;
+ }
+
+ public static void addNewNode(String nodeName, String nodeLabel, boolean useLink, String elementToAddWithRightClick, String pageName, String pageTitle, boolean verifyPage, boolean verifyNode) throws Exception
+ {
+ System.out.println("--Adding new node at navigation--");
+ editNavigation();
+ if (useLink)
+ {
+ waitForElementPresent("link=Add Node");
+ click("link=Add Node");
+ }
+ else
+ {
+ waitForElementPresent(elementToAddWithRightClick);
+ click(elementToAddWithRightClick);
+ pause(2000);
+ contextMenuOnElement(elementToAddWithRightClick);
+ pause(3000);
+ waitForElementPresent("//div[@id='UINavigationManagement']/div[2]/div[3]/div/div/div/div/div/div/div/div[2]/div/div/div//a");
+ click("//div[@id='UINavigationManagement']/div[2]/div[3]/div/div/div/div/div/div/div/div[2]/div/div/div//a");
+ }
+ waitForTextPresent("Page Node Setting");
+ waitForElementPresent("name");
+ type("name", nodeName);
+ type("label", nodeLabel);
+ waitForElementPresent("//div[text() = 'Page Selector']");
+ click("//div[text() = 'Page Selector']");
+ pause(3000);
+ if (pageName != null & pageTitle != null)
+ {
+ System.out.println("--Create new page");
+ waitForElementPresent("pageName");
+ type("pageName", pageName);
+ type("pageTitle", pageTitle);
+ waitForElementPresent("link=Create Page");
+ click("link=Create Page");
+ if (verifyPage)
+ {
+ waitForElementNotPresent("link=Create Page");
+ }
+ else
+ {
+ return;
+ }
+ }
+ else
+ {
+ System.out.println("--Select Page");
+ waitForElementPresent("link=Search and Select Page");
+ click("link=Search and Select Page");
+ waitForElementPresent("//div[@id='UIRepeater']//table//tbody/tr/td[5]/div[@class='ActionContainer']/img");
+ click("//div[@id='UIRepeater']//table//tbody/tr/td[5]/div[@class='ActionContainer']/img");
+ }
+ System.out.println("--Save");
+ waitForElementPresent("link=Save");
+ click("link=Save");
+ if (verifyNode)
+ {
+ waitForTextNotPresent("Page Node Setting");
+ if (elementToAddWithRightClick != null)
+ {
+ waitForElementPresent(elementToAddWithRightClick);
+ click(elementToAddWithRightClick);
+ }
+ waitForElementPresent("//a[@title='" + nodeLabel + "']");
+ waitForElementPresent("link=Save");
+ click("link=Save");
+ waitForTextNotPresent("Navigation Management");
+ waitForElementPresent("link=" + nodeLabel);
+ }
+ }
+
+ public static void deleteNode(String nodeLabel, String navigation) throws Exception
+ {
+ System.out.println("--Deleting node from navigation--");
+ editNavigation();
+ if (navigation != null)
+ {
+ String[] nav = navigation.split("/");
+ for (String navig : nav)
+ {
+ waitForElementPresent("//a[@title='" + navig + "']");
+ click("//a[@title='" + navig + "']");
+ }
+ }
+ deleteNode(nodeLabel);
+ }
+
+ public static void deleteNode(String nodeLabel) throws Exception
+ {
+ System.out.println("--Deleting node from navigation--");
+ waitForElementPresent("//a[@title='" + nodeLabel + "']");
+ pause(2000);
+ contextMenuOnElement("//a[@title='" + nodeLabel + "']");
+ pause(3000);
+ waitForElementPresent("//div[@id='UINavigationNodeSelector']//div[@id='NavigationNodePopupMenu']//a[@class='ItemIcon DeleteNode16x16Icon']");
+ click("//div[@id='UINavigationNodeSelector']//div[@id='NavigationNodePopupMenu']//a[@class='ItemIcon DeleteNode16x16Icon']");
+ waitForConfirmation("Are you sure you want to delete this node?");
+ waitForElementNotPresent("//a[@title='" + nodeLabel + "']");
+ waitForElementPresent("link=Save");
+ click("link=Save");
+ waitForTextNotPresent("Navigation Management");
+ waitForTextNotPresent(nodeLabel);
+ }
+
+ public static void editNavigation() throws Exception
+ {
+ waitForElementPresent("link=Edit Navigation");
+ click("link=Edit Navigation");
+ waitForTextPresent("Navigation Management");
+ }
+
+ public static void editNavigation(String site) throws Exception
+ {
+ System.out.println("--Edit Navigation : " + site + "--");
+ String navLink = "//table[@class='ManagementBlock' and //tr/td/div/text() = '"
+ + site + "']//a[text() = 'Edit Navigation']";
+ waitForElementPresent(navLink);
+ click(navLink);
+ waitForElementPresent("link=Add Node");
+ }
+
+ public static void copyNode(CopyType type, String navigation, String nodeLabel, String pasteToElement, String verifyElement) throws Exception
+ {
+ System.out.println("--" + ("COPY".equals(type.name()) ? "Copy" : "Cut") + " a node--");
+ if (navigation != null)
+ {
+ String[] nav = navigation.split("/");
+ for (String navig : nav)
+ {
+ waitForElementPresent("//a[@title='" + navig + "']");
+ click("//a[@title='" + navig + "']");
+ }
+ }
+ waitForElementPresent("//a[@title='" + nodeLabel + "']");
+ pause(2000);
+ contextMenuOnElement("//div[@id='UINavigationNodeSelector']//a[@class='NodeIcon DefaultPageIcon' and @title='" + nodeLabel + "']");
+ pause(3000);
+ switch (type)
+ {
+ case COPY:
+ waitForElementPresent("link=Copy Node");
+ click("link=Copy Node");
+ break;
+ case CUT:
+ waitForElementPresent("link=Cut Node");
+ click("link=Cut Node");
+ break;
+ case CLONE:
+ waitForElementPresent("link=Clone Node");
+ click("link=Clone Node");
+ break;
+ default:
+ break;
+ }
+ System.out.println("--Paste a node--");
+ waitForElementPresent(pasteToElement);
+ pause(2000);
+ contextMenuOnElement(pasteToElement);
+ pause(3000);
+ waitForElementPresent("//div[@id='UINavigationNodeSelector']//div[@id='NavigationNodePopupMenu']//a[@class='ItemIcon PasteNode16x16Icon']");
+ click("//div[@id='UINavigationNodeSelector']//div[@id='NavigationNodePopupMenu']//a[@class='ItemIcon PasteNode16x16Icon']");
+ if (verifyElement != null)
+ {
+ waitForElementPresent(verifyElement);
+ Assert.assertTrue(isElementPresent(verifyElement));
+ }
+ }
+}
Added: portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/page/PageHelper.java
===================================================================
--- portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/page/PageHelper.java (rev 0)
+++ portal/trunk/testsuite/selenium-tests-other/src/test/java/org/jboss/gatein/selenium/page/PageHelper.java 2010-11-09 13:45:48 UTC (rev 4988)
@@ -0,0 +1,249 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.gatein.selenium.page;
+
+import org.jboss.gatein.selenium.AbstractContextual;
+
+import static org.jboss.gatein.selenium.common.CommonHelper.*;
+
+public class PageHelper extends AbstractContextual
+{
+
+ public static enum PageType
+ {
+ USER, PORTAL, GROUP;
+ }
+
+ public static void editPage() throws Exception
+ {
+ waitForElementPresent("link=Edit Page");
+ click("link=Edit Page");
+ waitForTextPresent("Page Editor");
+ }
+
+ public static void finishPageEdit() throws Exception
+ {
+ waitForElementPresent("//div[@id='UIPageEditor']/div[1]/div/div/div/a[2]");
+ click("//div[@id='UIPageEditor']/div[1]/div/div/div/a[2]");
+ waitForTextNotPresent("Page Editor");
+ }
+
+ public static void addNewPageWithEditorAtFirstLevel(String pageName, String displayName, String categoryTitle, String portletName, String portletElementToDnD) throws Exception
+ {
+ System.out.println("-- Add new page with editor at first level--");
+ waitForElementPresent("link=Add New Page");
+ click("link=Add New Page");
+ waitForElementPresent("//a[@class='LevelUpArrowIcon' and @title='Up Level']");
+ click("//a[@class='LevelUpArrowIcon' and @title='Up Level']");
+ pause(3000);
+ fillPageEditor(pageName, displayName, categoryTitle, portletName, portletElementToDnD);
+ }
+
+ public static void addNewPageWithEditorAtFirstLevelWithMorePortlets(String pageName, String displayName, String categoryTitle, String portletNameSWithPortletElements) throws Exception
+ {
+ System.out.println("-- Add new page with editor at first level with more portlets--");
+ waitForElementPresent("link=Add New Page");
+ click("link=Add New Page");
+ waitForElementPresent("//a[@class='LevelUpArrowIcon' and @title='Up Level']");
+ click("//a[@class='LevelUpArrowIcon' and @title='Up Level']");
+ pause(3000);
+ waitForElementPresent("pageName");
+ type("pageName", pageName);
+ type("pageDisplayName", displayName);
+ click("//table[@class='ActionContainer']/tbody/tr/td/div[2]");
+ waitForTextPresent("Empty Layout");
+ click("//table[@class='ActionContainer']/tbody/tr/td/div[2]");
+ if (categoryTitle != null & portletNameSWithPortletElements != null)
+ {
+ waitForElementPresent("//div[contains(@class, 'Tab')]/a[@title='" + categoryTitle + "']");
+ click("//div[contains(@class, 'Tab')]/a[@title='" + categoryTitle + "']");
+ String[] portlets = portletNameSWithPortletElements.split(";");
+ for (String portlet : portlets)
+ {
+ String[] portletAttributes = portlet.split("---");
+ waitForTextPresent(portletAttributes[0]);
+ pause(3000);
+ dragAndDropToObject(portletAttributes[1], "//div[@class='UIComponentBlock']");
+ pause(3000);
+ }
+ }
+ finishPageEdit();
+ waitForElementPresent("link=classic");
+ }
+
+ public static void addNewPageWithEditor(String navigation, String pageName, String displayName, String categoryTitle, String portletName, String portletElementToDnD) throws Exception
+ {
+ System.out.println("--Add new page with editor--");
+ waitForElementPresent("link=Add New Page");
+ click("link=Add New Page");
+ if (navigation != null)
+ {
+ String[] navig = navigation.split("/");
+ for (String nav : navig)
+ {
+ waitForElementPresent("//a[@title='" + nav + "']");
+ click("//a[@title='" + nav + "']");
+ }
+ }
+ pause(3000);
+ fillPageEditor(pageName, displayName, categoryTitle, portletName, portletElementToDnD);
+ }
+
+ private static void fillPageEditor(String pageName, String displayName, String categoryTitle, String portletName, String portletElementToDnD) throws Exception
+ {
+ waitForElementPresent("pageName");
+ type("pageName", pageName);
+ type("pageDisplayName", displayName);
+ click("//table[@class='ActionContainer']/tbody/tr/td/div[2]");
+ waitForTextPresent("Empty Layout");
+ click("//table[@class='ActionContainer']/tbody/tr/td/div[2]");
+ if (categoryTitle != null & portletName != null & portletElementToDnD != null)
+ {
+ waitForElementPresent("//div[contains(@class, 'Tab')]/a[@title='" + categoryTitle + "']");
+ click("//div[contains(@class, 'Tab')]/a[@title='" + categoryTitle + "']");
+ waitForTextPresent(portletName);
+ pause(3000);
+ dragAndDropToObject(portletElementToDnD, "//div[@class='UIComponentBlock']");
+ pause(3000);
+ }
+ finishPageEdit();
+ waitForElementPresent("link=classic");
+ }
+
+ public static void addNewPageAtPageManagement(String name, String title, PageType type, String groupId, String verifyText) throws Exception
+ {
+ System.out.println("-- Add new " + type.name() + " page at page management--");
+ waitForElementPresent("xpath=//div[@id='UIPageBrowser']/div[2]/table/tbody/tr/td/div/div/div/div/a");
+ click("xpath=//div[@id='UIPageBrowser']/div[2]/table/tbody/tr/td/div/div/div/div/a");
+ waitForTextPresent("Page Setting");
+ waitForElementPresent("name");
+ type("name", name);
+ type("title", title);
+
+ switch (type)
+ {
+ case USER:
+ break;
+ case PORTAL:
+ waitForElementPresent("ownerType");
+ select("ownerType", "label=portal");
+ waitForElementPresent("//option[@value='portal']");
+ waitForElementPresent("//div[@onclick=\"eXo.webui.UIHorizontalTabs.changeTabForUIFormTabpane(this, 'UIPageForm', 'PermissionSetting');javascript:eXo.webui.UIForm.submitEvent('UIPageForm','SelectTab','&objectId=PermissionSetting')\"]");
+ click("//div[@onclick=\"eXo.webui.UIHorizontalTabs.changeTabForUIFormTabpane(this, 'UIPageForm', 'PermissionSetting');javascript:eXo.webui.UIForm.submitEvent('UIPageForm','SelectTab','&objectId=PermissionSetting')\"]");
+ waitForElementPresent("link=Access Permission Setting");
+ click("link=Access Permission Setting");
+ waitForElementPresent("link=Edit Permission Setting");
+ click("link=Edit Permission Setting");
+ break;
+ case GROUP:
+ waitForElementPresent("ownerType");
+ select("ownerType", "label=group");
+ waitForElementPresent("xpath=//option[@value='group']");
+ pause(5000);
+ waitForElementPresent("ownerId");
+ if (groupId != null)
+ {
+ select("ownerId", "label=" + groupId);
+ waitForElementPresent("//option[@value='" + groupId + "']");
+ }
+ waitForElementPresent("//div[@onclick=\"eXo.webui.UIHorizontalTabs.changeTabForUIFormTabpane(this, 'UIPageForm', 'PermissionSetting');javascript:eXo.webui.UIForm.submitEvent('UIPageForm','SelectTab','&objectId=PermissionSetting')\"]");
+ click("//div[@onclick=\"eXo.webui.UIHorizontalTabs.changeTabForUIFormTabpane(this, 'UIPageForm', 'PermissionSetting');javascript:eXo.webui.UIForm.submitEvent('UIPageForm','SelectTab','&objectId=PermissionSetting')\"]");
+ waitForElementPresent("link=Access Permission Setting");
+ click("link=Access Permission Setting");
+ waitForElementPresent("link=Edit Permission Setting");
+ click("link=Edit Permission Setting");
+ break;
+ default:
+ break;
+ }
+ waitForElementPresent("//div[@onclick=\"eXo.webui.UIHorizontalTabs.changeTabForUIFormTabpane(this, 'UIPageForm', 'UIPageTemplateOptions');javascript:eXo.webui.UIForm.submitEvent('UIPageForm','SelectTab','&objectId=UIPageTemplateOptions')\"]");
+ click("//div[@onclick=\"eXo.webui.UIHorizontalTabs.changeTabForUIFormTabpane(this, 'UIPageForm', 'UIPageTemplateOptions');javascript:eXo.webui.UIForm.submitEvent('UIPageForm','SelectTab','&objectId=UIPageTemplateOptions')\"]");
+ waitForElementPresent("link=Save");
+ click("link=Save");
+ if (verifyText != null)
+ {
+ waitForTextNotPresent("Page Setting");
+ waitForTextPresent(verifyText);
+ }
+ }
+
+ public static void searchPageByTitle(String title, String verifyText) throws Exception
+ {
+ System.out.println("--Searching page: " + title + "--");
+ waitForElementPresent("searchTerm");
+ type("searchTerm", title);
+ select("searchOption", "label=Title");
+ waitForElementPresent("xpath=//form[@id='UIPageSearch']/div[2]/a");
+ click("xpath=//form[@id='UIPageSearch']/div[2]/a");
+ pause(3000);
+ if (verifyText != null)
+ {
+ waitForTextPresent(verifyText);
+ }
+ }
+
+ private static void deletePage(String title, boolean closeDialog, String verifyText) throws Exception
+ {
+ System.out.println("--Delete page: " + title + "--");
+ String delButton = "//tbody[@class='FeedBox']//tr[*/div[@title='" + title + "']]//img[@title='Delete Page' and contains(@onclick, 'op=Delete')]";
+ waitForElementPresent(delButton);
+ click(delButton);
+ waitForConfirmation("Do you want to delete this page?");
+ if (verifyText != null)
+ {
+ waitForTextNotPresent(verifyText);
+ }
+ if (closeDialog)
+ {
+ closeMessageDialog();
+ }
+ }
+
+ public static void deletePage(String name, String title, boolean closeDialog, String verifyText) throws Exception
+ {
+ System.out.println("--Delete page: " + title + "--");
+ waitForElementPresent("xpath=//img[@title='Delete Page' and contains(@onclick, 'op=Delete') and contains(@onclick, '" + name + "')]");
+ click("xpath=//img[@title='Delete Page' and contains(@onclick, 'op=Delete') and contains(@onclick, '" + name + "')]");
+ waitForConfirmation("Do you want to delete this page?");
+ if (verifyText != null)
+ {
+ waitForTextNotPresent(verifyText);
+ }
+ if (closeDialog)
+ {
+ closeMessageDialog();
+ }
+ }
+
+ public static void searchAndDeletePage(String name, String title, boolean closeDialog, String verifyText) throws Exception
+ {
+ searchPageByTitle(title, verifyText);
+ deletePage(name, title, closeDialog, verifyText);
+ }
+
+ public static void searchAndDeletePage(String title) throws Exception
+ {
+ searchPageByTitle(title, null);
+ deletePage(title, false, null);
+ }
+}
Added: portal/trunk/testsuite/selenium-tests-other/src/test/resources/org/jboss/gatein/selenium/jira/Test_GTNPORTAL_1257_SeamSessionOutlivesTheGateInSession-build.xml
===================================================================
--- portal/trunk/testsuite/selenium-tests-other/src/test/resources/org/jboss/gatein/selenium/jira/Test_GTNPORTAL_1257_SeamSessionOutlivesTheGateInSession-build.xml (rev 0)
+++ portal/trunk/testsuite/selenium-tests-other/src/test/resources/org/jboss/gatein/selenium/jira/Test_GTNPORTAL_1257_SeamSessionOutlivesTheGateInSession-build.xml 2010-11-09 13:45:48 UTC (rev 4988)
@@ -0,0 +1,121 @@
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file 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.
+ -->
+
+<project default="deploy" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <path id="maven-ant-tasks.classpath"
+ path="${localRepository}/org/apache/maven/maven-ant-tasks/2.1.1/maven-ant-tasks-2.1.1.jar"/>
+ <typedef resource="org/apache/maven/artifact/ant/antlib.xml"
+ uri="antlib:org.apache.maven.artifact.ant"
+ classpathref="maven-ant-tasks.classpath"/>
+
+ <property name="scm.url" value="scm:svn:http://anonsvn.jboss.org/repos/portletbridge/tags/2.1.0.CR1/examples" />
+
+ <property name="deploy.dir" value="${container.config.deploy}" />
+ <dirname property="antfile.dir" file="${ant.file}"/>
+ <property name="testRoot.dir" value="${antfile.dir}" />
+ <property name="checkout.dir" value="${testRoot.dir}/checkout" />
+
+ <property name="bookingEar.dir" value="${testRoot.dir}/bookingEar" />
+ <property name="bookingEar.name" value="seamEAR.ear" />
+
+ <property name="bookingEar.location" value="${bookingEar.dir}/${bookingEar.name}" />
+ <property name="bookingEar.deploy.location" value="${deploy.dir}/${bookingEar.name}" />
+
+ <property name="bookingEar.groupId" value="org.jboss.portletbridge.examples.seam.booking" />
+ <property name="bookingEar.artifactId" value="seamBooking-ear" />
+ <property name="bookingEar.version" value="2.1.0.CR1" />
+ <property name="bookingEar.artifact" value="${bookingEar.artifactId}-${bookingEar.version}.ear" />
+
+ <property name="bookingEar.repo.group.path" value="org/jboss/portletbridge/examples/seam/booking" />
+ <property name="bookingEar.repo.path" value="${bookingEar.repo.group.path}/${bookingEar.artifactId}/${bookingEar.version}/${bookingEar.artifact}" />
+
+
+ <macrodef name="check-ear-available">
+ <attribute name="property" />
+ <sequential>
+ <!-- check if ear artifact exists in local repository -->
+ <copy tofile="${bookingEar.location}" file="${localRepository}/${bookingEar.repo.path}"
+ preservelastmodified="true" failonerror="false" />
+ <available file="${bookingEar.location}" property="@{property}"/>
+ </sequential>
+ </macrodef>
+
+ <macrodef name="check-uptodate">
+ <attribute name="property" />
+ <sequential>
+ <!-- if ear artifact exists in deploy, check if it’s up-to-date -->
+ <uptodate srcfile="${bookingEar.location}"
+ targetfile="${bookingEar.deploy.location}" property="@{property}"/>
+ </sequential>
+ </macrodef>
+
+ <target name="init">
+ <mkdir dir="${bookingEar.dir}"/>
+ <available file="${bookingEar.deploy.location}" property="build.not.required"/>
+ </target>
+
+ <target name="check-ear-exists-before" unless="build.not.required" depends="init">
+ <check-ear-available property="bookingEar.present"/>
+ </target>
+
+ <target name="check-uptodate-before" if="bookingEar.present" depends="check-ear-exists-before">
+ <check-uptodate property="bookingEar.uptodate"/>
+ </target>
+
+ <target name="check-ear-exists-after">
+ <check-ear-available property="bookingEar.present"/>
+ </target>
+
+ <target name="check-uptodate-after" if="bookingEar.present" depends="check-ear-exists-after">
+ <check-uptodate property="bookingEar.uptodate"/>
+ </target>
+
+ <target name="check-build-required" depends="check-uptodate-before">
+ <condition property="build.not.required">
+ <and>
+ <not>
+ <isset property="build.not.required"/>
+ </not>
+ <isset property="bookingEar.present"/>
+ </and>
+ </condition>
+ </target>
+
+ <target name="ensure-ear" unless="build.not.required" depends="check-build-required">
+ <!-- if ear artifact doesn’t exist or is not up-to-date - download and build/install the examples -->
+ <artifact:mvn mavenHome="${maven.home}">
+ <arg value="scm:bootstrap"/>
+ <arg value="-DconnectionUrl=${scm.url}"/>
+ <arg value="-Dbasedir=${testRoot.dir}"/>
+ <arg value="-DcheckoutDirectory=${checkout.dir}"/>
+ <arg value="-Dgoals=install"/>
+ </artifact:mvn>
+ </target>
+
+ <target name="deploy" if="bookingEar.present" unless="bookingEar.uptodate"
+ depends="ensure-ear,check-uptodate-after">
+
+ <copy file="${bookingEar.location}" tofile="${bookingEar.deploy.location}" preservelastmodified="true"/>
+ </target>
+
+</project>
Added: portal/trunk/testsuite/selenium-tests-other/src/test/resources/testng.xml
===================================================================
--- portal/trunk/testsuite/selenium-tests-other/src/test/resources/testng.xml (rev 0)
+++ portal/trunk/testsuite/selenium-tests-other/src/test/resources/testng.xml 2010-11-09 13:45:48 UTC (rev 4988)
@@ -0,0 +1,43 @@
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file 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.
+ -->
+
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
+<suite name="GateIn_Selenium_tests">
+
+ <listeners>
+ <listener class-name="org.jboss.gatein.selenium.TestCaseFailListener" />
+ </listeners>
+
+ <test name="JiraTests">
+ <groups>
+ <run>
+ <include name="jira" />
+ <exclude name="broken" />
+ </run>
+ </groups>
+ <packages>
+ <package name="org.jboss.gatein.selenium.jira.*" />
+ </packages>
+ </test>
+
+
+</suite>
\ No newline at end of file
14 years, 2 months
gatein SVN: r4987 - in portal/trunk/docs/reference-guide/en: modules and 1 other directory.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2010-11-09 08:22:09 -0500 (Tue, 09 Nov 2010)
New Revision: 4987
Modified:
portal/trunk/docs/reference-guide/en/images/WSRP/config_init.png
portal/trunk/docs/reference-guide/en/images/WSRP/consumer_operations.png
portal/trunk/docs/reference-guide/en/modules/WSRP.xml
Log:
- GTNWSRP-145: Updated for WSRP 2 changes, minor fixes, still need to write the import/export walkthrough.
Modified: portal/trunk/docs/reference-guide/en/images/WSRP/config_init.png
===================================================================
(Binary files differ)
Modified: portal/trunk/docs/reference-guide/en/images/WSRP/consumer_operations.png
===================================================================
(Binary files differ)
Modified: portal/trunk/docs/reference-guide/en/modules/WSRP.xml
===================================================================
--- portal/trunk/docs/reference-guide/en/modules/WSRP.xml 2010-11-09 13:12:06 UTC (rev 4986)
+++ portal/trunk/docs/reference-guide/en/modules/WSRP.xml 2010-11-09 13:22:09 UTC (rev 4987)
@@ -52,14 +52,13 @@
<para>On the Consumer side, &PRODUCT_NAME; provides a Medium level of support for WSRP, except that we only handle
HTML markup (as &PRODUCT_NAME; itself doesn't handle other markup types). We do support explicit portlet
- cloning and
- we fully support the PortletManagement interface.
+ cloning and we fully support the PortletManagement interface.
</para>
<para>As far as caching goes, we have Level 1 Producer and Consumer. We support Cookie handling properly on the
Consumer and our Producer requires initialization of cookies (as we have found that it improved interoperabilty
- with some consumers). We don't support custom window states or modes, as Portal doesn't either. We do, however,
- support CSS on both the Producer (though it's more a function of the portlets than inherent Producer
+ with some consumers). We don't support custom window states or modes, as &PRODUCT_NAME; doesn't either. We do,
+ however, support CSS on both the Producer (though it's more a function of the portlets than inherent Producer
capability) and Consumer.
</para>
@@ -69,6 +68,11 @@
Committee and Community at large).
</para>
+ <para>New for &PRODUCT_VERSION; of &PRODUCT_NAME; is support of WSRP 2.0 with a complete implementation of
+ the non-optional features. The only thing that we have not implemented is support for lifetimes and leasing
+ support.
+ </para>
+
<note>
<para>As of version &PRODUCT_VERSION; of &PRODUCT_NAME;, WSRP is only activated and supported
when &PRODUCT_NAME; is deployed on JBoss Application Server.
@@ -308,7 +312,9 @@
<para>
&PRODUCT_NAME;'s Producer is automatically set up when you deploy a portal instance with the WSRP service.
You can access the WSDL file at
- <filename>http://{hostname}:{port}/wsrp-producer/MarkupService?wsdl</filename>.
+ <filename>http://{hostname}:{port}/wsrp-producer/v2/MarkupService?wsdl</filename>. If you wish to use only the
+ WSRP 1 compliant version of the producer, please use the WSDL file found at
+ <filename>http://{hostname}:{port}/wsrp-producer/v1/MarkupService?wsdl</filename>.
The default hostname is
<literal>localhost</literal>
and the default port is 8080.
@@ -328,12 +334,6 @@
Once a remote producer has been configured, the portlets that it exposes are then available in the
Application Registry to be added to categories and then to pages.
</para>
- <para>
- As a way to test the WSRP producer service and to check that the portlets that you want to expose remotely
- are correctly published via WSRP, a default consumer named
- <literal>self</literal>, that consumes the portlets exposed by &PRODUCT_NAME;'s producer,
- has been configured.
- </para>
</sect2>
<sect2>
@@ -350,7 +350,8 @@
Some WSRP producers do not support chunked encoding that is activated by default by JBoss WS. If your
producer does not support chunked encoding, your consumer will not be able to properly connect to the
producer. This will manifest itself with the following error:
- <code>Caused by: org.jboss.ws.WSException: Invalid HTTP server response [503] - Service Unavailable</code>.
+ <code>Caused by: org.jboss.ws.WSException: Invalid HTTP server response [503] - Service
+ Unavailable</code>.
Please see this GateIn's
<ulink url="http://community.jboss.org/wiki/Workaroundwhenchunkedencodingisnotsupported">wiki page</ulink>
for more details.
@@ -361,28 +362,16 @@
<title>Using the configuration portlet</title>
<para>
&PRODUCT_NAME; provides a portlet to configure access (among other functions) to remote WSRP Producers
- grahically. It isn't, however, installed by default, so the first thing we will need to do is to install
- the WSRP configuration portlet using the Application Registry.
- </para>
-
- <para>
- Use the usual procedure to log in as a Portal administrator and go to the Application Registry.
- With the default install, you can just go to
+ grahically. Starting with &PRODUCT_VERSION;, the WSRP configuration portlet is installed by default. You
+ can find it at
<ulink
- url="http://localhost:8080/portal/login?initialURI=%2Fportal%2Fprivate%2Fclass...">
- http://localhost:8080/portal/login?initialURI=%2Fportal%2Fprivate%2Fclass...
+ url="http://localhost:8080/portal/login?initialURI=%2Fportal%2Fprivate%2Fclass...">
+ http://localhost:8080/portal/login?initialURI=%2Fportal%2Fprivate%2Fclass...
</ulink>
- Add the WSRP Configuration portlet to the Administration category. If you use the Import Applications
- functionality, the WSRP Configuration portlet will be automatically added to the Administration category.
</para>
+
<para>
- Now that the portlet is added to a category, it can be added to a page and used. We recommend adding it
- to the same page as the Application Registry as operations relating to WSRP and adding portlets to
- categories are somewhat related as we will see. Go ahead and add the WSRP Configuration portlet to the
- page using the standard procedure.
- </para>
- <para>
- If all went well, you should see something similar to this:
+ You should see a screen similar to:
<mediaobject>
<imageobject>
<imagedata fileref="images/WSRP/config_init.png" format="PNG" align="center" valign="middle"
@@ -398,9 +387,34 @@
that could potentially invalidate it, thus requiring re-validation of the information.
</para>
+ <note>
+ <para>
+ The WSRP configuration didn't use to be installed by default in previous versions of &PRODUCT_NAME;.
+ We include here the legacy instructions on how to install this portlet in case you ever need to
+ re-install it.
+ </para>
+ <para>
+ Use the usual procedure to log in as a Portal administrator and go to the Application
+ Registry. With the default install, you can just go to
+ <ulink
+ url="http://localhost:8080/portal/login?initialURI=%2Fportal%2Fprivate%2Fclass...">
+ http://localhost:8080/portal/login?initialURI=%2Fportal%2Fprivate%2Fclass...
+ </ulink>
+ Add the WSRP Configuration portlet to the Administration category. If you use the Import Applications
+ functionality, the WSRP Configuration portlet will be automatically added to the Administration
+ category.
+ </para>
+ <para>
+ Now that the portlet is added to a category, it can be added to a page and used. We recommend adding
+ it to the same page as the Application Registry as operations relating to WSRP and adding portlets to
+ categories are somewhat related as we will see. Go ahead and add the WSRP Configuration portlet to the
+ page using the standard procedure.
+ </para>
+ </note>
+
<para>
- Next, we create a new Consumer which we will call<literal>oracle</literal>. Type "<literal>
- oracle</literal>" in
+ Next, we create a new Consumer which we will call <literal>oracle</literal>. Type
+ "<literal>oracle</literal>" in
the "Create a consumer named:" field then click on "Create consumer":
<mediaobject>
<imageobject>
@@ -477,7 +491,7 @@
xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_wsrp_consumer_1_0 http://www.jboss.org/portal/xsd/gatein_wsrp_consumer_1_0.xsd">
<deployment>
<wsrp-producer id="self" expiration-cache="300" ws-timeout="30000">
- <endpoint-wsdl-url>http://localhost:8080/wsrp-producer/MarkupService?wsdl</endpoint-wsdl-url>
+ <endpoint-wsdl-url>http://localhost:8080/wsrp-producer/v2/MarkupService?wsdl</endpoint-wsdl-url>
<registration-data>
<property>
<name>email</name>
@@ -507,7 +521,7 @@
</sect3>
<sect3>
- <title>Configuring access to a remote portlet</title>
+ <title>Adding remote portlets to categories</title>
<para>
If we go back to the Application Registry and examine the available portlets by clicking on the
Portlet link, you will now be able to see the remote portlets if you click on the REMOTE tab in the left
@@ -560,7 +574,7 @@
<para>It is important to note how the XML consumers configuration file is processed. It is read the first
time the WSRP service starts and the associated information is then put under control of JCR (Java
Content Repository). Subsequent launches of the WSRP service will use the JCR-stored information for
- all producers are already known to &PRODUCT_NAME;. More specifically,
+ all producers already known to &PRODUCT_NAME;. More specifically, the
<filename>wsrp-consumers-config.xml</filename>
file is scanned for producer identifiers.
Any identifier that is already known will be bypassed and the JCR information associated with this
@@ -671,10 +685,10 @@
<para>
Here is the configuration of the
- <literal>self</literal>
- producer as found in
- <filename>default-wsrp.xml</filename>
- with a cache expiring every five minutes and with a 30 second timeout for web service operations.
+ <literal>selfv1</literal> and <literal>selfv2</literal>
+ producers as found in
+ <filename>$GATEIN_HOME/lib/wsrp-consumer-$WSRP_VERSION.jar/conf/wsrp-consumers-config.xml</filename>
+ with a cache expiring every 500 seconds and with a 50 second timeout for web service operations.
</para>
<example>
@@ -685,11 +699,17 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_wsrp_consumer_1_0 http://www.jboss.org/portal/xsd/gatein_wsrp_consumer_1_0.xsd">
<deployment>
- <wsrp-producer id="self" expiration-cache="300" ws-timeout="30000">
- <endpoint-wsdl-url>http://localhost:8080/wsrp-producer/MarkupService?wsdl</endpoint-wsdl-url>
+ <wsrp-producer id="selfv1" expiration-cache="500" ws-timeout="50000">
+ <endpoint-wsdl-url>http://localhost:8080/wsrp-producer/v1/MarkupService?wsdl</endpoint-wsdl-url>
<registration-data/>
</wsrp-producer>
</deployment>
+ <deployment>
+ <wsrp-producer id="selfv2" expiration-cache="500" ws-timeout="50000">
+ <endpoint-wsdl-url>http://localhost:8080/wsrp-producer/v2/MarkupService?wsdl</endpoint-wsdl-url>
+ <registration-data/>
+ </wsrp-producer>
+ </deployment>
</deployments>]]>
</programlisting>
</para>
@@ -840,7 +860,7 @@
</mediaobject>
<note>
- <para>As of WSRP 1, it is rather difficult to ascertain for sure what caused an
+ <para>WSRP 1 makes it rather difficult to ascertain for sure what caused an
<exceptionname>OperationFailedFault</exceptionname>
as it is the generic exception returned by
producers if something didn't quite happen as expected during a method invocation. This means that
@@ -890,13 +910,41 @@
</para>
</listitem>
<listitem>
- <para>Delete: destroys the consumer, after deregisterting it if it was registered</para>
+ <para>Delete: destroys the consumer, after deregistering it if it was registered</para>
</listitem>
+ <listitem>
+ <para>Export: exports some or all of the consumer's portlets to be able to later import them in a
+ different context
+ </para>
+ </listitem>
+ <listitem>
+ <para>Import: imports some or all of previously exported portlets</para>
+ </listitem>
</itemizedlist>
</para>
+ <note>
+ <para>Import/Export functionalities are only available to WSRP 2 consumers. Import functionality is only
+ available if portlets had previously been exported.
+ </para>
+ </note>
</sect2>
<sect2>
+ <title>Importing and exporting portlets</title>
+ <para>Import and export are new functionalities added in WSRP 2. Exporting a portlet allows a consumer to get
+ an opaque representation of the portlet which can then be use by the corresponding import operation to
+ reconstitute it. This is mostly used in migration scenarios during batch operations. Since &PRODUCT_NAME;
+ does not currently support automated migration of portal data, the functionality that we provide as part of
+ WSRP 2 is necessarily less complete than it could be with full portal support.
+ </para>
+ <para>The import/export implementation in &PRODUCT; allows users to export portlets from a given consumer and
+ then import them back to replace existing portlets assigned to windows on pages by the previously exported
+ portlets. Let us walk through an example to make things clearer.
+ </para>
+ <para>***** TODO: walk-through exporting portlets and then importing them</para>
+ </sect2>
+
+ <sect2>
<title>Erasing local registration data</title>
<para>
There are rare cases where it might be required to erase the local information without being able to
14 years, 2 months
gatein SVN: r4986 - components/wsrp/trunk/admin-gui/src/main/webapp/jsf/consumers/exports.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2010-11-09 08:12:06 -0500 (Tue, 09 Nov 2010)
New Revision: 4986
Modified:
components/wsrp/trunk/admin-gui/src/main/webapp/jsf/consumers/exports/export.xhtml
Log:
- Fixed improper formatting change. >_<
Modified: components/wsrp/trunk/admin-gui/src/main/webapp/jsf/consumers/exports/export.xhtml
===================================================================
--- components/wsrp/trunk/admin-gui/src/main/webapp/jsf/consumers/exports/export.xhtml 2010-11-09 13:11:00 UTC (rev 4985)
+++ components/wsrp/trunk/admin-gui/src/main/webapp/jsf/consumers/exports/export.xhtml 2010-11-09 13:12:06 UTC (rev 4986)
@@ -41,8 +41,7 @@
</h:column>
<h:column>
- <f:facet name="header">#{i18n.
- portlets_table_column_portlet_name}</f:facet>
+ <f:facet name="header">#{i18n.portlets_table_column_portlet_name}</f:facet>
#{portlet.handle}
</h:column>
</h:dataTable>
14 years, 2 months
gatein SVN: r4985 - in components/wsrp/trunk: admin-gui/src/main/webapp/jsf/consumers/exports and 3 other directories.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2010-11-09 08:11:00 -0500 (Tue, 09 Nov 2010)
New Revision: 4985
Modified:
components/wsrp/trunk/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ConsumerBean.java
components/wsrp/trunk/admin-gui/src/main/webapp/jsf/consumers/exports/export.xhtml
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/WSRPConsumer.java
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/WSRPConsumerImpl.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockWSRPConsumer.java
Log:
- GTNWSRP-153: Added releaseExport operation on WSRPConsumer and call to it in ConsumerBean.deleteExport.
- GTNWSRP-154: Disabled export button by default and made ConsumerBean decide whether the button can be activated or not based on whether or not portlets have been selected to be exported.
Modified: components/wsrp/trunk/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ConsumerBean.java
===================================================================
--- components/wsrp/trunk/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ConsumerBean.java 2010-11-09 11:14:17 UTC (rev 4984)
+++ components/wsrp/trunk/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ConsumerBean.java 2010-11-09 13:11:00 UTC (rev 4985)
@@ -539,6 +539,20 @@
}
}
+ public boolean isReadyForExport()
+ {
+ List<SelectablePortletHandle> handles = (List<SelectablePortletHandle>)portletHandles.getWrappedData();
+ for (SelectablePortletHandle handle : handles)
+ {
+ if (handle.isSelected())
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
public String exportPortlets()
{
if (consumer != null)
@@ -650,6 +664,20 @@
ExportInfo export = currentExport.getExport();
if (consumer.getMigrationService().remove(export) == export)
{
+ // release the export on the producer
+ try
+ {
+ consumer.releaseExport(export);
+ }
+ catch (PortletInvokerException e)
+ {
+ // re-add export to migration service
+ consumer.getMigrationService().add(export);
+
+ beanContext.createErrorMessageFrom(e);
+ return null;
+ }
+
existingExports = null; // force rebuild of export list
currentExport = null;
}
@@ -781,6 +809,9 @@
public void select(ValueChangeEvent event)
{
selected = (Boolean)event.getNewValue();
+
+ // bypass the rest of the life cycle and re-display page
+ FacesContext.getCurrentInstance().renderResponse();
}
public int compareTo(SelectablePortletHandle o)
Modified: components/wsrp/trunk/admin-gui/src/main/webapp/jsf/consumers/exports/export.xhtml
===================================================================
--- components/wsrp/trunk/admin-gui/src/main/webapp/jsf/consumers/exports/export.xhtml 2010-11-09 11:14:17 UTC (rev 4984)
+++ components/wsrp/trunk/admin-gui/src/main/webapp/jsf/consumers/exports/export.xhtml 2010-11-09 13:11:00 UTC (rev 4985)
@@ -36,11 +36,13 @@
<h:column>
<f:facet name="header">#{i18n.portlets_table_column_include}</f:facet>
- <h:selectBooleanCheckbox value="#{portlet.selected}"/>
+ <h:selectBooleanCheckbox value="#{portlet.selected}" valueChangeListener="#{portlet.select}"
+ immediate="true" onclick="this.form.submit()"/>
</h:column>
<h:column>
- <f:facet name="header">#{i18n.portlets_table_column_portlet_name}</f:facet>
+ <f:facet name="header">#{i18n.
+ portlets_table_column_portlet_name}</f:facet>
#{portlet.handle}
</h:column>
</h:dataTable>
@@ -51,7 +53,8 @@
<div class="ButtonRight">
<div class="ButtonMiddle">
<h:commandButton id="exportButton" action="#{consumer.exportPortlets}"
- value="#{i18n.portlets_table_export}"/>
+ value="#{i18n.portlets_table_export}"
+ disabled="#{! consumer.readyForExport}"/>
</div>
</div>
</div>
Modified: components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/WSRPConsumer.java
===================================================================
--- components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/WSRPConsumer.java 2010-11-09 11:14:17 UTC (rev 4984)
+++ components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/WSRPConsumer.java 2010-11-09 13:11:00 UTC (rev 4985)
@@ -130,6 +130,8 @@
ExportInfo exportPortlets(List<String> portletHandles) throws PortletInvokerException;
+ void releaseExport(ExportInfo exportInfo) throws PortletInvokerException;
+
MigrationService getMigrationService();
boolean isSupportsExport();
Modified: components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/WSRPConsumerImpl.java
===================================================================
--- components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/WSRPConsumerImpl.java 2010-11-09 11:14:17 UTC (rev 4984)
+++ components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/WSRPConsumerImpl.java 2010-11-09 13:11:00 UTC (rev 4985)
@@ -883,6 +883,13 @@
}
}
+ public void releaseExport(ExportInfo exportInfo) throws PortletInvokerException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(exportInfo, "ExportInfo to release");
+
+ getPortletManagementService().releaseExport(getRegistrationContext(), exportInfo.getExportContext(), UserAccess.getUserContext());
+ }
+
public ImportInfo importPortlets(ExportInfo exportInfo, List<String> portlets) throws PortletInvokerException
{
ParameterValidation.throwIllegalArgExceptionIfNull(exportInfo, "ExportInfo to import from");
Modified: components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockWSRPConsumer.java
===================================================================
--- components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockWSRPConsumer.java 2010-11-09 11:14:17 UTC (rev 4984)
+++ components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockWSRPConsumer.java 2010-11-09 13:11:00 UTC (rev 4985)
@@ -171,6 +171,11 @@
throw new NotYetImplemented();
}
+ public void releaseExport(ExportInfo exportInfo)
+ {
+ throw new NotYetImplemented();
+ }
+
public MigrationService getMigrationService()
{
throw new NotYetImplemented();
14 years, 2 months