This project has retired. For details please refer to its
Attic page.
TestProfilerService xref
1/*2 * Copyright 2000-2001,2004 The Apache Software Foundation.3 * 4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */1617packageorg.apache.jetspeed.services.profiler;
1819import java.io.File;
2021// Junit imports22import junit.framework.Test;
23import junit.framework.TestSuite;
2425// Jetspeed imports26import org.apache.jetspeed.test.JetspeedTestCase;
27import org.apache.jetspeed.om.profile.*;
28import org.apache.jetspeed.om.profile.psml.*;
2930import org.apache.jetspeed.services.Profiler;
3132import org.apache.turbine.util.TurbineConfig;
33import org.apache.turbine.util.StringUtils;
3435/***36 * TestProfilerService37 *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 */4142publicclassTestProfilerServiceextendsJetspeedTestCase {
4344/***45 * Defines the testcase name for JUnit.46 *47 * @param name the testcase's name.48 */49publicTestProfilerService( String name ) {
50super( name );
51 }
5253/***54 * Start the tests.55 *56 * @param args the arguments. Not used57 */58publicstaticvoid main(String args[]) {
59 junit.awtui.TestRunner.main( new String[] { TestProfilerService.class.getName() } );
60 }
6162publicvoid 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 methods69 * starting with "test"70 */71publicstatic Test suite() {
72// All methods starting with "test" will be executed in the test suite.73returnnew TestSuite( TestProfilerService.class );
74 }
7576/***77 * Tests categories78 * @throws Exception79 */80publicvoid testCreateProfile() throws Exception
81 {
82try83 {
84 ProfileLocator locator = Profiler.createLocator();
85 locator.setGroupByName("apache");
86 locator.setName("create-test");
8788 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();
9798 System.out.println("doc = " + doc.getName());
99100// this only works with the default configuration (Castor/Filebased)101 File file = new File(doc.getName());
102 assertTrue(file.exists());
103//file.delete();104 }
105catch (Exception e)
106 {
107 String errmsg = "Error in Profiler Service: " + e.toString();
108 e.printStackTrace();
109 assertNotNull(errmsg, null);
110 }
111 }
112113/*114 Configuration object to run Turbine outside a servlet container115 ( uses turbine.properties )116 */117privatestatic TurbineConfig config = null;
118119/*120 Sets up TurbineConfig using the system property:121 <pre>turbine.properties</pre>122 */123static124 {
125try126 {
127 config = new TurbineConfig( "webapp", "/WEB-INF/conf/TurbineResources.properties");
128 config.init();
129 }
130catch (Exception e)
131 {
132 fail(StringUtils.stackTrace(e));
133 }
134 }
135 }
136