Author: chris.laprun(a)jboss.com
Date: 2009-11-10 10:45:52 -0500 (Tue, 10 Nov 2009)
New Revision: 551
Modified:
components/pc/trunk/api/src/main/java/org/gatein/pc/api/spi/PortalContext.java
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/spi/AbstractPortalContext.java
components/pc/trunk/test/src/test/java/org/gatein/pc/test/portlet/jsr168/api/portalcontext/PortalInfoTestCase.java
Log:
- GTNPC-12:
+ Used correct PortalContext.VERSION.
+ Added documentation and PortalContext.PORTLET_SPEC_FORMAT to properly format version
String to conform to spec.
+ Updated PortalInfoTestCase to be more precise.
Modified: components/pc/trunk/api/src/main/java/org/gatein/pc/api/spi/PortalContext.java
===================================================================
---
components/pc/trunk/api/src/main/java/org/gatein/pc/api/spi/PortalContext.java 2009-11-10
14:59:32 UTC (rev 550)
+++
components/pc/trunk/api/src/main/java/org/gatein/pc/api/spi/PortalContext.java 2009-11-10
15:45:52 UTC (rev 551)
@@ -36,10 +36,10 @@
*/
public interface PortalContext
{
- public static final Version VERSION = new Version("GateIn Portlet
Container", 2, 1, 0, new Version.Qualifier(Version.Qualifier.Prefix.SNAPSHOT),
"Community");
+ public static final Version VERSION = new Version("GateIn Portlet
Container", 2, 1, 0, new Version.Qualifier(Version.Qualifier.Prefix.CR,
Version.Qualifier.Suffix.SUFFIX_1), "Community");
/**
- * Return info about the portal.
+ * Return info about the portal. Must conform to
javax.portlet.PortalContext.getPortalInfo().
*
* @return portal infos
*/
@@ -65,4 +65,18 @@
* @return the properties
*/
Map<String, String> getProperties();
+
+ Version.Format PORTLET_SPEC_FORMAT = new Version.Format()
+ {
+ public String toString(Version version)
+ {
+ StringBuffer buffer = new StringBuffer(version.getName());
+ buffer.append("/")
+ .append(version.getMajor()).append('.')
+ .append(version.getMinor()).append('.')
+ .append(version.getPatch()).append('-')
+ .append(version.getQualifier());
+ return buffer.toString();
+ }
+ };
}
Modified:
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/spi/AbstractPortalContext.java
===================================================================
---
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/spi/AbstractPortalContext.java 2009-11-10
14:59:32 UTC (rev 550)
+++
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/spi/AbstractPortalContext.java 2009-11-10
15:45:52 UTC (rev 551)
@@ -87,7 +87,7 @@
public String getInfo()
{
- return VERSION.toString();
+ return PortalContext.PORTLET_SPEC_FORMAT.toString(VERSION);
}
public Set<WindowState> getWindowStates()
Modified:
components/pc/trunk/test/src/test/java/org/gatein/pc/test/portlet/jsr168/api/portalcontext/PortalInfoTestCase.java
===================================================================
---
components/pc/trunk/test/src/test/java/org/gatein/pc/test/portlet/jsr168/api/portalcontext/PortalInfoTestCase.java 2009-11-10
14:59:32 UTC (rev 550)
+++
components/pc/trunk/test/src/test/java/org/gatein/pc/test/portlet/jsr168/api/portalcontext/PortalInfoTestCase.java 2009-11-10
15:45:52 UTC (rev 551)
@@ -22,20 +22,22 @@
******************************************************************************/
package org.gatein.pc.test.portlet.jsr168.api.portalcontext;
+import org.gatein.pc.api.spi.PortalContext;
+import org.gatein.pc.test.portlet.framework.UTP1;
+import org.gatein.pc.test.unit.Assertion;
import org.gatein.pc.test.unit.PortletTestCase;
import org.gatein.pc.test.unit.PortletTestContext;
import org.gatein.pc.test.unit.actions.PortletRenderTestAction;
-import org.gatein.pc.test.portlet.framework.UTP1;
import org.gatein.pc.test.unit.annotations.TestCase;
-import org.gatein.pc.test.unit.Assertion;
import org.jboss.unit.driver.DriverResponse;
import org.jboss.unit.driver.response.EndTestResponse;
-import static org.jboss.unit.api.Assert.assertTrue;
import javax.portlet.Portlet;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
+import static org.jboss.unit.api.Assert.assertTrue;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
@@ -52,8 +54,14 @@
String info = request.getPortalContext().getPortalInfo();
assertTrue(info.length() > 0);
- assertTrue(info.startsWith("JBossPortal"));
+ String[] components = info.split("/");
+ assertTrue(components.length == 2);
+ assertTrue(PortalContext.VERSION.getName().equals(components[0]));
+ String version = PortalContext.VERSION.getMajor() + "." +
PortalContext.VERSION.getMinor() + "."
+ + PortalContext.VERSION.getPatch() + "-" +
PortalContext.VERSION.getQualifier();
+ assertTrue(version.equals(components[1]));
+
return new EndTestResponse();
}
});