1   package org.portletbridge.portlet;
2   
3   import java.util.PropertyResourceBundle;
4   import java.util.ResourceBundle;
5   
6   import javax.portlet.PortletMode;
7   import javax.portlet.WindowState;
8   
9   import org.portletbridge.mock.MockBridgeTransformer;
10  import org.portletbridge.mock.MockHttpClientTemplate;
11  import org.portletbridge.mock.MockPortletConfig;
12  import org.portletbridge.mock.MockPortletPreferences;
13  import org.portletbridge.mock.MockPortletSession;
14  import org.portletbridge.mock.MockRenderRequest;
15  import org.portletbridge.mock.MockRenderResponse;
16  
17  import junit.framework.TestCase;
18  
19  public class BridgeViewPortletTest extends TestCase {
20  
21      public BridgeViewPortletTest(String name) {
22          super(name);
23      }
24  
25      protected void setUp() throws Exception {
26          super.setUp();
27      }
28  
29      protected void tearDown() throws Exception {
30          super.tearDown();
31      }
32  
33      /*
34       * Test method for 'org.portletbridge.portlet.BridgeViewPortlet.doView(RenderRequest, RenderResponse)'
35       */
36      public void testDoView() throws Exception {
37          BridgeViewPortlet portlet = new BridgeViewPortlet();
38          ResourceBundle bundle = PropertyResourceBundle.getBundle("org.portletbridge.portlet.PortletBridgePortlet");
39          MockPortletConfig mockPortletConfig = new MockPortletConfig();
40          mockPortletConfig.setupResourceBundle(bundle);
41          portlet.init(mockPortletConfig);
42          portlet.setHttpClientTemplate(new MockHttpClientTemplate());
43          portlet.setMementoSessionKey("mementoSessionKey");
44          portlet.setTransformer(new MockBridgeTransformer());
45          MockRenderRequest mockRenderRequest = new MockRenderRequest();
46          mockRenderRequest.setupWindowState(WindowState.NORMAL);
47          mockRenderRequest.setupPortletMode(PortletMode.VIEW);
48          mockRenderRequest.setupPortletSession(new MockPortletSession());
49          MockPortletPreferences mockPortletPreferences = new MockPortletPreferences();
50          mockPortletPreferences.setValue("initUrl", "http://blah:8080/");
51          mockPortletPreferences.setValue("stylesheet", "classpath:/org/portletbridge/xsl/default.xsl");
52          mockRenderRequest.setupPortletPreferences(mockPortletPreferences);
53          MockRenderResponse mockRenderResponse = new MockRenderResponse();
54          portlet.render(mockRenderRequest, mockRenderResponse);
55      }
56      
57      public static void main(String[] args) throws Exception {
58          BridgeViewPortletTest test = new BridgeViewPortletTest("BridgeViewPortletTest");
59          test.setUp();
60          test.testDoView();
61          test.tearDown();
62      }
63  
64  }