[portal-commits] JBoss Portal SVN: r9142 - in branches/presentation/presentation/src/main/org/jboss/portal/presentation: model and 1 other directories.

portal-commits at lists.jboss.org portal-commits at lists.jboss.org
Tue Nov 27 19:52:22 EST 2007


Author: julien at jboss.com
Date: 2007-11-27 19:52:22 -0500 (Tue, 27 Nov 2007)
New Revision: 9142

Modified:
   branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java
   branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/UIObject.java
   branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/ModelTestCase.java
Log:
- added a bunch of IAE testing exceptions (trivial)

Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java	2007-11-28 00:41:54 UTC (rev 9141)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java	2007-11-28 00:52:22 UTC (rev 9142)
@@ -129,6 +129,18 @@
 
    public <T> T getProperty(StateScopeType scopeType, String propertyName, Class<T> propertyType)
    {
+      if (scopeType == null)
+      {
+         throw new IllegalArgumentException();
+      }
+      if (propertyName == null)
+      {
+         throw new IllegalArgumentException();
+      }
+      if (propertyType == null)
+      {
+         throw new IllegalArgumentException();
+      }
       Map map;
       switch (scopeType)
       {
@@ -154,6 +166,14 @@
 
    public <T> void setProperty(StateScopeType scopeType, String propertyName, T propertyValue) throws StateChangeVetoException
    {
+      if (scopeType == null)
+      {
+         throw new IllegalArgumentException();
+      }
+      if (propertyName == null)
+      {
+         throw new IllegalArgumentException();
+      }
       switch (scopeType)
       {
          case CONTENT:

Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/UIObject.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/UIObject.java	2007-11-28 00:41:54 UTC (rev 9141)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/UIObject.java	2007-11-28 00:52:22 UTC (rev 9142)
@@ -23,6 +23,7 @@
 package org.jboss.portal.presentation.model;
 
 import org.jboss.portal.presentation.model.state.StateChangeVetoException;
+import org.jboss.portal.presentation.model.state.StateException;
 
 import java.util.List;
 
@@ -57,14 +58,10 @@
    /**
     * Equivalent to call <code>getPropertyValue(StateScopeType,String,Class)</code> with the <code>Object.class</code>
     * literal.
-    *
-    * @param scopeType
-    * @param propertyName
-    * @return
     */
-   Object getProperty(StateScopeType scopeType, String propertyName);
+   Object getProperty(StateScopeType scopeType, String propertyName) throws IllegalArgumentException, StateException, StateChangeVetoException;
 
-   <T> void setProperty(StateScopeType scopeType, String propertyName, T propertyValue) throws StateChangeVetoException;
+   <T> void setProperty(StateScopeType scopeType, String propertyName, T propertyValue) throws IllegalArgumentException, StateException, StateChangeVetoException;
 
    /**
     * Create a child with a specified type.

Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/ModelTestCase.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/ModelTestCase.java	2007-11-28 00:41:54 UTC (rev 9141)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/ModelTestCase.java	2007-11-28 00:52:22 UTC (rev 9142)
@@ -32,6 +32,7 @@
 import org.jboss.portal.presentation.model.UIPage;
 import org.jboss.portal.presentation.model.UIPortal;
 import org.jboss.portal.presentation.model.state.StateChangeVetoException;
+import org.jboss.portal.presentation.model.state.StateException;
 
 import java.util.Collections;
 import java.util.List;
@@ -138,7 +139,57 @@
       List<UIObject> pageChildren = page.getChildren();
       assertTrue(pageChildren == null || pageChildren.size() == 0);
    }*/
+
+   public void testSetPropertyThrowsIAE()
+   {
+      UIContext context = new UIContextImpl(model);
+
+      //
+      try
+      {
+         context.setProperty(null, "foo", "foo_value");
+         fail();
+      }
+      catch (IllegalArgumentException ignore)
+      {
+      }
+
+      //
+      try
+      {
+         context.setProperty(StateScopeType.STRUCTURAL, null, "foo_value");
+         fail();
+      }
+      catch (IllegalArgumentException ignore)
+      {
+      }
+   }
    
+   public void testGetPropertyThrowsIAE()
+   {
+      UIContext context = new UIContextImpl(model);
+
+      //
+      try
+      {
+         context.getProperty(null, "foo");
+         fail();
+      }
+      catch (IllegalArgumentException ignore)
+      {
+      }
+
+      //
+      try
+      {
+         context.getProperty(StateScopeType.STRUCTURAL, null);
+         fail();
+      }
+      catch (IllegalArgumentException ignore)
+      {
+      }
+   }
+
    public void testLoadChildren() throws Exception
    {
       MockObject mockDefaultPortal = model.getContext().addChild("defaultPortal", MockObject.Type.PORTAL);




More information about the portal-commits mailing list