You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-scm@portals.apache.org by ms...@apache.org on 2016/01/18 13:41:17 UTC

[15/35] portals-pluto git commit: Implemented type annotations for portlet request filters, portlet URL generation listeners, and portlet preference validators. The corresponding definitions in the portlet.xml file are merged into the annotated configura

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/a05e1563/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/AlterMultipleAnnotatedListenerTest.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/AlterMultipleAnnotatedListenerTest.java b/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/AlterMultipleAnnotatedListenerTest.java
new file mode 100644
index 0000000..af49bef
--- /dev/null
+++ b/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/AlterMultipleAnnotatedListenerTest.java
@@ -0,0 +1,222 @@
+/*  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+
+package org.apache.pluto.container.om.portlet.impl.jsr362;
+
+import static org.junit.Assert.*;
+
+import java.io.InputStream;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.pluto.container.om.portlet.Listener;
+import org.apache.pluto.container.om.portlet.PortletApplicationDefinition;
+import org.apache.pluto.container.om.portlet.impl.ConfigurationHolder;
+import org.apache.pluto.container.om.portlet.impl.ListenerImpl;
+import org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl;
+import org.apache.pluto.container.om.portlet.impl.fixtures.MultipleAnnotatedListeners1;
+import org.apache.pluto.container.om.portlet.impl.fixtures.MultipleAnnotatedListeners2;
+import org.apache.pluto.container.om.portlet.impl.fixtures.TestListener;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Junit test cases for JSR 362 portlet application definition.
+ * @author Scott Nicklous
+ *
+ */
+public class AlterMultipleAnnotatedListenerTest {
+   
+   // defines both some portlets and a Listener
+   private static final Class<?> TEST_ANNOTATED_CLASS1 = MultipleAnnotatedListeners1.class;
+   private static final Class<?> TEST_ANNOTATED_CLASS2 = MultipleAnnotatedListeners2.class;
+   private static final String XML_FILE = 
+         "org/apache/pluto/container/om/portlet/portlet362AlterListener.xml";
+   
+   private static PortletApplicationDefinition pad;
+   private static ConfigurationHolder cfp;
+   
+   // class under test; cloned new for each test
+   private  PortletApplicationDefinition cut;
+
+   /**
+    * @throws java.lang.Exception
+    */
+   @BeforeClass
+   public static void setUpBeforeClass() throws Exception {
+      
+      InputStream in = MergePortletAppTest.class
+            .getClassLoader().getResourceAsStream(XML_FILE);
+
+      Set<Class<?>> classes = new HashSet<Class<?>>();
+      classes.add(TEST_ANNOTATED_CLASS1);
+      classes.add(TEST_ANNOTATED_CLASS2);
+      cfp = new ConfigurationHolder();
+      try {
+         cfp.processConfigAnnotations(classes);
+         cfp.processPortletDD(in);
+         try {
+            cfp.validate();         // validate to expand the Listener mapping portlet names
+         } catch (Exception e) {}   // ignore any validation problems.
+         pad = cfp.getPad();
+      } catch (Exception e) {
+         e.printStackTrace();
+         throw e;
+      }
+   }
+   
+   @Before
+   public void setUpBefore() throws Exception {
+      cut = new PortletApplicationDefinitionImpl(pad);
+   }
+
+   /**
+    * Tests that bListener has been removed and aListener modified 
+    */
+   @Test
+   public void testGetListener() {
+      String fn1 = "bListener";
+      String fn2 = "aListener";
+      Listener lis1 = cut.getListener(fn1);
+      assertNull(lis1);
+      Listener lis2 = cut.getListener(fn2);
+      assertNotNull(lis2);
+      assertEquals(-40, lis2.getOrdinal());
+      assertEquals(TestListener.class.getCanonicalName(), lis2.getListenerClass());
+   }
+   
+   /**
+    * make sure we have the right number
+    */
+   @Test
+   public void testGetListeners() {
+      String fn2 = "aListener";
+      List<Listener> list = cut.getListeners();
+      assertEquals(1, list.size());
+      assertEquals(fn2, list.get(0).getListenerName());
+   }
+
+   /**
+    * Test that additional listener can be added
+    */
+   @Test
+   public void testAddListener() {
+      String newItem = "newListener";
+      String oldItem1 = "aListener";
+      Listener lis = new ListenerImpl("SomeClass");
+      lis.setListenerName(newItem);
+      lis.setOrdinal(-101);
+      cut.addListener(lis);
+      
+      List<Listener> list = cut.getListeners();
+      assertNotNull(list);
+      assertEquals(2, list.size());
+      assertEquals(newItem, list.get(0).getListenerName());
+      assertEquals(oldItem1, list.get(1).getListenerName());
+   }
+
+   /**
+    * Test method for {@link org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl#addListener(org.apache.pluto.container.om.portlet.Listener)}.
+    */
+   @Test
+   public void checkListenerOrder1() {
+      String newItem = "newListener";
+      String oldItem1 = "aListener";
+      Listener lis = new ListenerImpl("SomeClass");
+      lis.setListenerName(newItem);
+      lis.setOrdinal(1000);
+      cut.addListener(lis);
+      
+      List<Listener> list = cut.getListeners();
+      assertNotNull(list);
+      assertEquals(2, list.size());
+      assertEquals(newItem, list.get(1).getListenerName());
+      assertEquals(oldItem1, list.get(0).getListenerName());
+   }
+
+   /**
+    * Test method for {@link org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl#addListener(org.apache.pluto.container.om.portlet.Listener)}.
+    */
+   @Test
+   public void checkListenerOrder2() {
+      String newItem = "newListener";
+      String oldItem1 = "aListener";
+      Listener lis = new ListenerImpl("SomeClass");
+      lis.setListenerName(newItem);
+      lis.setOrdinal(0);
+      cut.addListener(lis);
+      
+      List<Listener> list = cut.getListeners();
+      assertNotNull(list);
+      assertEquals(2, list.size());
+      assertEquals(newItem, list.get(1).getListenerName());
+      assertEquals(oldItem1, list.get(0).getListenerName());
+   }
+
+   /**
+    * Test method for {@link org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl#addListener(org.apache.pluto.container.om.portlet.Listener)}.
+    */
+   @Test
+   public void deleteListener1() {
+      String oldItem = "aListener";
+      Listener lis = new ListenerImpl((String)null);
+      lis.setListenerName(oldItem);
+      lis.setOrdinal(1000);
+      cut.addListener(lis);
+      
+      List<Listener> list = cut.getListeners();
+      assertNotNull(list);
+      assertEquals(0, list.size());
+   }
+
+   /**
+    * Test method for {@link org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl#addListener(org.apache.pluto.container.om.portlet.Listener)}.
+    */
+   @Test
+   public void deleteListener2() {
+      String oldItem = "aListener";
+      Listener lis = new ListenerImpl("");
+      lis.setListenerName(oldItem);
+      lis.setOrdinal(1000);
+      cut.addListener(lis);
+      
+      List<Listener> list = cut.getListeners();
+      assertNotNull(list);
+      assertEquals(0, list.size());
+   }
+
+   @Test
+   public void testAddDupListener() {
+      String fn = "aListener";
+      String fc = "SomeClass";
+      Listener lis = new ListenerImpl(fc);
+      lis.setListenerName(fn);
+      lis.setOrdinal(200);
+      cut.addListener(lis);
+      
+      List<Listener> list = cut.getListeners();
+      assertNotNull(list);
+      assertEquals(1, list.size());
+      assertEquals(fn, list.get(0).getListenerName());
+      assertEquals(fc, list.get(0).getListenerClass());
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/a05e1563/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/FilterMultiplePortletsTest.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/FilterMultiplePortletsTest.java b/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/FilterMultiplePortletsTest.java
new file mode 100644
index 0000000..13eddd3
--- /dev/null
+++ b/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/FilterMultiplePortletsTest.java
@@ -0,0 +1,125 @@
+/*  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+
+package org.apache.pluto.container.om.portlet.impl.jsr362;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.portlet.PortletRequest;
+
+import org.apache.pluto.container.om.portlet.Filter;
+import org.apache.pluto.container.om.portlet.FilterMapping;
+import org.apache.pluto.container.om.portlet.PortletApplicationDefinition;
+import org.apache.pluto.container.om.portlet.impl.ConfigurationHolder;
+import org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl;
+import org.apache.pluto.container.om.portlet.impl.fixtures.TestAnnotatedFilterMultiple;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Junit test cases for JSR 362 portlet application definition.
+ * @author Scott Nicklous
+ *
+ */
+public class FilterMultiplePortletsTest {
+   
+   // defines both some portlets and a filter
+   private static final Class<?> TEST_ANNOTATED_CLASS = TestAnnotatedFilterMultiple.class;
+   
+   private static PortletApplicationDefinition pad;
+   private static ConfigurationHolder cfp;
+   
+   // class under test; cloned new for each test
+   private  PortletApplicationDefinition cut;
+
+   /**
+    * @throws java.lang.Exception
+    */
+   @BeforeClass
+   public static void setUpBeforeClass() throws Exception {
+
+      Set<Class<?>> classes = new HashSet<Class<?>>();
+      classes.add(TEST_ANNOTATED_CLASS);
+      cfp = new ConfigurationHolder();
+      try {
+         cfp.processConfigAnnotations(classes);
+         try {
+            cfp.validate();         // validate to expand the filter mapping portlet names
+         } catch (Exception e) {}   // ignore any validation problems.
+         pad = cfp.getPad();
+      } catch (Exception e) {
+         e.printStackTrace();
+         throw e;
+      }
+   }
+   
+   @Before
+   public void setUpBefore() throws Exception {
+      cut = new PortletApplicationDefinitionImpl(pad);
+   }
+
+   /**
+    * Test method for {@link org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl#getFilter(java.lang.String)}.
+    */
+   @Test
+   public void testGetFilter() {
+      String newItem = "aFilter";
+      Filter item = cut.getFilter(newItem);
+      assertNotNull(item);
+      Filter filter = cut.getFilters().get(0);
+      assertEquals(TEST_ANNOTATED_CLASS.getCanonicalName(), 
+            filter.getFilterClass());
+      assertEquals("true", filter.getInitParam("execute").getParamValue());
+   }
+   
+   @Test
+   public void testFilterLifecycle() {
+      String newItem = "aFilter";
+      Filter filter = cut.getFilter(newItem);
+      assertNotNull(filter);
+      List<String> lifecycles =  Arrays.asList(new String[] {PortletRequest.RENDER_PHASE, PortletRequest.RESOURCE_PHASE, PortletRequest.HEADER_PHASE});
+      for (String lc : filter.getLifecycles()) {
+         assertTrue(lifecycles.contains(lc));
+      }
+   }
+
+   /**
+    * Test method for {@link org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl#getFilterMapping(java.lang.String)}.
+    */
+   @Test
+   public void testGetFilterMapping() {
+      String newItem = "aFilter";
+      FilterMapping item = cut.getFilterMapping(newItem);
+      assertNotNull(item);
+      List<String> names = item.getPortletNames();
+      assertEquals(3, names.size());
+      assertTrue(names.contains("portlet1"));
+      assertTrue(names.contains("portlet2"));
+      assertTrue(names.contains("portlet3"));
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/a05e1563/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/JSR362PortletFilterAnnotationTest.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/JSR362PortletFilterAnnotationTest.java b/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/JSR362PortletFilterAnnotationTest.java
index 5412191..132adab 100644
--- a/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/JSR362PortletFilterAnnotationTest.java
+++ b/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/JSR362PortletFilterAnnotationTest.java
@@ -146,6 +146,7 @@ public class JSR362PortletFilterAnnotationTest {
       String newItem = "newFilter";
       Filter fil = new FilterImpl(newItem);
       fil.setFilterClass("SomeClass");
+      fil.setOrdinal(100);
       cut.addFilter(fil);
       
       List<Filter> list = cut.getFilters();
@@ -158,6 +159,76 @@ public class JSR362PortletFilterAnnotationTest {
     * Test method for {@link org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl#addFilter(org.apache.pluto.container.om.portlet.Filter)}.
     */
    @Test
+   public void checkFilterOrder1() {
+      String newItem = "newFilter";
+      String oldItem = "aFilter";
+      Filter fil = new FilterImpl(newItem);
+      fil.setFilterClass("SomeClass");
+      fil.setOrdinal(10);
+      cut.addFilter(fil);
+      
+      List<Filter> list = cut.getFilters();
+      assertNotNull(list);
+      assertEquals(2, list.size());
+      assertEquals(newItem, list.get(0).getFilterName());
+      assertEquals(oldItem, list.get(1).getFilterName());
+   }
+
+   /**
+    * Test method for {@link org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl#addFilter(org.apache.pluto.container.om.portlet.Filter)}.
+    */
+   @Test
+   public void checkFilterOrder2() {
+      String newItem = "newFilter";
+      String oldItem = "aFilter";
+      Filter fil = new FilterImpl(newItem);
+      fil.setFilterClass("SomeClass");
+      fil.setOrdinal(1000);
+      cut.addFilter(fil);
+      
+      List<Filter> list = cut.getFilters();
+      assertNotNull(list);
+      assertEquals(2, list.size());
+      assertEquals(newItem, list.get(1).getFilterName());
+      assertEquals(oldItem, list.get(0).getFilterName());
+   }
+
+   /**
+    * Test method for {@link org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl#addFilter(org.apache.pluto.container.om.portlet.Filter)}.
+    */
+   @Test
+   public void deleteFilter1() {
+      String oldItem = "aFilter";
+      Filter fil = new FilterImpl(oldItem);
+      fil.setFilterClass(null);
+      fil.setOrdinal(1000);
+      cut.addFilter(fil);
+      
+      List<Filter> list = cut.getFilters();
+      assertNotNull(list);
+      assertEquals(0, list.size());
+   }
+
+   /**
+    * Test method for {@link org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl#addFilter(org.apache.pluto.container.om.portlet.Filter)}.
+    */
+   @Test
+   public void deleteFilter2() {
+      String oldItem = "aFilter";
+      Filter fil = new FilterImpl(oldItem);
+      fil.setFilterClass("");
+      fil.setOrdinal(1000);
+      cut.addFilter(fil);
+      
+      List<Filter> list = cut.getFilters();
+      assertNotNull(list);
+      assertEquals(0, list.size());
+   }
+
+   /**
+    * Test method for {@link org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl#addFilter(org.apache.pluto.container.om.portlet.Filter)}.
+    */
+   @Test
    public void testAddDupFilter() {
       String newItem = "aFilter";
       Filter fil = new FilterImpl(newItem);

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/a05e1563/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/MergePortletDefinitionTest.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/MergePortletDefinitionTest.java b/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/MergePortletDefinitionTest.java
index d949ca0..dcb8d99 100644
--- a/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/MergePortletDefinitionTest.java
+++ b/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/MergePortletDefinitionTest.java
@@ -56,14 +56,12 @@ import org.apache.pluto.container.om.portlet.impl.EventDefinitionReferenceImpl;
 import org.apache.pluto.container.om.portlet.impl.InitParamImpl;
 import org.apache.pluto.container.om.portlet.impl.LocaleTextImpl;
 import org.apache.pluto.container.om.portlet.impl.PortletDefinitionImpl;
-import org.apache.pluto.container.om.portlet.impl.PortletInfoImpl;
 import org.apache.pluto.container.om.portlet.impl.PreferenceImpl;
 import org.apache.pluto.container.om.portlet.impl.PreferencesImpl;
 import org.apache.pluto.container.om.portlet.impl.SecurityRoleRefImpl;
 import org.apache.pluto.container.om.portlet.impl.SupportsImpl;
 import org.apache.pluto.container.om.portlet.impl.fixtures.TestAnnotatedPortlet;
 import org.apache.pluto.container.om.portlet.impl.fixtures.TestPortlet;
-import org.apache.pluto.container.om.portlet.impl.fixtures.TestPortletAppAnnotatedClass;
 import org.apache.pluto.container.om.portlet.impl.fixtures.TestPreferencesValidator;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -210,9 +208,6 @@ public class MergePortletDefinitionTest {
       PortletInfo info = cut.getPortletInfo();
       assertNotNull(info);
       List<LocaleText> list = info.getTitles();
-      for (LocaleText lt : list) {
-         System.out.println("title: " + lt.getText());
-      }
       assertEquals(2, list.size());
       assertEquals("Annotated Portlet", info.getTitle(Locale.ENGLISH).getText());
       assertEquals("Titel", info.getTitle(Locale.GERMAN).getText());

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/a05e1563/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/MergePrefs1Test.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/MergePrefs1Test.java b/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/MergePrefs1Test.java
new file mode 100644
index 0000000..1255474
--- /dev/null
+++ b/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/MergePrefs1Test.java
@@ -0,0 +1,245 @@
+/*  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+
+package org.apache.pluto.container.om.portlet.impl.jsr362;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.InputStream;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.pluto.container.om.portlet.PortletApplicationDefinition;
+import org.apache.pluto.container.om.portlet.PortletDefinition;
+import org.apache.pluto.container.om.portlet.Preference;
+import org.apache.pluto.container.om.portlet.Preferences;
+import org.apache.pluto.container.om.portlet.impl.ConfigurationHolder;
+import org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl;
+import org.apache.pluto.container.om.portlet.impl.fixtures.TestAnnotatedPrefs1;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Junit test cases for JSR 362 portlet application definition.
+ * @author Scott Nicklous
+ *
+ */
+public class MergePrefs1Test {
+   
+   // defines both some portlets and a Listener
+   private static final Class<?> TEST_ANNOTATED_CLASS1 = TestAnnotatedPrefs1.class;
+   private static final String XML_FILE = 
+         "org/apache/pluto/container/om/portlet/portlet362AlterValidator1.xml";
+   
+   private static PortletApplicationDefinition pad;
+   private static ConfigurationHolder cfp;
+   
+   // class under test; cloned new for each test
+   private  PortletApplicationDefinition cut;
+
+   /**
+    * @throws java.lang.Exception
+    */
+   @BeforeClass
+   public static void setUpBeforeClass() throws Exception {
+      
+      InputStream in = MergePortletAppTest.class
+            .getClassLoader().getResourceAsStream(XML_FILE);
+
+      Set<Class<?>> classes = new HashSet<Class<?>>();
+      classes.add(TEST_ANNOTATED_CLASS1);
+      cfp = new ConfigurationHolder();
+      try {
+         cfp.processConfigAnnotations(classes);
+         cfp.processPortletDD(in);     // process portlet xml after annotations
+         try {
+            cfp.validate();         // validate and ignore any validation problems.
+         } catch (Exception e) {}   
+         pad = cfp.getPad();
+      } catch (Exception e) {
+         e.printStackTrace();
+         throw e;
+      }
+   }
+   
+   @Before
+   public void setUpBefore() throws Exception {
+      cut = new PortletApplicationDefinitionImpl(pad);
+   }
+
+   /**
+    * Tests that the validator is properly applied to portlets 1 & 3 only
+    */
+   @Test
+   public void testPrefs() {
+      List<PortletDefinition> list = cut.getPortlets();
+      assertNotNull(list);
+      assertEquals(4, list.size());
+   }
+   
+   @Test
+   public void testGetPreferences1() {
+      String name = "bPref";
+      String[] testVals = {"dValue", "eValue", "fValue"};
+      PortletDefinition pd = cut.getPortlet("portlet1");
+      assertNotNull(pd);
+      Preferences prefs = pd.getPortletPreferences();
+      assertNotNull(prefs);
+      assertEquals(2, prefs.getPortletPreferences().size());
+      
+      Preference pref = prefs.getPortletPreference(name);
+      assertNotNull(pref);
+      List<String> vals = pref.getValues();
+      assertEquals(testVals.length, vals.size());
+      assertArrayEquals(testVals, vals.toArray());
+      
+      name = "aPref";
+      testVals = new String[] {"aValue"}; 
+      pref = prefs.getPortletPreference(name);
+      assertNotNull(pref);
+      vals = pref.getValues();
+      assertEquals(testVals.length, vals.size());
+      assertArrayEquals(testVals, vals.toArray());
+   }
+   
+   @Test
+   public void testGetPreferences2() {
+      PortletDefinition pd = cut.getPortlet("portlet2");
+      assertNotNull(pd);
+      Preferences prefs = pd.getPortletPreferences();
+      assertNotNull(prefs);
+      assertEquals(0, prefs.getPortletPreferences().size());
+   }
+   
+   @Test
+   public void testGetPreferences3() {
+      String name = "cPref";
+      String val = "cValue";
+      PortletDefinition pd = cut.getPortlet("portlet3");
+      assertNotNull(pd);
+      Preferences prefs = pd.getPortletPreferences();
+      assertNotNull(prefs);
+      assertEquals(1, prefs.getPortletPreferences().size());
+      
+      Preference pref = prefs.getPortletPreference(name);
+      assertNotNull(pref);
+      List<String> vals = pref.getValues();
+      assertEquals(1, vals.size());
+      assertEquals(val, vals.get(0));
+   }
+   
+   @Test
+   public void testGetPreferences4() {
+      String name = "dPref";
+      String val = "dValue";
+      PortletDefinition pd = cut.getPortlet("portlet4");
+      assertNotNull(pd);
+      Preferences prefs = pd.getPortletPreferences();
+      assertNotNull(prefs);
+      assertEquals(1, prefs.getPortletPreferences().size());
+      
+      Preference pref = prefs.getPortletPreference(name);
+      assertNotNull(pref);
+      List<String> vals = pref.getValues();
+      assertEquals(1, vals.size());
+      assertEquals(val, vals.get(0));
+   }
+   
+   @Test
+   public void testGetPreferenceList() {
+      PortletDefinition pd = cut.getPortlet("portlet1");
+      assertNotNull(pd);
+      Preferences prefs = pd.getPortletPreferences();
+      assertNotNull(prefs);
+      assertEquals(2, prefs.getPortletPreferences().size());
+      
+      for (Preference p : prefs.getPortletPreferences()) {
+         assertTrue(p.isReadOnly());
+      }
+   }
+   
+   @Test
+   public void testReadOnly3() {
+      PortletDefinition pd = cut.getPortlet("portlet3");
+      assertNotNull(pd);
+      Preferences prefs = pd.getPortletPreferences();
+      assertNotNull(prefs);
+      assertEquals(1, prefs.getPortletPreferences().size());
+      
+      Preference pref = prefs.getPortletPreference("cPref");
+      assertNotNull(pref);
+      assertFalse(pref.isReadOnly());
+   }
+   
+   @Test
+   public void testReadOnly4() {
+      PortletDefinition pd = cut.getPortlet("portlet4");
+      assertNotNull(pd);
+      Preferences prefs = pd.getPortletPreferences();
+      assertNotNull(prefs);
+      assertEquals(1, prefs.getPortletPreferences().size());
+      
+      Preference pref = prefs.getPortletPreference("dPref");
+      assertNotNull(pref);
+      assertTrue(pref.isReadOnly());
+   }
+
+   @Test
+   public void testValidatorApplied() {
+      PortletDefinition pd1 = cut.getPortlet("portlet1");
+      PortletDefinition pd4 = cut.getPortlet("portlet4");
+      
+      assertNotNull(pd1);
+      assertNotNull(pd4);
+      
+      Preferences prefs1 = pd1.getPortletPreferences();
+      Preferences prefs4 = pd4.getPortletPreferences();
+      
+      assertNotNull(prefs1);
+      assertNotNull(prefs4);
+      
+      assertNotNull(prefs1.getPreferencesValidator());
+      assertNotNull(prefs4.getPreferencesValidator());
+      
+      assertEquals(TEST_ANNOTATED_CLASS1.getCanonicalName(), prefs1.getPreferencesValidator());
+      assertEquals(TEST_ANNOTATED_CLASS1.getCanonicalName(), prefs4.getPreferencesValidator());
+   }
+
+   @Test
+   public void testValidatorNotApplied() {
+      PortletDefinition pd = cut.getPortlet("portlet2");
+      assertNotNull(pd);
+      Preferences prefs = pd.getPortletPreferences();
+      assertNotNull(prefs);
+      assertNull(prefs.getPreferencesValidator());
+      
+      pd = cut.getPortlet("portlet3");
+      assertNotNull(pd);
+      prefs = pd.getPortletPreferences();
+      assertNotNull(prefs);
+      assertNull(prefs.getPreferencesValidator());
+   }
+}

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/a05e1563/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/MergePrefs2Test.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/MergePrefs2Test.java b/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/MergePrefs2Test.java
new file mode 100644
index 0000000..f206c31
--- /dev/null
+++ b/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/MergePrefs2Test.java
@@ -0,0 +1,306 @@
+/*  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+
+package org.apache.pluto.container.om.portlet.impl.jsr362;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.InputStream;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.pluto.container.om.portlet.PortletApplicationDefinition;
+import org.apache.pluto.container.om.portlet.PortletDefinition;
+import org.apache.pluto.container.om.portlet.Preference;
+import org.apache.pluto.container.om.portlet.Preferences;
+import org.apache.pluto.container.om.portlet.impl.ConfigurationHolder;
+import org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl;
+import org.apache.pluto.container.om.portlet.impl.fixtures.TestAnnotatedPrefs2;
+import org.apache.pluto.container.om.portlet.impl.fixtures.TestPreferencesValidator;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Junit test cases for JSR 362 portlet application definition.
+ * @author Scott Nicklous
+ *
+ */
+public class MergePrefs2Test {
+   
+   // defines both some portlets and a Listener
+   private static final Class<?> TEST_ANNOTATED_CLASS1 = TestAnnotatedPrefs2.class;
+   private static final String XML_FILE = 
+         "org/apache/pluto/container/om/portlet/portlet362AlterValidator2.xml";
+   
+   private static PortletApplicationDefinition pad;
+   private static ConfigurationHolder cfp;
+   
+   // class under test; cloned new for each test
+   private  PortletApplicationDefinition cut;
+
+   /**
+    * @throws java.lang.Exception
+    */
+   @BeforeClass
+   public static void setUpBeforeClass() throws Exception {
+      
+      InputStream in = MergePortletAppTest.class
+            .getClassLoader().getResourceAsStream(XML_FILE);
+
+      Set<Class<?>> classes = new HashSet<Class<?>>();
+      classes.add(TEST_ANNOTATED_CLASS1);
+      cfp = new ConfigurationHolder();
+      try {
+         cfp.processConfigAnnotations(classes);
+         cfp.processPortletDD(in);     // process portlet xml after annotations
+         try {
+            cfp.validate();         // validate and ignore any validation problems.
+         } catch (Exception e) {}   
+         pad = cfp.getPad();
+      } catch (Exception e) {
+         e.printStackTrace();
+         throw e;
+      }
+   }
+   
+   @Before
+   public void setUpBefore() throws Exception {
+      cut = new PortletApplicationDefinitionImpl(pad);
+   }
+
+   /**
+    * Tests that the validator is properly applied to portlets 1 & 5 only
+    */
+   @Test
+   public void testPrefs() {
+      List<PortletDefinition> list = cut.getPortlets();
+      assertNotNull(list);
+      assertEquals(5, list.size());
+   }
+   
+   @Test
+   public void testGetPreferences1() {
+      String name = "bPref";
+      String[] testVals = {"dValue", "eValue", "fValue"};
+      PortletDefinition pd = cut.getPortlet("portlet1");
+      assertNotNull(pd);
+      Preferences prefs = pd.getPortletPreferences();
+      assertNotNull(prefs);
+      assertEquals(2, prefs.getPortletPreferences().size());
+      
+      Preference pref = prefs.getPortletPreference(name);
+      assertNotNull(pref);
+      List<String> vals = pref.getValues();
+      assertEquals(testVals.length, vals.size());
+      assertArrayEquals(testVals, vals.toArray());
+      
+      name = "aPref";
+      testVals = new String[] {"aValue"}; 
+      pref = prefs.getPortletPreference(name);
+      assertNotNull(pref);
+      vals = pref.getValues();
+      assertEquals(testVals.length, vals.size());
+      assertArrayEquals(testVals, vals.toArray());
+   }
+   
+   @Test
+   public void testGetPreferences2() {
+      String name = "aPref";
+      String val = "aValue";
+      PortletDefinition pd = cut.getPortlet("portlet2");
+      assertNotNull(pd);
+      Preferences prefs = pd.getPortletPreferences();
+      assertNotNull(prefs);
+      assertEquals(2, prefs.getPortletPreferences().size());
+      
+      Preference pref = prefs.getPortletPreference(name);
+      assertNotNull(pref);
+      List<String> vals = pref.getValues();
+      assertEquals(1, vals.size());
+      assertEquals(val, vals.get(0));
+      
+      name = "bPref";
+      String[] testVals = {"bValue", "cValue"};
+      pref = prefs.getPortletPreference(name);
+      assertNotNull(pref);
+      vals = pref.getValues();
+      assertEquals(2, vals.size());
+      assertArrayEquals(testVals, vals.toArray());
+   }
+   
+   @Test
+   public void testGetPreferences3() {
+      String name = "cPref";
+      String val = "cValue";
+      PortletDefinition pd = cut.getPortlet("portlet3");
+      assertNotNull(pd);
+      Preferences prefs = pd.getPortletPreferences();
+      assertNotNull(prefs);
+      assertEquals(2, prefs.getPortletPreferences().size());
+      
+      Preference pref = prefs.getPortletPreference(name);
+      assertNotNull(pref);
+      List<String> vals = pref.getValues();
+      assertEquals(1, vals.size());
+      assertEquals(val, vals.get(0));
+      
+      name = "aPref";
+      val = "aValue";
+      pref = prefs.getPortletPreference(name);
+      assertNotNull(pref);
+      vals = pref.getValues();
+      assertEquals(1, vals.size());
+      assertEquals(val, vals.get(0));
+   }
+   
+   @Test
+   public void testGetPreferences4() {
+      String name = "dPref";
+      String val = "dValue";
+      PortletDefinition pd = cut.getPortlet("portlet4");
+      assertNotNull(pd);
+      Preferences prefs = pd.getPortletPreferences();
+      assertNotNull(prefs);
+      assertEquals(1, prefs.getPortletPreferences().size());
+      
+      Preference pref = prefs.getPortletPreference(name);
+      assertNotNull(pref);
+      List<String> vals = pref.getValues();
+      assertEquals(1, vals.size());
+      assertEquals(val, vals.get(0));
+   }
+   
+   @Test
+   public void testGetPreferenceList() {
+      PortletDefinition pd = cut.getPortlet("portlet1");
+      assertNotNull(pd);
+      Preferences prefs = pd.getPortletPreferences();
+      assertNotNull(prefs);
+      assertEquals(2, prefs.getPortletPreferences().size());
+      
+      for (Preference p : prefs.getPortletPreferences()) {
+         assertTrue(p.isReadOnly());
+      }
+   }
+   
+   @Test
+   public void testReadOnly1() {
+      PortletDefinition pd = cut.getPortlet("portlet2");
+      assertNotNull(pd);
+      Preferences prefs = pd.getPortletPreferences();
+      assertNotNull(prefs);
+      assertEquals(2, prefs.getPortletPreferences().size());
+      
+      Preference pref = prefs.getPortletPreference("aPref");
+      assertNotNull(pref);
+      assertTrue(pref.isReadOnly());
+      
+      pref = prefs.getPortletPreference("bPref");
+      assertNotNull(pref);
+      assertFalse(pref.isReadOnly());
+   }
+   
+   @Test
+   public void testReadOnly2() {
+      PortletDefinition pd = cut.getPortlet("portlet3");
+      assertNotNull(pd);
+      Preferences prefs = pd.getPortletPreferences();
+      assertNotNull(prefs);
+      assertEquals(2, prefs.getPortletPreferences().size());
+      
+      Preference pref = prefs.getPortletPreference("aPref");
+      assertNotNull(pref);
+      assertTrue(pref.isReadOnly());
+      
+      pref = prefs.getPortletPreference("cPref");
+      assertNotNull(pref);
+      assertFalse(pref.isReadOnly());
+   }
+   
+   @Test
+   public void testReadOnly4() {
+      PortletDefinition pd = cut.getPortlet("portlet4");
+      assertNotNull(pd);
+      Preferences prefs = pd.getPortletPreferences();
+      assertNotNull(prefs);
+      assertEquals(1, prefs.getPortletPreferences().size());
+      
+      Preference pref = prefs.getPortletPreference("dPref");
+      assertNotNull(pref);
+      assertTrue(pref.isReadOnly());
+   }
+
+   /**
+    * Annotated Validator is applied to portlets 3 & 4. Portlet 1 gets
+    * a validator specified in the portlet DD. 
+    */
+   @Test
+   public void testValidatorApplied() {
+      PortletDefinition pd1 = cut.getPortlet("portlet1");
+      PortletDefinition pd3 = cut.getPortlet("portlet3");
+      PortletDefinition pd4 = cut.getPortlet("portlet4");
+      
+      assertNotNull(pd1);
+      assertNotNull(pd3);
+      assertNotNull(pd4);
+      
+      Preferences prefs1 = pd1.getPortletPreferences();
+      Preferences prefs3 = pd3.getPortletPreferences();
+      Preferences prefs4 = pd4.getPortletPreferences();
+      
+      assertNotNull(prefs1);
+      assertNotNull(prefs3);
+      assertNotNull(prefs4);
+      
+      assertNotNull(prefs1.getPreferencesValidator());
+      assertNotNull(prefs3.getPreferencesValidator());
+      assertNotNull(prefs4.getPreferencesValidator());
+      
+      assertEquals(TEST_ANNOTATED_CLASS1.getCanonicalName(), prefs1.getPreferencesValidator());
+      assertEquals(TestPreferencesValidator.class.getCanonicalName(), prefs3.getPreferencesValidator());
+      assertEquals(TestPreferencesValidator.class.getCanonicalName(), prefs4.getPreferencesValidator());
+   }
+
+   /**
+    * The annotated validator is not applied to portlet 2. The validator would normally
+    * be applied to portlet 5, but is explicitly set to null in the portlet DD, so
+    * portlet 5 doesn't get a validator.
+    */
+   @Test
+   public void testValidatorNotApplied() {
+      PortletDefinition pd = cut.getPortlet("portlet2");
+      assertNotNull(pd);
+      Preferences prefs = pd.getPortletPreferences();
+      assertNotNull(prefs);
+      assertNull(prefs.getPreferencesValidator());
+      
+      pd = cut.getPortlet("portlet5");
+      assertNotNull(pd);
+      prefs = pd.getPortletPreferences();
+      assertNotNull(prefs);
+      assertNull(prefs.getPreferencesValidator());
+   }
+}

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/a05e1563/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/MultipleAnnotatedFilterTest.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/MultipleAnnotatedFilterTest.java b/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/MultipleAnnotatedFilterTest.java
new file mode 100644
index 0000000..77c1e5b
--- /dev/null
+++ b/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/MultipleAnnotatedFilterTest.java
@@ -0,0 +1,212 @@
+/*  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+
+package org.apache.pluto.container.om.portlet.impl.jsr362;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.pluto.container.om.portlet.Filter;
+import org.apache.pluto.container.om.portlet.PortletApplicationDefinition;
+import org.apache.pluto.container.om.portlet.impl.ConfigurationHolder;
+import org.apache.pluto.container.om.portlet.impl.FilterImpl;
+import org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl;
+import org.apache.pluto.container.om.portlet.impl.fixtures.MultipleAnnotatedFilters1;
+import org.apache.pluto.container.om.portlet.impl.fixtures.MultipleAnnotatedFilters2;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Junit test cases for JSR 362 portlet application definition.
+ * @author Scott Nicklous
+ *
+ */
+public class MultipleAnnotatedFilterTest {
+   
+   // defines both some portlets and a filter
+   private static final Class<?> TEST_ANNOTATED_CLASS1 = MultipleAnnotatedFilters1.class;
+   private static final Class<?> TEST_ANNOTATED_CLASS2 = MultipleAnnotatedFilters2.class;
+   
+   private static PortletApplicationDefinition pad;
+   private static ConfigurationHolder cfp;
+   
+   // class under test; cloned new for each test
+   private  PortletApplicationDefinition cut;
+
+   /**
+    * @throws java.lang.Exception
+    */
+   @BeforeClass
+   public static void setUpBeforeClass() throws Exception {
+
+      Set<Class<?>> classes = new HashSet<Class<?>>();
+      classes.add(TEST_ANNOTATED_CLASS1);
+      classes.add(TEST_ANNOTATED_CLASS2);
+      cfp = new ConfigurationHolder();
+      try {
+         cfp.processConfigAnnotations(classes);
+         try {
+            cfp.validate();         // validate to expand the filter mapping portlet names
+         } catch (Exception e) {}   // ignore any validation problems.
+         pad = cfp.getPad();
+      } catch (Exception e) {
+         e.printStackTrace();
+         throw e;
+      }
+   }
+   
+   @Before
+   public void setUpBefore() throws Exception {
+      cut = new PortletApplicationDefinitionImpl(pad);
+   }
+
+   /**
+    * Test method for {@link org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl#getFilter(java.lang.String)}.
+    */
+   @Test
+   public void testGetFilter() {
+      String fn1 = "aFilter";
+      String fn2 = "bFilter";
+      Filter fil1 = cut.getFilter(fn1);
+      assertNotNull(fil1);
+      assertEquals(100, fil1.getOrdinal());
+      Filter fil2 = cut.getFilter(fn2);
+      assertNotNull(fil2);
+      assertEquals(-100, fil2.getOrdinal());
+      assertEquals(TEST_ANNOTATED_CLASS1.getCanonicalName(), fil1.getFilterClass());
+      assertEquals(TEST_ANNOTATED_CLASS2.getCanonicalName(), fil2.getFilterClass());
+   }
+
+   /**
+    * Test method for {@link org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl#addFilter(org.apache.pluto.container.om.portlet.Filter)}.
+    */
+   @Test
+   public void testAddFilter() {
+      String newItem = "newFilter";
+      String oldItem1 = "aFilter";
+      String oldItem2 = "bFilter";
+      Filter fil = new FilterImpl(newItem);
+      fil.setFilterClass("SomeClass");
+      fil.setOrdinal(-101);
+      cut.addFilter(fil);
+      
+      List<Filter> list = cut.getFilters();
+      assertNotNull(list);
+      assertEquals(3, list.size());
+      assertEquals(newItem, list.get(0).getFilterName());
+      assertEquals(oldItem1, list.get(2).getFilterName());
+      assertEquals(oldItem2, list.get(1).getFilterName());
+   }
+
+   /**
+    * Test method for {@link org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl#addFilter(org.apache.pluto.container.om.portlet.Filter)}.
+    */
+   @Test
+   public void checkFilterOrder1() {
+      String newItem = "newFilter";
+      String oldItem1 = "aFilter";
+      String oldItem2 = "bFilter";
+      Filter fil = new FilterImpl(newItem);
+      fil.setFilterClass("SomeClass");
+      fil.setOrdinal(1000);
+      cut.addFilter(fil);
+      
+      List<Filter> list = cut.getFilters();
+      assertNotNull(list);
+      assertEquals(3, list.size());
+      assertEquals(newItem, list.get(2).getFilterName());
+      assertEquals(oldItem1, list.get(1).getFilterName());
+      assertEquals(oldItem2, list.get(0).getFilterName());
+   }
+
+   /**
+    * Test method for {@link org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl#addFilter(org.apache.pluto.container.om.portlet.Filter)}.
+    */
+   @Test
+   public void checkFilterOrder2() {
+      String newItem = "newFilter";
+      String oldItem1 = "aFilter";
+      String oldItem2 = "bFilter";
+      Filter fil = new FilterImpl(newItem);
+      fil.setFilterClass("SomeClass");
+      fil.setOrdinal(0);
+      cut.addFilter(fil);
+      
+      List<Filter> list = cut.getFilters();
+      assertNotNull(list);
+      assertEquals(3, list.size());
+      assertEquals(newItem, list.get(1).getFilterName());
+      assertEquals(oldItem1, list.get(2).getFilterName());
+      assertEquals(oldItem2, list.get(0).getFilterName());
+   }
+
+   /**
+    * Test method for {@link org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl#addFilter(org.apache.pluto.container.om.portlet.Filter)}.
+    */
+   @Test
+   public void deleteFilter1() {
+      String oldItem = "aFilter";
+      Filter fil = new FilterImpl(oldItem);
+      fil.setFilterClass(null);
+      fil.setOrdinal(1000);
+      cut.addFilter(fil);
+      
+      List<Filter> list = cut.getFilters();
+      assertNotNull(list);
+      assertEquals(1, list.size());
+   }
+
+   /**
+    * Test method for {@link org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl#addFilter(org.apache.pluto.container.om.portlet.Filter)}.
+    */
+   @Test
+   public void deleteFilter2() {
+      String oldItem = "aFilter";
+      Filter fil = new FilterImpl(oldItem);
+      fil.setFilterClass("");
+      fil.setOrdinal(1000);
+      cut.addFilter(fil);
+      
+      List<Filter> list = cut.getFilters();
+      assertNotNull(list);
+      assertEquals(1, list.size());
+   }
+
+   @Test
+   public void testAddDupFilter() {
+      String fn = "aFilter";
+      String fc = "SomeClass";
+      Filter fil = new FilterImpl(fn);
+      fil.setFilterClass(fc);
+      fil.setOrdinal(200);
+      cut.addFilter(fil);
+      
+      List<Filter> list = cut.getFilters();
+      assertNotNull(list);
+      assertEquals(2, list.size());
+      assertEquals(fn, list.get(1).getFilterName());
+      assertEquals(fc, list.get(1).getFilterClass());
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/a05e1563/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/MultipleAnnotatedListenerTest.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/MultipleAnnotatedListenerTest.java b/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/MultipleAnnotatedListenerTest.java
new file mode 100644
index 0000000..5011ab7
--- /dev/null
+++ b/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/MultipleAnnotatedListenerTest.java
@@ -0,0 +1,212 @@
+/*  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+
+package org.apache.pluto.container.om.portlet.impl.jsr362;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.pluto.container.om.portlet.Listener;
+import org.apache.pluto.container.om.portlet.PortletApplicationDefinition;
+import org.apache.pluto.container.om.portlet.impl.ConfigurationHolder;
+import org.apache.pluto.container.om.portlet.impl.ListenerImpl;
+import org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl;
+import org.apache.pluto.container.om.portlet.impl.fixtures.MultipleAnnotatedListeners1;
+import org.apache.pluto.container.om.portlet.impl.fixtures.MultipleAnnotatedListeners2;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Junit test cases for JSR 362 portlet application definition.
+ * @author Scott Nicklous
+ *
+ */
+public class MultipleAnnotatedListenerTest {
+   
+   // defines both some portlets and a Listener
+   private static final Class<?> TEST_ANNOTATED_CLASS1 = MultipleAnnotatedListeners1.class;
+   private static final Class<?> TEST_ANNOTATED_CLASS2 = MultipleAnnotatedListeners2.class;
+   
+   private static PortletApplicationDefinition pad;
+   private static ConfigurationHolder cfp;
+   
+   // class under test; cloned new for each test
+   private  PortletApplicationDefinition cut;
+
+   /**
+    * @throws java.lang.Exception
+    */
+   @BeforeClass
+   public static void setUpBeforeClass() throws Exception {
+
+      Set<Class<?>> classes = new HashSet<Class<?>>();
+      classes.add(TEST_ANNOTATED_CLASS1);
+      classes.add(TEST_ANNOTATED_CLASS2);
+      cfp = new ConfigurationHolder();
+      try {
+         cfp.processConfigAnnotations(classes);
+         try {
+            cfp.validate();         // validate to expand the Listener mapping portlet names
+         } catch (Exception e) {}   // ignore any validation problems.
+         pad = cfp.getPad();
+      } catch (Exception e) {
+         e.printStackTrace();
+         throw e;
+      }
+   }
+   
+   @Before
+   public void setUpBefore() throws Exception {
+      cut = new PortletApplicationDefinitionImpl(pad);
+   }
+
+   /**
+    * Test method for {@link org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl#getListener(java.lang.String)}.
+    */
+   @Test
+   public void testGetListener() {
+      String fn1 = "aListener";
+      String fn2 = "bListener";
+      Listener lis1 = cut.getListener(fn1);
+      assertNotNull(lis1);
+      assertEquals(100, lis1.getOrdinal());
+      Listener lis2 = cut.getListener(fn2);
+      assertNotNull(lis2);
+      assertEquals(-100, lis2.getOrdinal());
+      assertEquals(TEST_ANNOTATED_CLASS1.getCanonicalName(), lis1.getListenerClass());
+      assertEquals(TEST_ANNOTATED_CLASS2.getCanonicalName(), lis2.getListenerClass());
+   }
+
+   /**
+    * Test method for {@link org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl#addListener(org.apache.pluto.container.om.portlet.Listener)}.
+    */
+   @Test
+   public void testAddListener() {
+      String newItem = "newListener";
+      String oldItem1 = "aListener";
+      String oldItem2 = "bListener";
+      Listener lis = new ListenerImpl("SomeClass");
+      lis.setListenerName(newItem);
+      lis.setOrdinal(-101);
+      cut.addListener(lis);
+      
+      List<Listener> list = cut.getListeners();
+      assertNotNull(list);
+      assertEquals(3, list.size());
+      assertEquals(newItem, list.get(0).getListenerName());
+      assertEquals(oldItem1, list.get(2).getListenerName());
+      assertEquals(oldItem2, list.get(1).getListenerName());
+   }
+
+   /**
+    * Test method for {@link org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl#addListener(org.apache.pluto.container.om.portlet.Listener)}.
+    */
+   @Test
+   public void checkListenerOrder1() {
+      String newItem = "newListener";
+      String oldItem1 = "aListener";
+      String oldItem2 = "bListener";
+      Listener lis = new ListenerImpl("SomeClass");
+      lis.setListenerName(newItem);
+      lis.setOrdinal(1000);
+      cut.addListener(lis);
+      
+      List<Listener> list = cut.getListeners();
+      assertNotNull(list);
+      assertEquals(3, list.size());
+      assertEquals(newItem, list.get(2).getListenerName());
+      assertEquals(oldItem1, list.get(1).getListenerName());
+      assertEquals(oldItem2, list.get(0).getListenerName());
+   }
+
+   /**
+    * Test method for {@link org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl#addListener(org.apache.pluto.container.om.portlet.Listener)}.
+    */
+   @Test
+   public void checkListenerOrder2() {
+      String newItem = "newListener";
+      String oldItem1 = "aListener";
+      String oldItem2 = "bListener";
+      Listener lis = new ListenerImpl("SomeClass");
+      lis.setListenerName(newItem);
+      lis.setOrdinal(0);
+      cut.addListener(lis);
+      
+      List<Listener> list = cut.getListeners();
+      assertNotNull(list);
+      assertEquals(3, list.size());
+      assertEquals(newItem, list.get(1).getListenerName());
+      assertEquals(oldItem1, list.get(2).getListenerName());
+      assertEquals(oldItem2, list.get(0).getListenerName());
+   }
+
+   /**
+    * Test method for {@link org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl#addListener(org.apache.pluto.container.om.portlet.Listener)}.
+    */
+   @Test
+   public void deleteListener1() {
+      String oldItem = "aListener";
+      Listener lis = new ListenerImpl((String)null);
+      lis.setListenerName(oldItem);
+      lis.setOrdinal(1000);
+      cut.addListener(lis);
+      
+      List<Listener> list = cut.getListeners();
+      assertNotNull(list);
+      assertEquals(1, list.size());
+   }
+
+   /**
+    * Test method for {@link org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl#addListener(org.apache.pluto.container.om.portlet.Listener)}.
+    */
+   @Test
+   public void deleteListener2() {
+      String oldItem = "aListener";
+      Listener lis = new ListenerImpl("");
+      lis.setListenerName(oldItem);
+      lis.setOrdinal(1000);
+      cut.addListener(lis);
+      
+      List<Listener> list = cut.getListeners();
+      assertNotNull(list);
+      assertEquals(1, list.size());
+   }
+
+   @Test
+   public void testAddDupListener() {
+      String fn = "aListener";
+      String fc = "SomeClass";
+      Listener lis = new ListenerImpl(fc);
+      lis.setListenerName(fn);
+      lis.setOrdinal(200);
+      cut.addListener(lis);
+      
+      List<Listener> list = cut.getListeners();
+      assertNotNull(list);
+      assertEquals(2, list.size());
+      assertEquals(fn, list.get(1).getListenerName());
+      assertEquals(fc, list.get(1).getListenerClass());
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/a05e1563/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/MultipleAnnotatedPrefs1Test.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/MultipleAnnotatedPrefs1Test.java b/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/MultipleAnnotatedPrefs1Test.java
new file mode 100644
index 0000000..49364c1
--- /dev/null
+++ b/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/MultipleAnnotatedPrefs1Test.java
@@ -0,0 +1,99 @@
+/*  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+
+package org.apache.pluto.container.om.portlet.impl.jsr362;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.pluto.container.om.portlet.PortletApplicationDefinition;
+import org.apache.pluto.container.om.portlet.PortletDefinition;
+import org.apache.pluto.container.om.portlet.impl.ConfigurationHolder;
+import org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl;
+import org.apache.pluto.container.om.portlet.impl.fixtures.TestAnnotatedPrefs1;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Junit test cases for JSR 362 portlet application definition.
+ * @author Scott Nicklous
+ *
+ */
+public class MultipleAnnotatedPrefs1Test {
+   
+   // defines both some portlets and a Listener
+   private static final Class<?> TEST_ANNOTATED_CLASS1 = TestAnnotatedPrefs1.class;
+   
+   private static PortletApplicationDefinition pad;
+   private static ConfigurationHolder cfp;
+   
+   // class under test; cloned new for each test
+   private  PortletApplicationDefinition cut;
+
+   /**
+    * @throws java.lang.Exception
+    */
+   @BeforeClass
+   public static void setUpBeforeClass() throws Exception {
+
+      Set<Class<?>> classes = new HashSet<Class<?>>();
+      classes.add(TEST_ANNOTATED_CLASS1);
+      cfp = new ConfigurationHolder();
+      try {
+         cfp.processConfigAnnotations(classes);
+         try {
+            cfp.validate();         // validate and ignore any validation problems.
+         } catch (Exception e) {}   
+         pad = cfp.getPad();
+      } catch (Exception e) {
+         e.printStackTrace();
+         throw e;
+      }
+   }
+   
+   @Before
+   public void setUpBefore() throws Exception {
+      cut = new PortletApplicationDefinitionImpl(pad);
+   }
+
+   /**
+    * Tests that the default portletNames='*' value in the portlet
+    * preferences validator annotation applies the validator to all
+    * portlets in the portlet app.  
+    */
+   @Test
+   public void testPrefs() {
+      List<PortletDefinition> list = cut.getPortlets();
+      assertNotNull(list);
+      assertEquals(3, list.size());
+      
+      for (PortletDefinition item : list) {
+         assertNotNull(item.getPortletPreferences());
+         assertNotNull(item.getPortletPreferences().getPreferencesValidator());
+         assertEquals(TEST_ANNOTATED_CLASS1.getCanonicalName(), 
+               item.getPortletPreferences().getPreferencesValidator());
+      }
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/a05e1563/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/MultipleAnnotatedPrefs2Test.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/MultipleAnnotatedPrefs2Test.java b/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/MultipleAnnotatedPrefs2Test.java
new file mode 100644
index 0000000..371d429
--- /dev/null
+++ b/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/MultipleAnnotatedPrefs2Test.java
@@ -0,0 +1,243 @@
+/*  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+
+package org.apache.pluto.container.om.portlet.impl.jsr362;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.pluto.container.om.portlet.PortletApplicationDefinition;
+import org.apache.pluto.container.om.portlet.PortletDefinition;
+import org.apache.pluto.container.om.portlet.Preference;
+import org.apache.pluto.container.om.portlet.Preferences;
+import org.apache.pluto.container.om.portlet.impl.ConfigurationHolder;
+import org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl;
+import org.apache.pluto.container.om.portlet.impl.fixtures.TestAnnotatedPrefs2;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Junit test cases for JSR 362 portlet application definition.
+ * @author Scott Nicklous
+ *
+ */
+public class MultipleAnnotatedPrefs2Test {
+   
+   // defines both some portlets and a Listener
+   private static final Class<?> TEST_ANNOTATED_CLASS1 = TestAnnotatedPrefs2.class;
+   
+   private static PortletApplicationDefinition pad;
+   private static ConfigurationHolder cfp;
+   
+   // class under test; cloned new for each test
+   private  PortletApplicationDefinition cut;
+
+   /**
+    * @throws java.lang.Exception
+    */
+   @BeforeClass
+   public static void setUpBeforeClass() throws Exception {
+
+      Set<Class<?>> classes = new HashSet<Class<?>>();
+      classes.add(TEST_ANNOTATED_CLASS1);
+      cfp = new ConfigurationHolder();
+      try {
+         cfp.processConfigAnnotations(classes);
+         try {
+            cfp.validate();         // validate and ignore any validation problems.
+         } catch (Exception e) {}   
+         pad = cfp.getPad();
+      } catch (Exception e) {
+         e.printStackTrace();
+         throw e;
+      }
+   }
+   
+   @Before
+   public void setUpBefore() throws Exception {
+      cut = new PortletApplicationDefinitionImpl(pad);
+   }
+
+   /**
+    * Tests that the validator is properly applied to portlets 1, 3, & 5 only
+    */
+   @Test
+   public void testPrefs() {
+      List<PortletDefinition> list = cut.getPortlets();
+      assertNotNull(list);
+      assertEquals(4, list.size());
+   }
+   
+   @Test
+   public void testGetPreferences1() {
+      String name = "aPref";
+      String val = "aValue";
+      PortletDefinition pd = cut.getPortlet("portlet1");
+      assertNotNull(pd);
+      Preferences prefs = pd.getPortletPreferences();
+      assertNotNull(prefs);
+      assertEquals(2, prefs.getPortletPreferences().size());
+      
+      Preference pref = prefs.getPortletPreference(name);
+      assertNotNull(pref);
+      List<String> vals = pref.getValues();
+      assertEquals(1, vals.size());
+      assertEquals(val, vals.get(0));
+      
+      name = "bPref";
+      val = "bValue";
+      pref = prefs.getPortletPreference(name);
+      assertNotNull(pref);
+      vals = pref.getValues();
+      assertEquals(1, vals.size());
+      assertEquals(val, vals.get(0));
+   }
+   
+   @Test
+   public void testGetPreferences2() {
+      String name = "aPref";
+      String val = "aValue";
+      PortletDefinition pd = cut.getPortlet("portlet2");
+      assertNotNull(pd);
+      Preferences prefs = pd.getPortletPreferences();
+      assertNotNull(prefs);
+      assertEquals(2, prefs.getPortletPreferences().size());
+      
+      Preference pref = prefs.getPortletPreference(name);
+      assertNotNull(pref);
+      List<String> vals = pref.getValues();
+      assertEquals(1, vals.size());
+      assertEquals(val, vals.get(0));
+      
+      name = "bPref";
+      String[] testVals = {"bValue", "cValue"};
+      pref = prefs.getPortletPreference(name);
+      assertNotNull(pref);
+      vals = pref.getValues();
+      assertEquals(2, vals.size());
+      assertArrayEquals(testVals, vals.toArray());
+   }
+   
+   @Test
+   public void testGetPreferences3() {
+      String name = "aPref";
+      String val = "aValue";
+      PortletDefinition pd = cut.getPortlet("portlet3");
+      assertNotNull(pd);
+      Preferences prefs = pd.getPortletPreferences();
+      assertNotNull(prefs);
+      assertEquals(1, prefs.getPortletPreferences().size());
+      
+      Preference pref = prefs.getPortletPreference(name);
+      assertNotNull(pref);
+      List<String> vals = pref.getValues();
+      assertEquals(1, vals.size());
+      assertEquals(val, vals.get(0));
+      
+      name = "bPref";
+      pref = prefs.getPortletPreference(name);
+      assertNull(pref);
+   }
+   
+   @Test
+   public void testGetPreferences() {
+      PortletDefinition pd = cut.getPortlet("portlet1");
+      assertNotNull(pd);
+      Preferences prefs = pd.getPortletPreferences();
+      assertNotNull(prefs);
+      assertEquals(2, prefs.getPortletPreferences().size());
+      
+      for (Preference p : prefs.getPortletPreferences()) {
+         assertFalse(p.isReadOnly());
+      }
+   }
+   
+   @Test
+   public void testReadOnly1() {
+      PortletDefinition pd = cut.getPortlet("portlet2");
+      assertNotNull(pd);
+      Preferences prefs = pd.getPortletPreferences();
+      assertNotNull(prefs);
+      assertEquals(2, prefs.getPortletPreferences().size());
+      
+      Preference pref = prefs.getPortletPreference("aPref");
+      assertNotNull(pref);
+      assertTrue(pref.isReadOnly());
+      
+      pref = prefs.getPortletPreference("bPref");
+      assertNotNull(pref);
+      assertFalse(pref.isReadOnly());
+   }
+   
+   @Test
+   public void testReadOnly2() {
+      PortletDefinition pd = cut.getPortlet("portlet3");
+      assertNotNull(pd);
+      Preferences prefs = pd.getPortletPreferences();
+      assertNotNull(prefs);
+      assertEquals(1, prefs.getPortletPreferences().size());
+      
+      Preference pref = prefs.getPortletPreference("aPref");
+      assertNotNull(pref);
+      assertTrue(pref.isReadOnly());
+   }
+
+   @Test
+   public void testValidatorApplied() {
+      PortletDefinition pd1 = cut.getPortlet("portlet1");
+      PortletDefinition pd3 = cut.getPortlet("portlet3");
+      PortletDefinition pd5 = cut.getPortlet("portlet5");
+      
+      assertNotNull(pd1);
+      assertNotNull(pd3);
+      assertNotNull(pd5);
+      
+      Preferences prefs1 = pd1.getPortletPreferences();
+      Preferences prefs3 = pd3.getPortletPreferences();
+      Preferences prefs5 = pd5.getPortletPreferences();
+      
+      assertNotNull(prefs1);
+      assertNotNull(prefs3);
+      assertNotNull(prefs5);
+      assertNotNull(prefs1.getPreferencesValidator());
+      assertNotNull(prefs3.getPreferencesValidator());
+      assertNotNull(prefs5.getPreferencesValidator());
+      assertEquals(TEST_ANNOTATED_CLASS1.getCanonicalName(), prefs1.getPreferencesValidator());
+      assertEquals(TEST_ANNOTATED_CLASS1.getCanonicalName(), prefs3.getPreferencesValidator());
+      assertEquals(TEST_ANNOTATED_CLASS1.getCanonicalName(), prefs5.getPreferencesValidator());
+   }
+
+   @Test
+   public void testValidatorNotApplied() {
+      PortletDefinition pd2 = cut.getPortlet("portlet2");
+      assertNotNull(pd2);
+      Preferences prefs2 = pd2.getPortletPreferences();
+      assertNotNull(prefs2);
+      assertNull(prefs2.getPreferencesValidator());
+   }
+}

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/a05e1563/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/PortletApplicationDefinition362ImplTest.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/PortletApplicationDefinition362ImplTest.java b/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/PortletApplicationDefinition362ImplTest.java
index bbaa992..13ccd87 100644
--- a/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/PortletApplicationDefinition362ImplTest.java
+++ b/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/PortletApplicationDefinition362ImplTest.java
@@ -749,6 +749,7 @@ public class PortletApplicationDefinition362ImplTest {
       assertEquals(1, list.size());
       assertEquals("org.apache.pluto.container.om.portlet.impl.fixtures.TestListener", list.get(0).getListenerClass());
       assertEquals("test listener", list.get(0).getListenerName());
+      assertEquals(100, list.get(0).getOrdinal());
    }
 
    /**
@@ -758,16 +759,20 @@ public class PortletApplicationDefinition362ImplTest {
    public void testAddListener() {
       String clsName = "org.apache.pluto.container.om.portlet.impl.fixtures.DifferentListener";
       String lisName = "Different Listener";
+      int ord = 200;
       Listener newitem = new ListenerImpl(clsName);
       newitem.setListenerName(lisName);
+      newitem.setOrdinal(ord);
       
       cut.addListener(newitem);
       
       List<Listener> list = cut.getListeners();
       assertNotNull(list);
       assertEquals(2, list.size());
-      assertEquals(clsName, list.get(1).getListenerClass());
-      assertEquals(lisName, list.get(1).getListenerName());
+      Listener testItem = list.get(1);
+      assertEquals(clsName, testItem.getListenerClass());
+      assertEquals(lisName, testItem.getListenerName());
+      assertEquals(ord, testItem.getOrdinal());
    }
 
    /**
@@ -777,16 +782,43 @@ public class PortletApplicationDefinition362ImplTest {
    public void testAddDupListener() {
       String clsName = "org.apache.pluto.container.om.portlet.impl.fixtures.TestListener";
       String lisName = "test listener";
+      int ord = 100;
       Listener newitem = new ListenerImpl(clsName);
       newitem.setListenerName(lisName);
+      newitem.setOrdinal(ord);
       
       cut.addListener(newitem);
       
       List<Listener> list = cut.getListeners();
       assertNotNull(list);
       assertEquals(1, list.size());
-      assertEquals(clsName, list.get(0).getListenerClass());
-      assertEquals(lisName, list.get(0).getListenerName());
+      Listener testItem = list.get(0);
+
+      assertEquals(clsName, testItem.getListenerClass());
+      assertEquals(lisName, testItem.getListenerName());
+      assertEquals(ord, testItem.getOrdinal());
+   }
+
+   /**
+    * Test method for {@link org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl#addListener(org.apache.pluto.container.om.portlet.Listener)}.
+    */
+   @Test
+   public void testReplaceListenerClass() {
+      String clsName = "org.apache.pluto.container.om.portlet.impl.fixtures.DifferentListener";
+      String lisName = "test listener";
+      Listener newitem = new ListenerImpl(clsName);
+      newitem.setListenerName(lisName);
+      
+      cut.addListener(newitem);
+      
+      List<Listener> list = cut.getListeners();
+      assertNotNull(list);
+      assertEquals(1, list.size());
+      Listener testItem = list.get(0);
+
+      assertEquals(clsName, testItem.getListenerClass());
+      assertEquals(lisName, testItem.getListenerName());
+      assertEquals(0, testItem.getOrdinal());
    }
 
    /**

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/a05e1563/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/PortletListenerAnnotationTest.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/PortletListenerAnnotationTest.java b/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/PortletListenerAnnotationTest.java
new file mode 100644
index 0000000..4f7459c
--- /dev/null
+++ b/pluto-container/src/test/java/org/apache/pluto/container/om/portlet/impl/jsr362/PortletListenerAnnotationTest.java
@@ -0,0 +1,237 @@
+/*  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+
+package org.apache.pluto.container.om.portlet.impl.jsr362;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Set;
+
+import org.apache.pluto.container.om.portlet.Listener;
+import org.apache.pluto.container.om.portlet.PortletApplicationDefinition;
+import org.apache.pluto.container.om.portlet.impl.ConfigurationHolder;
+import org.apache.pluto.container.om.portlet.impl.ListenerImpl;
+import org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl;
+import org.apache.pluto.container.om.portlet.impl.fixtures.TestAnnotatedListener;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Junit test cases for JSR 362 portlet application definition.
+ * @author Scott Nicklous
+ *
+ */
+public class PortletListenerAnnotationTest {
+   
+   private static final Class<?> TEST_ANNOTATED_CLASS = TestAnnotatedListener.class;
+   
+   private static PortletApplicationDefinition pad;
+   private static ConfigurationHolder cfp;
+   
+   // class under test; cloned new for each test
+   private  PortletApplicationDefinition cut;
+
+   /**
+    * @throws java.lang.Exception
+    */
+   @BeforeClass
+   public static void setUpBeforeClass() throws Exception {
+
+      Set<Class<?>> classes = new HashSet<Class<?>>();
+      classes.add(TEST_ANNOTATED_CLASS);
+      cfp = new ConfigurationHolder();
+      try {
+         cfp.processConfigAnnotations(classes);
+         pad = cfp.getPad();
+      } catch (Exception e) {
+         e.printStackTrace();
+         throw e;
+      }
+   }
+   
+   @Before
+   public void setUpBefore() throws Exception {
+      cut = new PortletApplicationDefinitionImpl(pad);
+   }
+
+   /**
+    * Test method for {@link org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl#getListener(java.lang.String)}.
+    */
+   @Test
+   public void testGetListener() {
+      String newItem = "aListener";
+      Listener item = cut.getListener(newItem);
+      assertNotNull(item);
+      Listener listener = cut.getListeners().get(0);
+      assertEquals("org.apache.pluto.container.om.portlet.impl.fixtures.TestAnnotatedListener", 
+            listener.getListenerClass());
+   }
+   
+   @Test
+   public void testListenerDescription() {
+      String newItem = "aListener";
+      Listener listener = cut.getListener(newItem);
+      assertNotNull(listener);
+      assertEquals(2, listener.getDescriptions().size());
+      assertEquals("Ein ordentlicher Listener", listener.getDescription(new Locale("de")).getText());
+      assertEquals("Quite the listener", listener.getDescription(Locale.ENGLISH).getText());
+   }
+
+   @Test
+   public void testListenerDisplayName() {
+      String newItem = "aListener";
+      Listener listener = cut.getListener(newItem);
+      assertNotNull(listener);
+      assertEquals(2, listener.getDisplayNames().size());
+      assertEquals("Ein Listener", listener.getDisplayName(Locale.GERMAN).getText());
+      assertEquals("A Listener", listener.getDisplayName(new Locale("en")).getText());
+   }
+
+   @Test
+   public void testListenerOrdinal() {
+      String newItem = "aListener";
+      Listener listener = cut.getListener(newItem);
+      assertNotNull(listener);
+      assertEquals(100, listener.getOrdinal());
+   }
+
+   /**
+    * Test method for {@link org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl#getListeners()}.
+    */
+   @Test
+   public void testGetListeners() {
+      String newItem = "aListener";
+      List<Listener> list = cut.getListeners();
+      assertNotNull(list);
+      assertEquals(1, list.size());
+      assertEquals(newItem, list.get(0).getListenerName());
+      assertEquals(100, list.get(0).getOrdinal());
+   }
+
+   /**
+    * Test method for {@link org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl#addListener(org.apache.pluto.container.om.portlet.Listener)}.
+    */
+   @Test
+   public void testAddListener() {
+      String newItem = "newListener";
+      Listener l = new ListenerImpl("SomeClass");
+      l.setListenerName(newItem);
+      l.setOrdinal(200);
+      cut.addListener(l);
+      
+      List<Listener> list = cut.getListeners();
+      assertNotNull(list);
+      assertEquals(2, list.size());
+      assertEquals(newItem, list.get(1).getListenerName());
+   }
+
+   /**
+    * Test method for {@link org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl#addListener(org.apache.pluto.container.om.portlet.Listener)}.
+    */
+   @Test
+   public void checkListenerOrder1() {
+      String newItem = "newListener";
+      String oldItem = "aListener";
+      Listener l = new ListenerImpl("SomeClass");
+      l.setListenerName(newItem);
+      l.setOrdinal(10);
+      cut.addListener(l);
+      
+      List<Listener> list = cut.getListeners();
+      assertNotNull(list);
+      assertEquals(2, list.size());
+      assertEquals(newItem, list.get(0).getListenerName());
+      assertEquals(oldItem, list.get(1).getListenerName());
+   }
+
+   /**
+    * Test method for {@link org.apache.pluto.container.om.portlet.impl.PortletApplicationDefinitionImpl#addListener(org.apache.pluto.container.om.portlet.Listener)}.
+    */
+   @Test
+   public void checkListenerOrder2() {
+      String newItem = "newListener";
+      String oldItem = "aListener";
+      Listener l = new ListenerImpl("SomeClass");
+      l.setListenerName(newItem);
+      l.setOrdinal(1000);
+      cut.addListener(l);
+      
+      List<Listener> list = cut.getListeners();
+      assertNotNull(list);
+      assertEquals(2, list.size());
+      assertEquals(newItem, list.get(1).getListenerName());
+      assertEquals(oldItem, list.get(0).getListenerName());
+   }
+
+   /**
+    * Test method to delete listener when class is null
+    */
+   @Test
+   public void deleteListener1() {
+      String oldItem = "aListener";
+      Listener l = new ListenerImpl((String)null);
+      l.setListenerName(oldItem);
+      l.setOrdinal(1000);
+      cut.addListener(l);
+      
+      List<Listener> list = cut.getListeners();
+      assertNotNull(list);
+      assertEquals(0, list.size());
+   }
+
+   /**
+    * Test method to delete listener when class is empty
+    */
+   @Test
+   public void deleteListener2() {
+      String oldItem = "aListener";
+      Listener l = new ListenerImpl("");
+      l.setListenerName(oldItem);
+      l.setOrdinal(1000);
+      cut.addListener(l);
+      
+      List<Listener> list = cut.getListeners();
+      assertNotNull(list);
+      assertEquals(0, list.size());
+   }
+
+   /**
+    * Test method for replacing a listener definition
+    */
+   @Test
+   public void testAddDupListener() {
+      String newItem = "aListener";
+      String clsName = "SomeClass";
+      Listener fil = new ListenerImpl(clsName);
+      fil.setListenerName(newItem);
+      cut.addListener(fil);
+      
+      List<Listener> list = cut.getListeners();
+      assertNotNull(list);
+      assertEquals(1, list.size());
+      assertEquals(newItem, list.get(0).getListenerName());
+      assertEquals(clsName, list.get(0).getListenerClass());
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/a05e1563/pluto-container/src/test/resources/org/apache/pluto/container/om/portlet/portlet362AlterFilter.xml
----------------------------------------------------------------------
diff --git a/pluto-container/src/test/resources/org/apache/pluto/container/om/portlet/portlet362AlterFilter.xml b/pluto-container/src/test/resources/org/apache/pluto/container/om/portlet/portlet362AlterFilter.xml
new file mode 100644
index 0000000..6670706
--- /dev/null
+++ b/pluto-container/src/test/resources/org/apache/pluto/container/om/portlet/portlet362AlterFilter.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<portlet-app id="id1" version="3.0"
+   xmlns="http://xmlns.jcp.org/xml/ns/portlet" 
+   xmlns:portlet="http://xmlns.jcp.org/xml/ns/portlet" 
+   xmlns:xml="http://www.w3.org/XML/1998/namespace"
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/portlet portlet-app_3_0.xsd ">
+
+   <!-- JSR 362 portlet DD test file -->
+
+   <portlet id="id2">
+      <portlet-name>portlet1</portlet-name>
+      <display-name xml:lang="de">display-name</display-name>
+   </portlet>
+   <filter>
+      <!-- delete bFilter from configuration (no filter class) -->
+      <filter-name>bFilter</filter-name>
+   </filter>
+   <filter>
+      <!-- change aFilter to use different class -->
+      <filter-name>aFilter</filter-name>
+      <filter-class>org.apache.pluto.container.om.portlet.impl.fixtures.TestFilter</filter-class>
+      <ordinal>-40</ordinal>
+   </filter>
+</portlet-app>

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/a05e1563/pluto-container/src/test/resources/org/apache/pluto/container/om/portlet/portlet362AlterListener.xml
----------------------------------------------------------------------
diff --git a/pluto-container/src/test/resources/org/apache/pluto/container/om/portlet/portlet362AlterListener.xml b/pluto-container/src/test/resources/org/apache/pluto/container/om/portlet/portlet362AlterListener.xml
new file mode 100644
index 0000000..e00cd2e
--- /dev/null
+++ b/pluto-container/src/test/resources/org/apache/pluto/container/om/portlet/portlet362AlterListener.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<portlet-app id="id1" version="3.0"
+   xmlns="http://xmlns.jcp.org/xml/ns/portlet" 
+   xmlns:portlet="http://xmlns.jcp.org/xml/ns/portlet" 
+   xmlns:xml="http://www.w3.org/XML/1998/namespace"
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/portlet portlet-app_3_0.xsd ">
+
+   <!-- JSR 362 portlet DD test file -->
+
+   <portlet id="id2">
+      <portlet-name>portlet1</portlet-name>
+      <display-name xml:lang="de">display-name</display-name>
+   </portlet>
+   <listener>
+      <!-- delete bListener from configuration (no listener class) -->
+      <listener-name>bListener</listener-name>
+   </listener>
+   <listener>
+      <!-- change aListener to use different class -->
+      <listener-name>aListener</listener-name>
+      <listener-class>org.apache.pluto.container.om.portlet.impl.fixtures.TestListener</listener-class>
+      <ordinal>-40</ordinal>
+   </listener>
+</portlet-app>