001 // Copyright 2005 The Apache Software Foundation 002 // 003 // Licensed under the Apache License, Version 2.0 (the "License"); 004 // you may not use this file except in compliance with the License. 005 // You may obtain a copy of the License at 006 // 007 // http://www.apache.org/licenses/LICENSE-2.0 008 // 009 // Unless required by applicable law or agreed to in writing, software 010 // distributed under the License is distributed on an "AS IS" BASIS, 011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012 // See the License for the specific language governing permissions and 013 // limitations under the License. 014 015 package org.apache.tapestry.portlet; 016 017 import static org.easymock.EasyMock.expect; 018 019 import org.apache.tapestry.util.ContentType; 020 import org.testng.annotations.Test; 021 022 import javax.portlet.RenderResponse; 023 024 /** 025 * Tests for {@link org.apache.tapestry.portlet.RenderWebResponse}. 026 * 027 * @author Howard M. Lewis Ship 028 * @since 4.0 029 */ 030 @Test 031 public class TestRenderWebResponse extends BasePortletWebTestCase 032 { 033 private RenderResponse newResponse() 034 { 035 return newMock(RenderResponse.class); 036 } 037 038 public void testReset() 039 { 040 RenderResponse response = newResponse(); 041 042 response.reset(); 043 044 replay(); 045 046 RenderWebResponse rwr = new RenderWebResponse(response); 047 048 rwr.reset(); 049 050 verify(); 051 } 052 053 public void testGetOutputStream() throws Exception 054 { 055 RenderResponse response = newMock(RenderResponse.class); 056 057 replay(); 058 059 RenderWebResponse rwr = new RenderWebResponse(response); 060 061 try 062 { 063 rwr.getOutputStream(new ContentType("foo/bar")); 064 unreachable(); 065 } 066 catch (UnsupportedOperationException ex) 067 { 068 // Expected. 069 } 070 071 verify(); 072 } 073 074 public void testGetNamespace() 075 { 076 RenderResponse response = newMock(RenderResponse.class); 077 078 expect(response.getNamespace()).andReturn("_NAMESPACE_"); 079 080 replay(); 081 082 RenderWebResponse rwr = new RenderWebResponse(response); 083 084 assertEquals("_NAMESPACE_", rwr.getNamespace()); 085 086 verify(); 087 } 088 }