1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.services.profiler;
18
19 import java.io.File;
20
21
22 import junit.framework.Test;
23 import junit.framework.TestSuite;
24
25
26 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 /***
36 * TestProfilerService
37 *
38 * @author <a href="taylor@apache.org">David Sean Taylor</a>
39 * @version $Id: TestProfilerService.java,v 1.1 2004/04/07 22:02:42 jford Exp $
40 */
41
42 public class TestProfilerService extends JetspeedTestCase {
43
44 /***
45 * Defines the testcase name for JUnit.
46 *
47 * @param name the testcase's name.
48 */
49 public TestProfilerService( String name ) {
50 super( name );
51 }
52
53 /***
54 * Start the tests.
55 *
56 * @param args the arguments. Not used
57 */
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 /***
66 * Creates the test suite.
67 *
68 * @return a test suite (<code>TestSuite</code>) that includes all methods
69 * starting with "test"
70 */
71 public static Test suite() {
72
73 return new TestSuite( TestProfilerService.class );
74 }
75
76 /***
77 * Tests categories
78 * @throws Exception
79 */
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
101 File file = new File(doc.getName());
102 assertTrue(file.exists());
103
104 }
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
114
115
116
117 private static TurbineConfig config = null;
118
119
120
121
122
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