1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.chain.web.portlet;
18  
19  
20  import junit.framework.Test;
21  import junit.framework.TestSuite;
22  import org.apache.commons.chain.Context;
23  import org.apache.commons.chain.impl.ContextBaseTestCase;
24  import org.apache.commons.chain.web.WebContext;
25  
26  import javax.portlet.PortletContext;
27  import javax.portlet.PortletRequest;
28  import javax.portlet.PortletResponse;
29  import javax.portlet.PortletSession;
30  import java.util.HashMap;
31  import java.util.Iterator;
32  import java.util.Map;
33  import java.util.Set;
34  import java.util.Collection;
35  
36  
37  /**
38   * Extension of <code>ContextBaseTestCase</code> to validate the
39   * extra functionality of this implementation.
40   */
41  
42  public class PortletWebContextTestCase extends ContextBaseTestCase {
43  
44  
45      // ---------------------------------------------------------- Constructors
46  
47      /**
48       * Construct a new instance of this test case.
49       *
50       * @param name Name of the test case
51       */
52      public PortletWebContextTestCase(String name) {
53          super(name);
54      }
55  
56  
57      // ----------------------------------------------------- Instance Variables
58  
59  
60      // Portlet API Objects
61      protected PortletContext pcontext = null;
62      protected PortletRequest request = null;
63      protected PortletResponse response = null;
64      protected PortletSession session = null;
65  
66  
67      // -------------------------------------------------- Overall Test Methods
68  
69  
70      /**
71       * Set up instance variables required by this test case.
72       */
73      public void setUp() {
74          pcontext = new MockPortletContext();
75          pcontext.setAttribute("akey1", "avalue1");
76          pcontext.setAttribute("akey2", "avalue2");
77          pcontext.setAttribute("akey3", "avalue3");
78          pcontext.setAttribute("akey4", "avalue4");
79          ((MockPortletContext) pcontext).addInitParameter("ikey1", "ivalue1");
80          ((MockPortletContext) pcontext).addInitParameter("ikey2", "ivalue2");
81          ((MockPortletContext) pcontext).addInitParameter("ikey3", "ivalue3");
82          session = new MockPortletSession(pcontext);
83          session.setAttribute("skey1", "svalue1");
84          session.setAttribute("skey2", "svalue2");
85          session.setAttribute("skey3", "svalue3");
86          request = new MockPortletRequest(null, pcontext, session);
87          request.setAttribute("rkey1", "rvalue1");
88          request.setAttribute("rkey2", "rvalue2");
89          ((MockPortletRequest) request).addParameter("pkey1", "pvalue1");
90          ((MockPortletRequest) request).addParameter("pkey2", "pvalue2a");
91          ((MockPortletRequest) request).addParameter("pkey2", "pvalue2b");
92          context = createContext();
93      }
94  
95  
96      /**
97       * Return the tests included in this test suite.
98       */
99      public static Test suite() {
100         return (new TestSuite(PortletWebContextTestCase.class));
101     }
102 
103 
104     /**
105      * Tear down instance variables required by this test case.
106      */
107     public void tearDown() {
108         pcontext = null;
109         session = null;
110         request = null;
111         response = null;
112         context = null;
113     }
114 
115 
116     // ------------------------------------------------ Individual Test Methods
117 
118 
119     // Test getApplicationScope()
120     public void testApplicationScope() {
121 
122         Map map = ((WebContext) context).getApplicationScope();
123         assertNotNull(map);
124 
125         // Initial contents
126         checkMapSize(map, 4);
127         assertEquals("avalue1", (String) map.get("akey1"));
128         assertEquals("avalue2", (String) map.get("akey2"));
129         assertEquals("avalue3", (String) map.get("akey3"));
130         assertEquals("avalue4", (String) map.get("akey4"));
131 
132         // Transparency - entrySet()
133         checkEntrySet(map, true);
134  
135         // Transparency - removal via web object
136         pcontext.removeAttribute("akey1");
137         checkMapSize(map, 3);
138         assertNull(map.get("akey1"));
139 
140         // Transparency - removal via map
141         map.remove("akey2");
142         checkMapSize(map, 2);
143         assertNull(pcontext.getAttribute("akey2"));
144 
145         // Transparency - addition via web object
146         pcontext.setAttribute("akeyA", "avalueA");
147         checkMapSize(map, 3);
148         assertEquals("avalueA", (String) map.get("akeyA"));
149 
150         // Transparency - addition via map
151         map.put("akeyB", "avalueB");
152         checkMapSize(map, 4);
153         assertEquals("avalueB", (String) pcontext.getAttribute("akeyB"));
154 
155         // Transparency - replacement via web object
156         pcontext.setAttribute("akeyA", "newvalueA");
157         checkMapSize(map, 4);
158         assertEquals("newvalueA", (String) map.get("akeyA"));
159 
160         // Transparency - replacement via map
161         map.put("akeyB", "newvalueB");
162         assertEquals(4, map.size());
163         assertEquals("newvalueB", (String) pcontext.getAttribute("akeyB"));
164 
165         // Clearing the map
166         map.clear();
167         checkMapSize(map, 0);
168 
169         // Test putAll()
170         Map values = new HashMap();
171         values.put(new Integer(1), "One");
172         values.put("2", "Two");
173         map.putAll(values);
174         assertEquals("putAll(1)", "One", map.get("1"));
175         assertEquals("putAll(2)", "Two", map.get("2"));
176         checkMapSize(map, 2);
177 
178     }
179 
180 
181     // Test equals() and hashCode()
182     // Copied from ContextBaseTestCase with customized creation of "other"
183     public void testEquals() {
184 
185         // Compare to self
186         assertTrue(context.equals(context));
187         assertTrue(context.hashCode() == context.hashCode());
188 
189         // Compare to equivalent instance
190         Context other = new PortletWebContext(pcontext, request, response);
191         // assertTrue(context.equals(other));
192         assertTrue(context.hashCode() == other.hashCode());
193 
194         // Compare to non-equivalent instance - other modified
195         other.put("bop", "bop value");
196         // assertTrue(!context.equals(other));
197         assertTrue(context.hashCode() != other.hashCode());
198 
199         // Compare to non-equivalent instance - self modified
200         other = new PortletWebContext(pcontext, request, response);
201         context.put("bop", "bop value");
202         // assertTrue(!context.equals(other));
203         assertTrue(context.hashCode() != other.hashCode());
204 
205     }        
206 
207 
208     // Test getHeader()
209     public void testHeader() {
210 
211         Map map = ((WebContext) context).getHeader();
212         assertNotNull("Header Map Null", map);
213 
214         // Initial contents
215         checkMapSize(map, 0);
216 
217         try {
218             map.put("hkey3", "hvalue3");
219             fail("Should have thrown UnsupportedOperationException");
220         } catch (UnsupportedOperationException e) {
221             ; // expected result
222         }
223 
224     }
225 
226 
227     // Test getHeaderValues()
228     public void testHeaderValues() {
229 
230         Map map = ((WebContext) context).getHeaderValues();
231         assertNotNull("HeaderValues Map Null", map);
232 
233         // Initial contents
234         checkMapSize(map, 0);
235  
236         try {
237             map.put("hkey3", "ABC");
238             fail("Should have thrown UnsupportedOperationException");
239         } catch (UnsupportedOperationException e) {
240             ; // expected result
241         }
242 
243     }
244 
245 
246     // Test getInitParam()
247     public void testInitParam() {
248 
249         Map map = ((WebContext) context).getInitParam();
250         assertNotNull(map);
251 
252         // Initial contents
253         checkMapSize(map, 3);
254         assertEquals("ivalue1", (String) map.get("ikey1"));
255         assertEquals("ivalue2", (String) map.get("ikey2"));
256         assertEquals("ivalue3", (String) map.get("ikey3"));
257         assertTrue(map.containsKey("ikey1"));
258         assertTrue(map.containsKey("ikey2"));
259         assertTrue(map.containsKey("ikey3"));
260         assertTrue(map.containsValue("ivalue1"));
261         assertTrue(map.containsValue("ivalue2"));
262         assertTrue(map.containsValue("ivalue3"));
263 
264         // Transparency - entrySet()
265         checkEntrySet(map, false);
266  
267         // Unsupported operations on read-only map
268         try {
269             map.clear();
270             fail("Should have thrown UnsupportedOperationException");
271         } catch (UnsupportedOperationException e) {
272             ; // expected result
273         }
274         try {
275             map.put("ikey4", "ivalue4");
276             fail("Should have thrown UnsupportedOperationException");
277         } catch (UnsupportedOperationException e) {
278             ; // expected result
279         }
280         try {
281             map.putAll(new HashMap());
282             fail("Should have thrown UnsupportedOperationException");
283         } catch (UnsupportedOperationException e) {
284             ; // expected result
285         }
286         try {
287             map.remove("ikey1");
288             fail("Should have thrown UnsupportedOperationException");
289         } catch (UnsupportedOperationException e) {
290             ; // expected result
291         }
292 
293     }
294 
295 
296     // Test getParam()
297     public void testParam() {
298 
299         Map map = ((WebContext) context).getParam();
300         assertNotNull(map);
301 
302         // Initial contents
303         checkMapSize(map, 2);
304         assertEquals("pvalue1", (String) map.get("pkey1"));
305         assertEquals("pvalue2a", (String) map.get("pkey2"));
306         assertTrue(map.containsKey("pkey1"));
307         assertTrue(map.containsKey("pkey2"));
308         assertTrue(map.containsValue("pvalue1"));
309         assertTrue(map.containsValue("pvalue2a"));
310 
311         checkEntrySet(map, false);
312 
313         // Unsupported operations on read-only map
314         try {
315             map.clear();
316             fail("Should have thrown UnsupportedOperationException");
317         } catch (UnsupportedOperationException e) {
318             ; // expected result
319         }
320         try {
321             map.put("pkey3", "pvalue3");
322             fail("Should have thrown UnsupportedOperationException");
323         } catch (UnsupportedOperationException e) {
324             ; // expected result
325         }
326         try {
327             map.putAll(new HashMap());
328             fail("Should have thrown UnsupportedOperationException");
329         } catch (UnsupportedOperationException e) {
330             ; // expected result
331         }
332         try {
333             map.remove("pkey1");
334             fail("Should have thrown UnsupportedOperationException");
335         } catch (UnsupportedOperationException e) {
336             ; // expected result
337         }
338 
339     }
340 
341 
342     // Test getParamValues()
343     public void testParamValues() {
344 
345         Map map = ((WebContext) context).getParamValues();
346         assertNotNull(map);
347 
348         // Initial contents
349         checkMapSize(map, 2);
350         Object value1 = map.get("pkey1");
351         assertNotNull(value1);
352         assertTrue(value1 instanceof String[]);
353         String values1[] = (String[]) value1;
354         assertEquals(1, values1.length);
355         assertEquals("pvalue1", values1[0]);
356         Object value2 = map.get("pkey2");
357         assertNotNull(value2);
358         assertTrue(value2 instanceof String[]);
359         String values2[] = (String[]) value2;
360         assertEquals(2, values2.length);
361         assertEquals("pvalue2a", values2[0]);
362         assertEquals("pvalue2b", values2[1]);
363         assertTrue(map.containsKey("pkey1"));
364         assertTrue(map.containsKey("pkey2"));
365         assertTrue(map.containsValue(values1));
366         assertTrue(map.containsValue(values2));
367 
368         // Unsupported operations on read-only map
369         try {
370             map.clear();
371             fail("Should have thrown UnsupportedOperationException");
372         } catch (UnsupportedOperationException e) {
373             ; // expected result
374         }
375         try {
376             map.put("pkey3", values2);
377             fail("Should have thrown UnsupportedOperationException");
378         } catch (UnsupportedOperationException e) {
379             ; // expected result
380         }
381         try {
382             map.putAll(new HashMap());
383             fail("Should have thrown UnsupportedOperationException");
384         } catch (UnsupportedOperationException e) {
385             ; // expected result
386         }
387         try {
388             map.remove("pkey1");
389             fail("Should have thrown UnsupportedOperationException");
390         } catch (UnsupportedOperationException e) {
391             ; // expected result
392         }
393 
394     }
395 
396 
397     // Test getCookies()
398     public void testCookies() {
399 
400         Map map = ((WebContext) context).getCookies();
401         assertNotNull(map);
402 
403         // Initial contents
404         checkMapSize(map, 0);
405 
406         try {
407             map.put("ckey3", "XXX");
408             fail("map.put() Should have thrown UnsupportedOperationException");
409         } catch (UnsupportedOperationException e) {
410             ; // expected result
411         }
412     }
413 
414     // Test state of newly created instance
415     public void testPristine() {
416 
417         super.testPristine();
418         PortletWebContext pwcontext = (PortletWebContext) context;
419 
420         // Properties should all be non-null
421         assertNotNull(pwcontext.getApplicationScope());
422         assertNotNull(pwcontext.getHeader());
423         assertNotNull(pwcontext.getHeaderValues());
424         assertNotNull(pwcontext.getInitParam());
425         assertNotNull(pwcontext.getParam());
426         assertNotNull(pwcontext.getParamValues());
427         assertNotNull(pwcontext.getCookies());
428         assertNotNull(pwcontext.getRequestScope());
429         assertNotNull(pwcontext.getSessionScope());
430 
431         // Attribute-property transparency
432         assertTrue(pwcontext.getApplicationScope() ==
433                      pwcontext.get("applicationScope"));
434         assertTrue(pwcontext.getHeader() ==
435                      pwcontext.get("header"));
436         assertTrue(pwcontext.getHeaderValues() ==
437                      pwcontext.get("headerValues"));
438         assertTrue(pwcontext.getInitParam() ==
439                      pwcontext.get("initParam"));
440         assertTrue(pwcontext.getParam() ==
441                      pwcontext.get("param"));
442         assertTrue(pwcontext.getParamValues() ==
443                      pwcontext.get("paramValues"));
444         assertTrue(pwcontext.getCookies() ==
445                      pwcontext.get("cookies"));
446         assertTrue(pwcontext.getRequestScope() ==
447                      pwcontext.get("requestScope"));
448         assertTrue(pwcontext.getSessionScope() ==
449                      pwcontext.get("sessionScope"));
450 
451     }
452 
453 
454     // Test release()
455     public void testRelease() {
456 
457         PortletWebContext pwcontext = (PortletWebContext) context;
458         pwcontext.release();
459 
460         // Properties should all be null
461         assertNull("getApplicationScope()", pwcontext.getApplicationScope());
462         assertNull("getHeader()", pwcontext.getHeader());
463         assertNull("getHeaderValues()", pwcontext.getHeaderValues());
464         assertNull("getInitParam()", pwcontext.getInitParam());
465         assertNull("getParam()", pwcontext.getParam());
466         assertNull("getParamValues()", pwcontext.getParamValues());
467         assertNull("getRequestScope()", pwcontext.getRequestScope());
468         assertNull("getSessionScope()", pwcontext.getSessionScope());
469 
470         // Attributes should all be null
471         assertNull("applicationScope", pwcontext.get("applicationScope"));
472         assertNull("header", pwcontext.get("header"));
473         assertNull("headerValues", pwcontext.get("headerValues"));
474         assertNull("initParam", pwcontext.get("initParam"));
475         assertNull("param", pwcontext.get("param"));
476         assertNull("paramValues", pwcontext.get("paramValues"));
477         assertNull("requestScope", pwcontext.get("requestScope"));
478         assertNull("sessionScope", pwcontext.get("sessionScope"));
479 
480     }
481 
482 
483     // Test getRequestScope()
484     public void testRequestScope() {
485 
486         Map map = ((WebContext) context).getRequestScope();
487         assertNotNull(map);
488 
489         // Initial contents
490         checkMapSize(map, 2);
491         assertEquals("rvalue1", (String) map.get("rkey1"));
492         assertEquals("rvalue2", (String) map.get("rkey2"));
493 
494         // Transparency - entrySet()
495         checkEntrySet(map, true);
496  
497         // Transparency - removal via web object
498         request.removeAttribute("rkey1");
499         checkMapSize(map, 1);
500         assertNull(map.get("rkey1"));
501 
502         // Transparency - removal via map
503         map.remove("rkey2");
504         checkMapSize(map, 0);
505         assertNull(request.getAttribute("rkey2"));
506 
507         // Transparency - addition via web object
508         request.setAttribute("rkeyA", "rvalueA");
509         checkMapSize(map, 1);
510         assertEquals("rvalueA", (String) map.get("rkeyA"));
511 
512         // Transparency - addition via map
513         map.put("rkeyB", "rvalueB");
514         checkMapSize(map, 2);
515         assertEquals("rvalueB", (String) request.getAttribute("rkeyB"));
516 
517         // Transparency - replacement via web object
518         request.setAttribute("rkeyA", "newvalueA");
519         checkMapSize(map, 2);
520         assertEquals("newvalueA", (String) map.get("rkeyA"));
521 
522         // Transparency - replacement via map
523         map.put("rkeyB", "newvalueB");
524         checkMapSize(map, 2);
525         assertEquals("newvalueB", (String) request.getAttribute("rkeyB"));
526 
527         // Clearing the map
528         map.clear();
529         checkMapSize(map, 0);
530 
531         // Test putAll()
532         Map values = new HashMap();
533         values.put(new Integer(1), "One");
534         values.put("2", "Two");
535         map.putAll(values);
536         assertEquals("putAll(1)", "One", map.get("1"));
537         assertEquals("putAll(2)", "Two", map.get("2"));
538         checkMapSize(map, 2);
539 
540     }
541 
542 
543     // Test getSessionScope()
544     public void testSessionScope() {
545 
546         Map map = ((WebContext) context).getSessionScope();
547         assertNotNull(map);
548 
549         // Initial contents
550         checkMapSize(map, 3);
551         assertEquals("svalue1", (String) map.get("skey1"));
552         assertEquals("svalue2", (String) map.get("skey2"));
553         assertEquals("svalue3", (String) map.get("skey3"));
554 
555         // Transparency - entrySet()
556         checkEntrySet(map, true);
557  
558         // Transparency - removal via web object
559         session.removeAttribute("skey1");
560         checkMapSize(map, 2);
561         assertNull(map.get("skey1"));
562 
563         // Transparency - removal via map
564         map.remove("skey2");
565         checkMapSize(map, 1);
566         assertNull(session.getAttribute("skey2"));
567 
568         // Transparency - addition via web object
569         session.setAttribute("skeyA", "svalueA");
570         checkMapSize(map, 2);
571         assertEquals("svalueA", (String) map.get("skeyA"));
572 
573         // Transparency - addition via map
574         map.put("skeyB", "svalueB");
575         checkMapSize(map, 3);
576         assertEquals("svalueB", (String) session.getAttribute("skeyB"));
577 
578         // Transparency - replacement via web object
579         session.setAttribute("skeyA", "newvalueA");
580         checkMapSize(map, 3);
581         assertEquals("newvalueA", (String) map.get("skeyA"));
582 
583         // Transparency - replacement via map
584         map.put("skeyB", "newvalueB");
585         checkMapSize(map, 3);
586         assertEquals("newvalueB", (String) session.getAttribute("skeyB"));
587 
588         // Clearing the map
589         map.clear();
590         checkMapSize(map, 0);
591 
592         // Test putAll()
593         Map values = new HashMap();
594         values.put(new Integer(1), "One");
595         values.put("2", "Two");
596         map.putAll(values);
597         assertEquals("putAll(1)", "One", map.get("1"));
598         assertEquals("putAll(2)", "Two", map.get("2"));
599         checkMapSize(map, 2);
600 
601     }
602 
603 
604     // Test getSessionScope() without Session
605     public void testSessionScopeWithoutSession() {
606 
607         // Create a Context without a session
608         PortletWebContext ctx = new PortletWebContext(pcontext, 
609            new MockPortletRequest(), response);
610         assertNull("Session(A)", ctx.getRequest().getPortletSession(false));
611 
612         // Get the session Map & check session doesn't exist
613         Map sessionMap = ctx.getSessionScope();
614         assertNull("Session(B)", ctx.getRequest().getPortletSession(false));
615         assertNotNull("Session Map(A)", sessionMap);
616 
617         // test clear()
618         sessionMap.clear();
619         assertNull("Session(C)", ctx.getRequest().getPortletSession(false));
620 
621         // test containsKey()
622         assertFalse("containsKey()", sessionMap.containsKey("ABC"));
623         assertNull("Session(D)", ctx.getRequest().getPortletSession(false));
624 
625         // test containsValue()
626         assertFalse("containsValue()", sessionMap.containsValue("ABC"));
627         assertNull("Session(E)", ctx.getRequest().getPortletSession(false));
628 
629         // test entrySet()
630         Set entrySet = sessionMap.entrySet();
631         assertNotNull("entrySet", entrySet);
632         assertEquals("entrySet Size", 0, entrySet.size());
633         assertNull("Session(F)", ctx.getRequest().getPortletSession(false));
634 
635         // test equals()
636         assertFalse("equals()", sessionMap.equals("ABC"));
637         assertNull("Session(G)", ctx.getRequest().getPortletSession(false));
638 
639         // test get()
640         assertNull("get()", sessionMap.get("ABC"));
641         assertNull("Session(H)", ctx.getRequest().getPortletSession(false));
642 
643         // test hashCode()
644         sessionMap.hashCode();
645         assertNull("Session(I)", ctx.getRequest().getPortletSession(false));
646 
647         // test isEmpty()
648         assertTrue("isEmpty()", sessionMap.isEmpty());
649         assertNull("Session(J)", ctx.getRequest().getPortletSession(false));
650 
651         // test keySet()
652         Set keySet = sessionMap.keySet();
653         assertNotNull("keySet", keySet);
654         assertEquals("keySet Size", 0, keySet.size());
655         assertNull("Session(K)", ctx.getRequest().getPortletSession(false));
656 
657         // test putAll() with an empty Map
658         sessionMap.putAll(new HashMap());
659         assertNull("Session(L)", ctx.getRequest().getPortletSession(false));
660 
661         // test remove()
662         assertNull("remove()", sessionMap.remove("ABC"));
663         assertNull("Session(M)", ctx.getRequest().getPortletSession(false));
664 
665         // test size()
666         assertEquals("size() Size", 0, sessionMap.size());
667         assertNull("Session(N)", ctx.getRequest().getPortletSession(false));
668 
669         // test values()
670         Collection values = sessionMap.values();
671         assertNotNull("values", values);
672         assertEquals("values Size", 0, values.size());
673         assertNull("Session(O)", ctx.getRequest().getPortletSession(false));
674 
675         // test put()
676         try {
677             assertNull("put()", sessionMap.put("ABC", "XYZ"));
678             assertNotNull("Session(P)", ctx.getRequest().getPortletSession(false));
679         } catch(UnsupportedOperationException ex) {
680             // expected: currently MockPortletRequest throws this
681             //           when trying to create a PortletSession
682         }
683 
684     }
685 
686 
687     // ------------------------------------------------------- Protected Methods
688 
689 
690     protected void checkMapSize(Map map, int size) {
691         // Check reported size of the map
692         assertEquals("checkMapSize(A)", size, map.size());
693         // Iterate over key set
694         int nk = 0;
695         Iterator keys = map.keySet().iterator();
696         while (keys.hasNext()) {
697             keys.next();
698             nk++;
699         }
700         assertEquals("checkMapSize(B)", size, nk);
701         // Iterate over entry set
702         int nv = 0;
703         Iterator values = map.entrySet().iterator();
704         while (values.hasNext()) {
705             values.next();
706             nv++;
707         }
708         assertEquals("checkMapSize(C)", size, nv);
709         // Count the values
710         assertEquals("checkMapSize(D)", size, map.values().size());
711     }
712 
713     // Test to ensure proper entrySet() and are modifiable optionally
714     protected void checkEntrySet(Map map, boolean modifiable) {
715         assertTrue("checkEntrySet(A)", map.size() > 1);
716         Set entries = map.entrySet();
717         assertTrue(map.size() == entries.size());
718         Object o = entries.iterator().next();
719 
720         assertTrue("checkEntrySet(B)", o instanceof Map.Entry);
721 
722         if (!modifiable) {
723             try {
724                 ((Map.Entry)o).setValue(new Object());
725                 fail("Should have thrown UnsupportedOperationException");
726             } catch (UnsupportedOperationException e) {
727                 ; // expected result
728             }
729         } else {
730             // Should pass and not throw UnsupportedOperationException
731             Map.Entry e = (Map.Entry)o;
732             e.setValue(e.setValue(new Object()));
733         }    
734     }    
735 
736     // Create a new instance of the appropriate Context type for this test case
737     protected Context createContext() {
738         return (new PortletWebContext(pcontext, request, response));
739     }
740 
741 
742 }