Author: julien(a)jboss.com
Date: 2008-03-18 19:30:27 -0400 (Tue, 18 Mar 2008)
New Revision: 10320
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerCapabilitiesInfo.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/info/CapabilitiesInfo.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/support/info/CapabilitiesInfoSupport.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/ContentTypesTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/info/CapabilitiesInfoTest.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/info/ModeInfoTest.java
Log:
updated portlet module to use the new media type and media type map
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerCapabilitiesInfo.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerCapabilitiesInfo.java 2008-03-18
22:44:34 UTC (rev 10319)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerCapabilitiesInfo.java 2008-03-18
23:30:27 UTC (rev 10320)
@@ -24,15 +24,13 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
+import org.jboss.portal.common.net.media.MediaTypeMapImpl;
+import org.jboss.portal.common.net.media.MediaType;
import org.jboss.portal.portlet.info.CapabilitiesInfo;
import org.jboss.portal.portlet.info.ModeInfo;
import org.jboss.portal.portlet.info.WindowStateInfo;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
import java.util.HashSet;
-import java.util.Map;
import java.util.Set;
import java.util.Locale;
@@ -49,49 +47,29 @@
{
/** . */
- private static Set<WindowStateInfo> WINDOW_STATES;
+ private final MediaTypeMapImpl<ModeInfo> supportedModes;
/** . */
- private static final String ANY = "*";
+ private final MediaTypeMapImpl<WindowStateInfo> supportedWindowStates;
/** . */
- private static final String ANY_ANY = "*/*";
-
- /** . */
- private static final char SEPARATOR = '/';
-
- static
- {
- Set<WindowStateInfo> tmp = new HashSet<WindowStateInfo>();
- tmp.add(new ContainerWindowStateInfo(WindowState.MAXIMIZED));
- tmp.add(new ContainerWindowStateInfo(WindowState.MINIMIZED));
- tmp.add(new ContainerWindowStateInfo(WindowState.NORMAL));
- WINDOW_STATES = Collections.unmodifiableSet(tmp);
- }
-
- /** Maps MIME Type (String) -> Modes (Set), excluding multiple MIME Types
("*", "* / *", "type / *"). */
- protected final Map<String, Set<Mode>> singleTypeToPortletModes;
-
- /** Maps MIME Type (String) -> Modes (Set), including multiple MIME Types
("*", "* / *", "type / *"). */
- protected final Map<String, Set<Mode>> allTypeToPortletModes;
-
- /** . */
- protected final Set<Mode> allModes;
-
- /** . */
private final Set<Locale> supportedLocales;
- // case-insensitive
- // CONTENT TYPE = TYPE / SUBTYPE
- // SUBTYPE = any char except a TSPECIALS or SPACE or CTLS (??)
- // TSPECIALS ( ) < > @ , ; : \ " / [ ] ? . =
-
public ContainerCapabilitiesInfo()
{
- this.singleTypeToPortletModes = new HashMap<String, Set<Mode>>();
- this.allTypeToPortletModes = new HashMap<String, Set<Mode>>(); //
Including *
- this.allModes = new HashSet<Mode>();
+ MediaTypeMapImpl<ModeInfo> supportedModes = new
MediaTypeMapImpl<ModeInfo>();
+ supportedModes.put(new ContainerModeInfo(Mode.VIEW));
+
+ //
+ MediaTypeMapImpl<WindowStateInfo> supportedWindowStates = new
MediaTypeMapImpl<WindowStateInfo>();
+ supportedWindowStates.put(new ContainerWindowStateInfo(WindowState.MAXIMIZED));
+ supportedWindowStates.put(new ContainerWindowStateInfo(WindowState.NORMAL));
+ supportedWindowStates.put(new ContainerWindowStateInfo(WindowState.MINIMIZED));
+
+ //
this.supportedLocales = new HashSet<Locale>();
+ this.supportedModes = supportedModes;
+ this.supportedWindowStates = supportedWindowStates;
}
public void addLocale(Locale locale)
@@ -101,281 +79,68 @@
public void add(String contentType, Mode mode)
{
- // Determines which map and key to store the mode under
- String key;
- if (ANY.equals(contentType) || ANY_ANY.equals(contentType))
+ try
{
- key = ANY;
+ supportedModes.put(contentType, new ContainerModeInfo(mode));
}
- else
+ catch (IllegalArgumentException e)
{
- int index = contentType.indexOf(SEPARATOR);
- if (index == -1)
- {
- System.out.println("'" + contentType + "' is not a
valid MIME type: ignoring!");
- return;
- }
+ e.printStackTrace();
- String type = contentType.substring(0, index);
- String subtype = contentType.substring(index + 1);
-
- if (ANY.equals(subtype))
- {
- key = type;
- }
- else
- {
- key = contentType;
- // This is a single content type so we need to add it to the single mappings
in addition to all
- addMode(singleTypeToPortletModes, key, mode);
- }
+ //
+ System.out.println("'" + contentType + "' is not a valid
MIME type: ignoring!");
}
-
- // Store the mode in the complete mapping
- addMode(allTypeToPortletModes, key, mode);
-
- // Add the mode to the known modes
- allModes.add(mode);
}
- private void addMode(Map<String, Set<Mode>> map, String key, Mode mode)
+ public void add(String contentType, WindowState windowState)
{
- Set<Mode> modes = map.get(key);
- if (modes == null)
+ try
{
- modes = new HashSet<Mode>();
- map.put(key, modes);
+ supportedWindowStates.put(contentType, new
ContainerWindowStateInfo(windowState));
}
- modes.add(mode);
- }
+ catch (IllegalArgumentException e)
+ {
+ e.printStackTrace();
- /**
- * Return all modes.
- *
- * @return all modes
- */
- public Collection<Mode> getModes()
- {
- return Collections.unmodifiableCollection(allModes);
+ //
+ System.out.println("'" + contentType + "' is not a valid
MIME type: ignoring!");
+ }
}
- /**
- * Return all content types.
- *
- * @return all content types
- */
- public Collection<String> getAllContentTypes()
- {
- return Collections.unmodifiableCollection(allTypeToPortletModes.keySet());
- }
+ // CapabilitiesInfo implementation
**********************************************************************************
- /**
- * Return true if the mode is supported
- *
- * @param mode the mode to check
- * @return true if the mode is supported
- * @throws IllegalArgumentException if the mode is null
- */
- public boolean isModeSupported(Mode mode)
+ public Set<ModeInfo> getModes(MediaType mimeType)
{
- if (mode == null)
- {
- throw new IllegalArgumentException("Mode must not be null");
- }
- return allModes.contains(mode);
+ return supportedModes.resolve(mimeType);
}
- /**
- * Return all the supported modes for this content type.
- *
- * @param contentType the content type to check
- * @throws IllegalArgumentException if the content type is null
- * @return the set of modes matching the content types support
- */
- public Set<Mode> getSupportedModes(String contentType)
+ public Set<WindowStateInfo> getWindowStates(MediaType mimeType)
{
- if (contentType == null)
- {
- throw new IllegalArgumentException("Content type must not be null");
- }
-
- int index = contentType.indexOf(SEPARATOR);
- if (index == -1)
- {
- // Not valid content type so return empty set
- return Collections.emptySet();
- }
-
- //
- Set<Mode> set = new HashSet<Mode>();
-
- //
- Set<Mode> contentTypeModes =
singleTypeToPortletModes.get(contentType.toLowerCase());
- if (contentTypeModes != null)
- {
- set.addAll(contentTypeModes);
- }
-
- //
- Set<Mode> typeModes = allTypeToPortletModes.get(contentType.substring(0,
index).toLowerCase());
- if (typeModes != null)
- {
- set.addAll(typeModes);
- }
-
- Set<Mode> wildcardModes = allTypeToPortletModes.get(ANY);
- if (wildcardModes != null)
- {
- set.addAll(wildcardModes);
- }
-
- return set;
+ return supportedWindowStates.resolve(mimeType);
}
- /**
- * Return true if the content type is supported.
- *
- * @param contentType the content type
- * @return true is it is supported
- * @throws IllegalArgumentException if the content type is null
- */
- public boolean isContentTypeSupported(String contentType)
+ public Set<Locale> getLocales(MediaType mimeType)
{
- Collection allContentTypes = getAllContentTypes();
- if (contentType == null)
- {
- throw new IllegalArgumentException("Content type must not be null");
- }
-
- int index = contentType.indexOf(SEPARATOR);
- if (index == -1)
- {
- // Not valid content type so return false
- return false;
- }
-
- // Try the content type, * or */*
- if (allContentTypes.contains(contentType) |
- allContentTypes.contains(contentType.toLowerCase()) |
- allContentTypes.contains(ANY) |
- allContentTypes.contains(ANY_ANY))
- {
- return true;
- }
-
- // Try xxx/*
- String wildcard = contentType.substring(0, index) + "/*";
- return allContentTypes.contains(wildcard) |
allContentTypes.contains(wildcard.toLowerCase());
+ return supportedLocales;
}
- /**
- * Return true if the given content type is supported for the given mode.
- *
- * @param mode the mode to check
- * @param contentType the content type to check
- * @return true if is it supported
- * @throws IllegalArgumentException if the content type or the mode is null
- */
- public boolean isSupported(Mode mode, String contentType)
+ public Set<MediaType> getMimeTypes()
{
- if (mode == null)
- {
- throw new IllegalArgumentException("Mode must not be null");
- }
- if (contentType == null)
- {
- throw new IllegalArgumentException("Content type must not be null");
- }
-
- int index = contentType.indexOf(SEPARATOR);
- if (index == -1)
- {
- // Not valid content type so return false
- return false;
- }
-
- // Try full name matching
- Set<Mode> contentTypeModes = singleTypeToPortletModes.get(contentType);
- if (contentTypeModes != null && contentTypeModes.contains(mode))
- {
- return true;
- }
-
- // Try full name lowercase matching
- Set<Mode> lowercaseContentTypeModes =
singleTypeToPortletModes.get(contentType.toLowerCase());
- if (lowercaseContentTypeModes != null &&
lowercaseContentTypeModes.contains(mode))
- {
- return true;
- }
-
- // Try type matching
- String type = contentType.substring(0, index);
- Set<Mode> typeMode = allTypeToPortletModes.get(type);
- if (typeMode != null && typeMode.contains(mode))
- {
- return true;
- }
-
- // Try type matching
- Set<Mode> lowercaseTypeMode = allTypeToPortletModes.get(type.toLowerCase());
- if (lowercaseTypeMode != null && lowercaseTypeMode.contains(mode))
- {
- return true;
- }
-
- // Try wildcard matching
- Set<Mode> wildcardMode = allTypeToPortletModes.get(ANY);
- return wildcardMode != null && wildcardMode.contains(mode);
+ return supportedModes.getMediaTypes();
}
- // CapabilitiesInfo implementation
**********************************************************************************
-
- public Set<String> getMimeTypes()
- {
- return new HashSet<String>(getAllContentTypes());
- }
-
public Set<ModeInfo> getAllModes()
{
- Set<ModeInfo> infos = new HashSet<ModeInfo>();
- for (Mode mode : getModes())
- {
- infos.add(new ContainerModeInfo(mode));
- }
- return infos;
+ return supportedModes.getValues();
}
- public Set<ModeInfo> getModes(String mimeType)
- {
- Set<ModeInfo> infos = new HashSet<ModeInfo>();
- for (Mode mode : getSupportedModes(mimeType))
- {
- infos.add(new ContainerModeInfo(mode));
- }
- return infos;
- }
-
public Set<WindowStateInfo> getAllWindowStates()
{
- return WINDOW_STATES;
+ return supportedWindowStates.getValues();
}
- public Set<WindowStateInfo> getWindowStates(String mimeType)
- {
- if (isContentTypeSupported(mimeType))
- {
- return getAllWindowStates();
- }
- return Collections.emptySet();
- }
-
public Set<Locale> getAllLocales()
{
return supportedLocales;
}
-
- public Set<Locale> getLocales(String mimeType)
- {
- return supportedLocales;
- }
}
\ No newline at end of file
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java 2008-03-18
22:44:34 UTC (rev 10319)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java 2008-03-18
23:30:27 UTC (rev 10320)
@@ -53,6 +53,7 @@
import org.jboss.portal.common.i18n.ResourceBundleManager;
import org.jboss.portal.common.reflect.NoSuchClassException;
import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
import org.apache.log4j.Logger;
import javax.xml.namespace.QName;
@@ -798,6 +799,17 @@
{
capabilities.add(mimeType, modeMD.getPortletMode());
}
+
+ //
+ capabilities.add(mimeType, WindowState.NORMAL);
+ capabilities.add(mimeType, WindowState.MINIMIZED);
+ capabilities.add(mimeType, WindowState.MAXIMIZED);
+
+ // Then process each window state
+ for (WindowStateMetaData windowStateMD : supportsMD.getWindowStates())
+ {
+ capabilities.add(mimeType, windowStateMD.getWindowState());
+ }
}
//
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java 2008-03-18
22:44:34 UTC (rev 10319)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java 2008-03-18
23:30:27 UTC (rev 10320)
@@ -28,6 +28,7 @@
import org.jboss.portal.common.util.MultiValuedPropertyMap;
import org.jboss.portal.common.util.SimpleMultiValuedPropertyMap;
import org.jboss.portal.common.util.ContentInfo;
+import org.jboss.portal.common.net.media.MediaType;
import org.jboss.portal.portlet.impl.jsr168.PortletApplicationImpl;
import org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl;
import org.jboss.portal.portlet.impl.jsr168.PortletUtils;
@@ -580,12 +581,15 @@
ContentInfo si = invocation.getContext().getMarkupInfo();
String contentType = si.getContentType().toString();
+ //
+ MediaType mediaType = MediaType.create(contentType);
+
// Get the modes for this content type
CapabilitiesInfo capabilities = container.getInfo().getCapabilities();
// Add all the modes
Set<Mode> modes = new HashSet<Mode>();
- for (ModeInfo modeInfo : capabilities.getModes(contentType))
+ for (ModeInfo modeInfo : capabilities.getModes(mediaType))
{
modes.add(modeInfo.getMode());
}
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderResponseImpl.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderResponseImpl.java 2008-03-18
22:44:34 UTC (rev 10319)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderResponseImpl.java 2008-03-18
23:30:27 UTC (rev 10320)
@@ -129,9 +129,11 @@
//
Mode currentMode = preq.invocation.getMode();
+ org.jboss.portal.common.net.media.MediaType mediaType =
org.jboss.portal.common.net.media.MediaType.create(contentType);
+
PortletInfo info = preq.container.getInfo();
CapabilitiesInfo capabilities = info.getCapabilities();
- Set<ModeInfo> compatibleModes = capabilities.getModes(contentType);
+ Set<ModeInfo> compatibleModes = capabilities.getModes(mediaType);
for (ModeInfo modeInfo : compatibleModes)
{
if (currentMode.equals(modeInfo.getMode()))
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/info/CapabilitiesInfo.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/info/CapabilitiesInfo.java 2008-03-18
22:44:34 UTC (rev 10319)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/info/CapabilitiesInfo.java 2008-03-18
23:30:27 UTC (rev 10320)
@@ -22,11 +22,13 @@
******************************************************************************/
package org.jboss.portal.portlet.info;
+import org.jboss.portal.common.net.media.MediaType;
+
import java.util.Set;
import java.util.Locale;
/**
- * Gathers capability information (portlet modes, window states, supported MIME types and
locales) regarding a portlet.
+ * Gathers capability information (portlet modes, window states, supported media types
and locales) regarding a portlet.
*
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 5448 $
@@ -39,7 +41,7 @@
*
* @return a Set of String representation of supported MIME types
*/
- Set<String> getMimeTypes();
+ Set<MediaType> getMimeTypes();
/**
* Retrieves all the portlet modes supported by the associated Portlet.
@@ -54,7 +56,7 @@
* @param mimeType the mime type
* @return a Set of {@link ModeInfo} reprensenting the supported portlet modes for the
specified MIME type
*/
- Set<ModeInfo> getModes(String mimeType);
+ Set<ModeInfo> getModes(MediaType mimeType);
/**
* Retrieves all the window states supported by the associated Portlet.
@@ -69,7 +71,7 @@
* @param mimeType the mime type
* @return a Set of {@link ModeInfo} reprensenting the supported window states for the
specified MIME type
*/
- Set<WindowStateInfo> getWindowStates(String mimeType);
+ Set<WindowStateInfo> getWindowStates(MediaType mimeType);
/**
* Retrieves all the locales supported by the associated Portlet.
@@ -84,5 +86,5 @@
* @param mimeType the mime type
* @return a Set of supported {@link java.util.Locale}s for the specified MIME type
*/
- Set<Locale> getLocales(String mimeType);
+ Set<Locale> getLocales(MediaType mimeType);
}
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/support/info/CapabilitiesInfoSupport.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/support/info/CapabilitiesInfoSupport.java 2008-03-18
22:44:34 UTC (rev 10319)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/support/info/CapabilitiesInfoSupport.java 2008-03-18
23:30:27 UTC (rev 10320)
@@ -27,6 +27,7 @@
import org.jboss.portal.portlet.info.WindowStateInfo;
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
+import org.jboss.portal.common.net.media.MediaType;
import java.util.Set;
import java.util.HashSet;
@@ -41,7 +42,7 @@
{
/** . */
- private Set<String> mimeTypes;
+ private Set<MediaType> mimeTypes;
/** . */
private Set<ModeInfo> modes;
@@ -54,8 +55,8 @@
public CapabilitiesInfoSupport()
{
- mimeTypes = new HashSet<String>();
- mimeTypes.add("text/html");
+ mimeTypes = new HashSet<MediaType>();
+ mimeTypes.add(MediaType.TEXT_HTML);
//
this.modes = new HashSet<ModeInfo>();
@@ -74,7 +75,7 @@
locales.add(Locale.ENGLISH);
}
- public Set<String> getMimeTypes()
+ public Set<MediaType> getMimeTypes()
{
return mimeTypes;
}
@@ -84,7 +85,7 @@
return modes;
}
- public Set<ModeInfo> getModes(String mimeType)
+ public Set<ModeInfo> getModes(MediaType mimeType)
{
if (mimeTypes.contains(mimeType))
{
@@ -98,7 +99,7 @@
return windowStates;
}
- public Set<WindowStateInfo> getWindowStates(String mimeType)
+ public Set<WindowStateInfo> getWindowStates(MediaType mimeType)
{
if (mimeTypes.contains(mimeType))
{
@@ -112,7 +113,7 @@
return locales;
}
- public Set<Locale> getLocales(String mimeType)
+ public Set<Locale> getLocales(MediaType mimeType)
{
if (mimeTypes.contains(mimeType))
{
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/ContentTypesTestCase.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/ContentTypesTestCase.java 2008-03-18
22:44:34 UTC (rev 10319)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/ContentTypesTestCase.java 2008-03-18
23:30:27 UTC (rev 10320)
@@ -68,18 +68,6 @@
}
@Test
- public void testGetAllContentTypes()
- {
- Collection types = contentTypes.getAllContentTypes();
- assertEquals(5, types.size());
- assertTrue(types.contains("text/html"));
- assertTrue(types.contains("text/xml"));
- assertTrue(types.contains("pipo/pipo"));
- assertTrue(types.contains("*"));
- assertTrue(types.contains("text"));
- }
-
- @Test
public void testIsModeSupported()
{
}
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/info/CapabilitiesInfoTest.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/info/CapabilitiesInfoTest.java 2008-03-18
22:44:34 UTC (rev 10319)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/info/CapabilitiesInfoTest.java 2008-03-18
23:30:27 UTC (rev 10320)
@@ -25,6 +25,7 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
+import org.jboss.portal.common.net.media.MediaType;
import org.jboss.portal.portlet.container.managed.ManagedPortletContainer;
import org.jboss.portal.portlet.info.CapabilitiesInfo;
import org.jboss.portal.portlet.info.ModeInfo;
@@ -63,7 +64,7 @@
assertTrue(allLocales.contains(Locale.ENGLISH));
//check mime types
- Set types = capInfo.getMimeTypes();
+ Set<MediaType> types = capInfo.getMimeTypes();
String[] mt = new String[types.size()];
int count = 0;
for (Iterator i = types.iterator(); i.hasNext();)
@@ -82,21 +83,21 @@
assertTrue(modes.contains(Mode.EDIT));
//check text/html modes
- modeInfos = capInfo.getModes("text/html");
+ modeInfos = capInfo.getModes(MediaType.TEXT_HTML);
modes = extractModes(modeInfos);
assertEquals(2, modes.size());
assertTrue(modes.contains(Mode.VIEW));
assertTrue(modes.contains(Mode.HELP));
//check text/vnd.wap.wml modes
- modeInfos = capInfo.getModes("text/vnd.wap.wml");
+ modeInfos = capInfo.getModes(MediaType.create("text/vnd.wap.wml"));
modes = extractModes(modeInfos);
assertEquals(2, modes.size());
assertTrue(modes.contains(Mode.VIEW));
assertTrue(modes.contains(Mode.EDIT));
//check undeclared
- modeInfos = capInfo.getModes("text/undeclared");
+ modeInfos = capInfo.getModes(MediaType.create("text/undeclared"));
modes = extractModes(modeInfos);
assertEquals(0, modes.size());
@@ -109,7 +110,7 @@
assertTrue(states.contains(WindowState.MAXIMIZED));
//check for text/html
- stateInfos = capInfo.getWindowStates("text/html");
+ stateInfos = capInfo.getWindowStates(MediaType.TEXT_HTML);
states = extractWindowStates(stateInfos);
assertEquals(3, states.size());
assertTrue(states.contains(WindowState.NORMAL));
@@ -118,11 +119,11 @@
//simple check for text/vnd.wap.wml
//TODO:is this really expected behaviour? shouldn't it return no states as this
is unsupported by portal one?
- states = capInfo.getWindowStates("text/vnd.wap.wml");
+ states = capInfo.getWindowStates(MediaType.create("text/vnd.wap.wml"));
assertEquals(3, states.size());
//check undeclared
- states = capInfo.getWindowStates("undeclared/mime");
+ states = capInfo.getWindowStates(MediaType.create("undeclared/mime"));
assertEquals(0, states.size());
//fail();
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/info/ModeInfoTest.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/info/ModeInfoTest.java 2008-03-18
22:44:34 UTC (rev 10319)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/info/ModeInfoTest.java 2008-03-18
23:30:27 UTC (rev 10320)
@@ -23,6 +23,7 @@
package org.jboss.portal.test.portlet.info;
import org.jboss.portal.Mode;
+import org.jboss.portal.common.net.media.MediaType;
import org.jboss.portal.portlet.container.managed.ManagedPortletContainer;
import org.jboss.portal.portlet.info.CapabilitiesInfo;
import org.jboss.portal.portlet.info.ModeInfo;
@@ -52,7 +53,7 @@
CapabilitiesInfo capaInfo = container1.getInfo().getCapabilities();
//Portlet 1 with VIEW, EDIT, HELP
- Set modeInfos = capaInfo.getModes("text/html");
+ Set modeInfos = capaInfo.getModes(MediaType.TEXT_HTML);
//shoule be 3 modes
assertEquals(3, modeInfos.size());
@@ -72,7 +73,7 @@
//Portlet 2 with only VIEW
capaInfo = container2.getInfo().getCapabilities();
- modeInfos = capaInfo.getModes("text/html");
+ modeInfos = capaInfo.getModes(MediaType.TEXT_HTML);
//shoule be 1 mode
assertEquals(1, modeInfos.size());