[gatein-commits] gatein SVN: r3744 - in components/pc/trunk: test/src/test/java/org/gatein/pc/test/portlet/jsr286/tck/resourceserving and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Aug 4 17:02:16 EDT 2010


Author: chris.laprun at jboss.com
Date: 2010-08-04 17:02:15 -0400 (Wed, 04 Aug 2010)
New Revision: 3744

Modified:
   components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/jsr168/api/ResourceURLImpl.java
   components/pc/trunk/test/src/test/java/org/gatein/pc/test/portlet/jsr286/tck/resourceserving/DowngradeCacheabilityTestCase.java
Log:
- GTNPC-24: fixed ResourceURLImpl.setCacheability implementation

Modified: components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/jsr168/api/ResourceURLImpl.java
===================================================================
--- components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/jsr168/api/ResourceURLImpl.java	2010-08-04 05:38:32 UTC (rev 3743)
+++ components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/jsr168/api/ResourceURLImpl.java	2010-08-04 21:02:15 UTC (rev 3744)
@@ -1,40 +1,40 @@
-/******************************************************************************
- * JBoss, a division of Red Hat                                               *
- * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
- * contributors as indicated by the @authors tag. See the                     *
- * copyright.txt in the distribution for a full listing of                    *
- * individual contributors.                                                   *
- *                                                                            *
- * This is free software; you can redistribute it and/or modify it            *
- * under the terms of the GNU Lesser General Public License as                *
- * published by the Free Software Foundation; either version 2.1 of           *
- * the License, or (at your option) any later version.                        *
- *                                                                            *
- * This software is distributed in the hope that it will be useful,           *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
- * Lesser General Public License for more details.                            *
- *                                                                            *
- * You should have received a copy of the GNU Lesser General Public           *
- * License along with this software; if not, write to the Free                *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
- * 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.pc.portlet.impl.jsr168.api;
 
-import org.gatein.pc.api.invocation.PortletInvocation;
-import org.gatein.pc.api.invocation.ResourceInvocation;
-import org.gatein.pc.api.cache.CacheLevel;
-import org.gatein.pc.api.StateString;
-import org.gatein.pc.api.ParametersStateString;
 import org.gatein.common.util.ParameterMap;
 import org.gatein.pc.api.Mode;
+import org.gatein.pc.api.ParametersStateString;
+import org.gatein.pc.api.StateString;
 import org.gatein.pc.api.WindowState;
+import org.gatein.pc.api.cache.CacheLevel;
+import org.gatein.pc.api.invocation.PortletInvocation;
+import org.gatein.pc.api.invocation.ResourceInvocation;
 
+import javax.portlet.PortletURLGenerationListener;
 import javax.portlet.ResourceURL;
-import javax.portlet.PortletURLGenerationListener;
+import java.util.HashMap;
 import java.util.Map;
-import java.util.HashMap;
 
 /**
  * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
@@ -142,6 +142,10 @@
             url.cacheLevel = cacheLevel;
          }
       }
+      else
+      {
+         throw new IllegalArgumentException("Unknown cache level: " + s);
+      }
    }
 
    protected InternalContainerURL getContainerURL()
@@ -164,7 +168,7 @@
       return new ResourceURLImpl(
          invocation,
          preq,
-         new InternalResourceURL(invocation.getNavigationalState(), invocation.getMode(),invocation.getWindowState()),
+         new InternalResourceURL(invocation.getNavigationalState(), invocation.getMode(), invocation.getWindowState()),
          true);
    }
 

Modified: components/pc/trunk/test/src/test/java/org/gatein/pc/test/portlet/jsr286/tck/resourceserving/DowngradeCacheabilityTestCase.java
===================================================================
--- components/pc/trunk/test/src/test/java/org/gatein/pc/test/portlet/jsr286/tck/resourceserving/DowngradeCacheabilityTestCase.java	2010-08-04 05:38:32 UTC (rev 3743)
+++ components/pc/trunk/test/src/test/java/org/gatein/pc/test/portlet/jsr286/tck/resourceserving/DowngradeCacheabilityTestCase.java	2010-08-04 21:02:15 UTC (rev 3744)
@@ -1,66 +1,61 @@
-/******************************************************************************
- * JBoss, a division of Red Hat                                               *
- * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
- * contributors as indicated by the @authors tag. See the                     *
- * copyright.txt in the distribution for a full listing of                    *
- * individual contributors.                                                   *
- *                                                                            *
- * This is free software; you can redistribute it and/or modify it            *
- * under the terms of the GNU Lesser General Public License as                *
- * published by the Free Software Foundation; either version 2.1 of           *
- * the License, or (at your option) any later version.                        *
- *                                                                            *
- * This software is distributed in the hope that it will be useful,           *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
- * Lesser General Public License for more details.                            *
- *                                                                            *
- * You should have received a copy of the GNU Lesser General Public           *
- * License along with this software; if not, write to the Free                *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
- * 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.pc.test.portlet.jsr286.tck.resourceserving;
 
+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.Assertion;
-import org.gatein.pc.test.unit.annotations.TestCase;
 import org.gatein.pc.test.unit.actions.PortletRenderTestAction;
 import org.gatein.pc.test.unit.actions.PortletResourceTestAction;
-import org.gatein.pc.test.portlet.framework.UTP1;
+import org.gatein.pc.test.unit.annotations.TestCase;
 import org.jboss.unit.driver.DriverResponse;
 import org.jboss.unit.driver.response.EndTestResponse;
 import org.jboss.unit.remote.driver.handler.http.response.InvokeGetResponse;
 
-import static org.jboss.unit.api.Assert.*;
-
 import javax.portlet.Portlet;
+import javax.portlet.PortletException;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
-import javax.portlet.PortletException;
-import javax.portlet.ResourceURL;
 import javax.portlet.ResourceRequest;
 import javax.portlet.ResourceResponse;
+import javax.portlet.ResourceURL;
 import java.io.IOException;
 
+import static org.jboss.unit.api.Assert.assertEquals;
+import static org.jboss.unit.api.Assert.fail;
+
 /**
- * cxxx:
- * Only URLs with a cache level FULL are allowed in the response of the
- * serveResource call triggered via a ResourceURL with a cache level FULL. The
- * same restriction is true for all downstream URLs that result from this
- * serveResource call. Setting a cachability different from  must result in an
- * IllegalStateException.
+ * cxxx: Only URLs with a cache level FULL are allowed in the response of the serveResource call triggered via a
+ * ResourceURL with a cache level FULL. The same restriction is true for all downstream URLs that result from this
+ * serveResource call. Setting a cachability different from  must result in an IllegalStateException.
+ * <p/>
+ * cxxxi: Attempts to create URLs that are not of type FULL or are not resource URLs in the current or a downstream
+ * response must result in an IllegalStateException25
+ * <p/>
+ * cxxxii: Creating other URLs, e.g. resource URLs of type  or action or render URLs, must result in an
+ * IllegalStateException
  *
- * cxxxi:
- * Attempts to create URLs that are not of type FULL
- * or are not resource URLs in the current or a downstream response must result in
- * an IllegalStateException25
- *
- * cxxxii:
- * Creating other URLs, e.g. resource URLs of type  or
- * action or render URLs, must result in an IllegalStateException
- *
  * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
  * @version $Revision: 630 $
  */
@@ -68,7 +63,7 @@
    Assertion.JSR286_130,
    Assertion.JSR286_131,
    Assertion.JSR286_132
-   })
+})
 public class DowngradeCacheabilityTestCase
 {
    public DowngradeCacheabilityTestCase(PortletTestCase seq)
@@ -79,6 +74,22 @@
          {
             ResourceURL resourceURL = response.createResourceURL();
             assertEquals(ResourceURL.PAGE, resourceURL.getCacheability());
+            try
+            {
+               resourceURL.setCacheability(null);
+               fail();
+            }
+            catch (IllegalArgumentException ignore)
+            {
+            }
+            try
+            {
+               resourceURL.setCacheability("inexistent");
+               fail();
+            }
+            catch (IllegalArgumentException ignore)
+            {
+            }
             resourceURL.setCacheability(ResourceURL.PORTLET);
             assertEquals(ResourceURL.PORTLET, resourceURL.getCacheability());
             return new InvokeGetResponse(resourceURL.toString());



More information about the gatein-commits mailing list