You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-user@jakarta.apache.org by Sadaf_Choudhry <Sa...@infosys.com> on 2004/07/29 17:09:23 UTC

Testing EJBs

Hi all!
 
How do I test EJB's through cactus? I have my EJBs deployed on weblogic
and my servlets are on tomcat.
Also, Is there any advantage of testing EJBs through cactus, rather than
plain vanilla junit? The java code is the same for both cases.
Also, the cactus web pages say:
*	Cactus provides automated Ant tasks to automatically start your
EJB server, run the tests and stop it, thus automating your entire test
process and making it easy to implement continuous build and continuous
integration of your J2EE project. 
 
How is this done? I mean, which tasks allow me to do this?
 
 
Sadaf

RE: Testing EJBs

Posted by Vincent Massol <vm...@pivolis.com>.
Hi Sadaf,

Please see http://jakarta.apache.org/cactus/writing/howto_ejb.html

-Vincent

> -----Original Message-----
> From: Sadaf_Choudhry [mailto:Sadaf_Choudhry@infosys.com]
> Sent: jeudi 29 juillet 2004 17:09
> To: cactus-user@jakarta.apache.org
> Subject: Testing EJBs
> 
> Hi all!
> 
> How do I test EJB's through cactus? I have my EJBs deployed on weblogic
> and my servlets are on tomcat.
> Also, Is there any advantage of testing EJBs through cactus, rather than
> plain vanilla junit? The java code is the same for both cases.
> Also, the cactus web pages say:
> *	Cactus provides automated Ant tasks to automatically start your
> EJB server, run the tests and stop it, thus automating your entire test
> process and making it easy to implement continuous build and continuous
> integration of your J2EE project.
> 
> How is this done? I mean, which tasks allow me to do this?
> 
> 
> Sadaf


RE: Testing EJBs

Posted by Bret Kumler <bk...@bitfone.com>.
Here's an example of how I use ANT to start/stop weblogic and execute the
tests.


<!-- Sarts weblogic -->

<target name="start.weblogic">
		<java classname="weblogic.Server" fork="yes"
dir="${target.weblogic81.dir}/testdomain">
			<classpath>
				<pathelement
location="${weblogic.home.81}/weblogic81/server/lib/weblogic.jar"/>
				<pathelement location="${tools.jar}"/>
				<pathelement location="${oracle.driver}"/>
				<pathelement location="${mysql.driver}"/>
				<pathelement location="${junit-jar}"/>
				<pathelement location="${log4j.jar}"/>
			</classpath>
			<jvmarg value="-hotspot"/>
			<jvmarg value="-ms512m"/>
			<jvmarg value="-mx512m"/>
			<jvmarg
value="-Djava.library.path=${java.library.path};${weblogic.home.81}/weblogic
81/server/bin"/>
			<jvmarg value="-Dweblogic.Name=testserver"/>
			<jvmarg value="-Dbea.home=${weblogic.home.81}"/>
			<jvmarg
value="-Dweblogic.management.username=${weblogic.username}"/>
			<jvmarg
value="-Dweblogic.management.password=${weblogic.password}"/>
			<jvmarg
value="-Djava.security.policy==./server/lib/weblogic.policy"/>
		</java>
	</target>



<!-- Stops weblogic -->

<target name="stop.weblogic">
		<java classname="weblogic.Admin" fork="yes">
			<classpath>
				<pathelement
location="${weblogic.home.81}/weblogic81/server/lib/weblogic.sp.jar"/>
				<pathelement
location="${weblogic.home.81}/weblogic81/server/lib/weblogic.jar"/>
			</classpath>
			<arg line="-url t3://${machine}:${test.port}"/>
			<arg line="-username ${weblogic.username}"/>
			<arg line="-password ${weblogic.password}"/>
			<arg value="FORCESHUTDOWN"/>
		</java>
	</target>


<!-- location of the actual tests -->

<target name="tests">
		<mkdir dir="${execution.dir}/tests/cactus"/>
		<!-- Run the tests -->
		<cactus
warfile="${execution.dir}/tests/testwar/${web.app.custcare}.war" fork="yes"
failureproperty="tests.failed" haltonerror="true">
			<cactusproperty server="false"
propertiesFile="${conf.dir}/log_client.properties"/>
			<cactusproperty server="true"
propertiesFile="${conf.dir}/log_server.properties"/>
			<classpath>
				<path refid="project.classpath"/>
				<pathelement
location="${execution.dir}/tests/lib/test.jar"/>
				<fileset dir="${execution.dir}"
includes="**/*.jar"/>
			</classpath>
			<containerset>
				<generic name="Weblogic 8.1.2.0"
port="${test.port}"/>
			</containerset>
			<formatter type="brief" usefile="false"/>
			<formatter type="xml"/>
			<batchtest todir="${execution.dir}/tests/cactus">
				<fileset dir="${test.classes}">
					<include name="**/*.class"/>
				</fileset>
			</batchtest>
		</cactus>
		<!-- Generate the JUnit reports -->
		<junitreport todir="${execution.dir}/tests/cactus">
			<fileset dir="${execution.dir}/tests/cactus"
includes="TEST-*.xml"/>
			<report todir="${execution.dir}/tests/cactus"
format="frames"/>
		</junitreport>
     
		<fail if="tests.failed">At least one test failed!</fail>
	</target>


<!-- Executes the actual tests -->

<target name="run.tests" depends="prepare.war" description="Run the tests
against Weblogic.">
		<echo message ="machine-name: ${machine}"/>
		<runservertests
testURL="http://${machine}:${test.port}/${web.app.custcare}/ServletRedirecto
r?Cactus_Service=RUN_TEST"
    			startTarget="start.weblogic"
    			stopTarget="stop.weblogic"
    			testTarget=" tests"/>
	</target>

-----Original Message-----
From: Sadaf_Choudhry [mailto:Sadaf_Choudhry@infosys.com] 
Sent: Thursday, July 29, 2004 8:09 AM
To: cactus-user@jakarta.apache.org
Subject: Testing EJBs

Hi all!
 
How do I test EJB's through cactus? I have my EJBs deployed on weblogic
and my servlets are on tomcat.
Also, Is there any advantage of testing EJBs through cactus, rather than
plain vanilla junit? The java code is the same for both cases.
Also, the cactus web pages say:
*	Cactus provides automated Ant tasks to automatically start your
EJB server, run the tests and stop it, thus automating your entire test
process and making it easy to implement continuous build and continuous
integration of your J2EE project. 
 
How is this done? I mean, which tasks allow me to do this?
 
 
Sadaf