1 16 package org.apache.jetspeed.services.forward; 17 18 import java.util.Collection ; 19 import java.util.Map ; 20 import java.util.Iterator ; 21 22 import junit.framework.Test; 24 import junit.framework.TestSuite; 25 26 27 import org.apache.jetspeed.test.HeadlessBaseTest; 28 import org.apache.jetspeed.util.ServiceUtil; 29 30 import org.apache.jetspeed.services.forward.configuration.Forward; 31 import org.apache.jetspeed.services.forward.configuration.PortletForward; 32 import org.apache.jetspeed.services.forward.configuration.Page; 33 import org.apache.jetspeed.services.forward.configuration.Pane; 34 import org.apache.jetspeed.services.forward.configuration.Portlet; 35 import org.apache.jetspeed.services.forward.configuration.QueryParam; 36 37 43 44 public class TestForwardService extends HeadlessBaseTest 45 { 46 51 public TestForwardService( String name ) { 52 super( name ); 53 } 54 55 60 public static void main(String args[]) { 61 junit.awtui.TestRunner.main( new String [] { TestForwardService.class.getName() } ); 62 } 63 64 public void setup() { 65 System.out.println("Setup: Testing TestForwardService"); 66 } 67 68 public static Test suite() 69 { 70 return new TestSuite( TestForwardService.class ); 72 } 73 74 75 77 public void testConfiguration() throws Exception 78 { 79 try 80 { 81 System.out.println("Running TestForwardService"); 82 ForwardService fs = (ForwardService)ServiceUtil.getServiceByName("ForwardService"); 83 assertNotNull(fs); 84 Collection forwards = fs.getForwards(); 85 Iterator it = forwards.iterator(); 86 while (it.hasNext()) 87 { 88 System.out.println("-------------------------------------------"); 89 90 Forward forward = (Forward)it.next(); 91 System.out.println("forward = " + forward.getName()); 92 Page page = forward.getPage(); 93 Pane pane = forward.getPane(); 94 Portlet portlet = forward.getPortlet(); 95 if (page != null) 96 { 97 System.out.println("page = " + page.getName() + ", user = " + page.getUser()); 98 } 99 if (pane != null) 100 { 101 System.out.println("pane = " + pane.getId()); 102 } 103 if (portlet != null) 104 { 105 System.out.println("portlet = " + portlet.getId() + ", action = " + portlet.getAction()); 106 } 107 printQueryParams(forward.getQueryParams()); 108 } 109 Collection pfs = fs.getPortletForwards(); 110 it = pfs.iterator(); 111 while (it.hasNext()) 112 { 113 System.out.println("-------------------------------------------"); 114 115 PortletForward pf = (PortletForward)it.next(); 116 System.out.println("PF: portlet = " + pf.getPortlet() + ", forward = " + pf.getForward() + ", target = " + pf.getTarget()); 117 printQueryParams(pf.getQueryParams()); 118 } 119 120 System.out.println("End Run TestForwardService"); 121 } 122 catch (Throwable t) 123 { 124 t.printStackTrace(); 125 } 126 } 127 128 private void printQueryParams(Map qparams) 129 { 130 Iterator it = qparams.values().iterator(); 131 while (it.hasNext()) 132 { 133 QueryParam qp = (QueryParam)it.next(); 134 System.out.println("QP: name = " + qp.getName() + ", value = " + qp.getValue()); 135 } 136 137 } 138 139 140 } 141 | Popular Tags |