1 16 17 package org.apache.jetspeed.services.profiler; 18 19 import java.io.File ; 20 21 import junit.framework.Test; 23 import junit.framework.TestSuite; 24 25 import org.apache.jetspeed.test.JetspeedTestCase; 27 import org.apache.jetspeed.om.profile.*; 28 import org.apache.jetspeed.om.profile.psml.*; 29 30 import org.apache.jetspeed.services.Profiler; 31 32 import org.apache.turbine.util.TurbineConfig; 33 import org.apache.turbine.util.StringUtils; 34 35 41 42 public class TestProfilerService extends JetspeedTestCase { 43 44 49 public TestProfilerService( String name ) { 50 super( name ); 51 } 52 53 58 public static void main(String args[]) { 59 junit.awtui.TestRunner.main( new String [] { TestProfilerService.class.getName() } ); 60 } 61 62 public void setup() { 63 System.out.println("Setup: Testing categories of Profiler Service"); 64 } 65 71 public static Test suite() { 72 return new TestSuite( TestProfilerService.class ); 74 } 75 76 80 public void testCreateProfile() throws Exception 81 { 82 try 83 { 84 ProfileLocator locator = Profiler.createLocator(); 85 locator.setGroupByName("apache"); 86 locator.setName("create-test"); 87 88 Portlets portlets = new PsmlPortlets(); 89 Control control = new PsmlControl(); 90 Controller controller = new PsmlController(); 91 control.setName("BoxControl"); 92 controller.setName("GridPortletController"); 93 portlets.setControl(control); 94 portlets.setController(controller); 95 Profile profile = Profiler.createProfile(locator, portlets); 96 PSMLDocument doc = profile.getDocument(); 97 98 System.out.println("doc = " + doc.getName()); 99 100 File file = new File (doc.getName()); 102 assertTrue(file.exists()); 103 } 105 catch (Exception e) 106 { 107 String errmsg = "Error in Profiler Service: " + e.toString(); 108 e.printStackTrace(); 109 assertNotNull(errmsg, null); 110 } 111 } 112 113 117 private static TurbineConfig config = null; 118 119 123 static 124 { 125 try 126 { 127 config = new TurbineConfig( "webapp", "/WEB-INF/conf/TurbineResources.properties"); 128 config.init(); 129 } 130 catch (Exception e) 131 { 132 fail(StringUtils.stackTrace(e)); 133 } 134 } 135 } 136 137 | Popular Tags |