You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Hugh Brien <hp...@home.com> on 2001/11/08 08:58:44 UTC
TestActon for Newbies
Since I am a newbie to Turbine and Jetspeed I thought I would contribute a
little test class I whipped up for testing my Action and Database Peer
classes. When testing my action classes I got sick firing up Tomcat to test
functionality. It also demonstrates creating service instances for calling.
Also this worked nicely with JBuilder. I hope some of you find this helpful.
Also to get this to work with Jetspeed you may have to modify your
JetspeedProperties file.
r,
Hugh
##########################################
# Remote Object Storage System #
##########################################
#Specify the directory that Jetspeed should
#cache XML documents to.
#for Win32 systems specify your directory as:
cache.directory=/d:/temp/JetspeedDocumentCache
#Default: /tmp/JetspeedDocumentCache
cache.directory=G:/jakarta-tomcat-3.2.3/webapps/jetspeed/WEB-INF/cache
#cache.directory=${webapp.dir}/WEB-INF/cache
#########################################
# Registry Service #
#########################################
services.Registry.classname=org.apache.jetspeed.services.registry.CastorRegi
stryService
#services.Registry.directory=${webapp.dir}/WEB-INF/conf/services.Registry.di
rectory=G:/jakarta-tomcat-3.2.3/webapps/jetspeed/WEB-INF
/conf/
services.Registry.mapping=G:/jakarta-tomcat-3.2.3/webapps/jetspeed/WEB-INF/c
onf/registry.xml
#services.Registry.mapping=${webapp.dir}/WEB-INF/conf/registry.xml
###########################################################################3
3
package com.novuscg.modules.actions;
import org.apache.turbine.util.TurbineConfig;
import org.apache.turbine.util.RunData;
import org.apache.turbine.services.TurbineServices;
import org.apache.turbine.services.db.*;
import org.apache.turbine.services.rundata.*;
import org.apache.turbine.services.cache.*;
import org.apache.turbine.services.security.*;
import org.apache.turbine.services.servlet.*;
import org.apache.turbine.services.pool.*;
import org.apache.turbine.services.factory.*;
import org.apache.turbine.services.pool.*;
import org.apache.turbine.services.resources.*;
import org.apache.turbine.services.assemblerbroker.*;
import org.apache.turbine.services.intake.*;
import org.apache.turbine.services.jsp.*;
import org.apache.turbine.services.localization.*;
import org.apache.turbine.services.mimetype.*;
import org.apache.turbine.services.schedule.*;
import org.apache.turbine.services.template.*;
import org.apache.turbine.services.uniqueid.*;
import org.apache.turbine.services.velocity.*;
import org.apache.turbine.services.xmlrpc.*;
import org.apache.turbine.services.xslt.*;
import org.apache.turbine.om.security.TurbineUser;
import org.apache.turbine.om.security.User;
import org.apache.velocity.context.Context;
import org.apache.velocity.VelocityContext;
import org.apache.turbine.modules.actions.*;
public class TestAction extends VelocityAction
{
SecurityService securityService;
GlobalCacheService cacheService;
RunDataService runDataService;
ServletService servletService;
PoolService poolService;
FactoryService factoryService;
ResourceService resourceService;
public TestAction()
{
TurbineConfig config = new
TurbineConfig("G:/jakarta-tomcat-3.2.3/webapps/jetspeed",
"WEB-INF/conf/TurbineResources.properties");
config.init();
file://We could use the Static Classes such as TurbineSecurity to
invoke
these classes
file://however I am instatiating them explicit for demonstration
purposes. I don't believe
file://services have and associated static class for calling service
methods
file://securityService.getAllGroups(); is the same as
TurbineSecurity.getAllGroups();
securityService =
(SecurityService)TurbineServices.getInstance().getService(SecurityService.SE
RVICE_NAME);
cacheService =
(GlobalCacheService)TurbineServices.getInstance().getService(GlobalCacheServ
ice.SERVICE_NAME);
poolService =
(PoolService)TurbineServices.getInstance().getService(PoolService.SERVICE_NA
ME);
factoryService =
(FactoryService)TurbineServices.getInstance().getService(FactoryService.SERV
ICE_NAME);
resourceService =
(ResourceService)TurbineServices.getInstance().getService(ResourceService.SE
RVICE_NAME);
}
public void initRundata(RunData runData)
{
try
{
runData.setAction("TestAction");
User user = securityService.getUser("hbrien");
runData.setUser(user);
}
catch (org.apache.turbine.util.security.UnknownEntityException ex)
{
ex.printStackTrace();
}
catch (org.apache.turbine.util.security.DataBackendException dbe)
{
dbe.printStackTrace();
}
}
public void initVelocityContext(Context context)
{
context.put("TEST", "TEST");
context.put("TEST1", "TEST");
context.put("TEST2", "TEST");
}
public void doPerform(RunData runData, Context context) throws
java.lang.Exception
{
System.out.println("Starting Action");
User user = runData.getUser();
String testStr = (String)context.get("TEST");
System.out.println(user.getUserName());
System.out.println(testStr);
System.out.println("Ending Action");
}
public static void main(String[] args)
{
TestAction testAction = new TestAction();
file://Create a RunData object to pass to doPerform
RunData rundata = new DefaultTurbineRunData();
file://Get a Context object to pass to doPerform
Context context = new VelocityContext();
file://initialize RunData
testAction.initRundata(rundata);
file://initialize Context
testAction.initVelocityContext(context);
try
{
file://Run Action
testAction.doPerform(rundata, context);
}
catch (Exception ex)
{
ex.printStackTrace();
}
System.exit(0);
}
}
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Turbine teacher/consultant wanted in DC to educate NASA coders?
Posted by Chris Shenton <Ch...@hq.nasa.gov>.
We're embarking on a project at NASA HQ to use servlets for a number
of applications. We've got a few people who have worked with small
servlets before but we realize we should be leveraging the power of a
framework. We've decided on Turbine due to its sophistication, but
are facing a very steep learning curve. Naturally, our project has a
short deadline so time is of the essence.
We have a go-ahead to hire a teacher, consultant, or experienced
Turbine developer to educate us in the basics of Turbine so we can be
productive quickly. We're thinking a couple or a few days, real
hands-on with our coder dudes, who are experienced programmers but
don't "get" Turbine yet.
I don't know the dollar figure they're talking about but I can put
interested parties in touch with people could can talk about such
things.
Anyone know of places (e.g., Learning Tree) who might offer this, or a
fellow developer in the DC area who's got plenty of Turbine
experience?
Thanks.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>